mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
ls: fix grid alignment with --color
This commit is contained in:
parent
7dcc8c2960
commit
cfc11b47a5
1 changed files with 9 additions and 1 deletions
|
@ -1615,6 +1615,10 @@ fn display_file_name(path: &PathData, strip: Option<&Path>, config: &Config) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to keep track of the width ourselfs instead of letting term_grid
|
||||||
|
// infer it because the color codes mess up term_grid's width calculation.
|
||||||
|
let mut width = name.len();
|
||||||
|
|
||||||
if let Some(ls_colors) = &config.color {
|
if let Some(ls_colors) = &config.color {
|
||||||
name = color_name(&ls_colors, &path.p_buf, name, path.md()?);
|
name = color_name(&ls_colors, &path.p_buf, name, path.md()?);
|
||||||
}
|
}
|
||||||
|
@ -1643,6 +1647,7 @@ fn display_file_name(path: &PathData, strip: Option<&Path>, config: &Config) ->
|
||||||
|
|
||||||
if let Some(c) = char_opt {
|
if let Some(c) = char_opt {
|
||||||
name.push(c);
|
name.push(c);
|
||||||
|
width += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,7 +1658,10 @@ fn display_file_name(path: &PathData, strip: Option<&Path>, config: &Config) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(name.into())
|
Some(Cell {
|
||||||
|
contents: name,
|
||||||
|
width,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn color_name(ls_colors: &LsColors, path: &Path, name: String, md: &Metadata) -> String {
|
fn color_name(ls_colors: &LsColors, path: &Path, name: String, md: &Metadata) -> String {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue