mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-22 12:05:11 +00:00
Add classify char to symlink targets
Fixes GH-589.
This commit is contained in:
parent
b1c49341c0
commit
dbd11d3804
@ -173,7 +173,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
|
|||||||
show_icons: ShowIcons::Off,
|
show_icons: ShowIcons::Off,
|
||||||
};
|
};
|
||||||
|
|
||||||
let target = FileName {
|
let target_name = FileName {
|
||||||
file: target,
|
file: target,
|
||||||
colours: self.colours,
|
colours: self.colours,
|
||||||
target: None,
|
target: None,
|
||||||
@ -181,9 +181,15 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
|
|||||||
options: target_options,
|
options: target_options,
|
||||||
};
|
};
|
||||||
|
|
||||||
for bit in target.coloured_file_name() {
|
for bit in target_name.coloured_file_name() {
|
||||||
bits.push(bit);
|
bits.push(bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Classify::AddFileIndicators = self.options.classify {
|
||||||
|
if let Some(class) = self.classify_char(target) {
|
||||||
|
bits.push(Style::default().paint(class));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +212,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if let Classify::AddFileIndicators = self.options.classify {
|
else if let Classify::AddFileIndicators = self.options.classify {
|
||||||
if let Some(class) = self.classify_char() {
|
if let Some(class) = self.classify_char(self.file) {
|
||||||
bits.push(Style::default().paint(class));
|
bits.push(Style::default().paint(class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,20 +241,20 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
|
|||||||
|
|
||||||
/// The character to be displayed after a file when classifying is on, if
|
/// The character to be displayed after a file when classifying is on, if
|
||||||
/// the file’s type has one associated with it.
|
/// the file’s type has one associated with it.
|
||||||
fn classify_char(&self) -> Option<&'static str> {
|
fn classify_char(&self, file: &File<'_>) -> Option<&'static str> {
|
||||||
if self.file.is_executable_file() {
|
if file.is_executable_file() {
|
||||||
Some("*")
|
Some("*")
|
||||||
}
|
}
|
||||||
else if self.file.is_directory() {
|
else if file.is_directory() {
|
||||||
Some("/")
|
Some("/")
|
||||||
}
|
}
|
||||||
else if self.file.is_pipe() {
|
else if file.is_pipe() {
|
||||||
Some("|")
|
Some("|")
|
||||||
}
|
}
|
||||||
else if self.file.is_link() {
|
else if file.is_link() {
|
||||||
Some("@")
|
Some("@")
|
||||||
}
|
}
|
||||||
else if self.file.is_socket() {
|
else if file.is_socket() {
|
||||||
Some("=")
|
Some("=")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -43,3 +43,11 @@ stdout = { file = "outputs/specials_long_classify.ansitxt" }
|
|||||||
stderr = { empty = true }
|
stderr = { empty = true }
|
||||||
status = 0
|
status = 0
|
||||||
tags = [ 'long', 'classify' ]
|
tags = [ 'long', 'classify' ]
|
||||||
|
|
||||||
|
[[cmd]]
|
||||||
|
name = "‘exa -lF’ handles and classifies symlink kinds"
|
||||||
|
shell = "exa -lF --no-time /testcases/links"
|
||||||
|
stdout = { file = "outputs/links_long_classify.ansitxt" }
|
||||||
|
stderr = { empty = true }
|
||||||
|
status = 0
|
||||||
|
tags = [ 'long', 'classify' ]
|
||||||
|
10
xtests/outputs/links_long_classify.ansitxt
Normal file
10
xtests/outputs/links_long_classify.ansitxt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m7[0m [1;33mvagrant[0m [36mbroken[0m [31m->[0m [4;31mnowhere[0m
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m1[0m [1;33mvagrant[0m [36mcurrent_dir[0m [38;5;244m->[0m [1;34m.[0m/
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m12[0m [1;33mvagrant[0m [36mforbidden[0m [31m->[0m [4;31m/proc/1/root[0m
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m6[0m [1;33mvagrant[0m [36mitself[0m [31m->[0m [4;31mitself[0m
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m2[0m [1;33mvagrant[0m [36mparent_dir[0m [38;5;244m->[0m [1;34m..[0m/
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m1[0m [1;33mvagrant[0m [36mroot[0m [38;5;244m->[0m [1;34m/[0m/
|
||||||
|
.[1;33mr[31mw[0m[38;5;244m-[33mr[31mw[38;5;244m-[33mr[38;5;244m--[0m [1;32m0[0m [1;33mvagrant[0m some_file
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m26[0m [1;33mvagrant[0m [36msome_file_absolute[0m [38;5;244m->[0m [36m/testcases/links/[0msome_file
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m9[0m [1;33mvagrant[0m [36msome_file_relative[0m [38;5;244m->[0m some_file
|
||||||
|
[36ml[1;33mr[31mw[32mx[0m[33mr[31mw[32mx[33mr[31mw[32mx[0m [1;32m4[0m [1;33mvagrant[0m [36musr[0m [38;5;244m->[0m [36m/[1;34musr[0m/
|
Loading…
Reference in New Issue
Block a user