mirror of
https://github.com/eza-community/eza
synced 2024-09-06 00:13:51 +00:00
refactor(file): do not match for numbers and remove single-use fn
This commit is contained in:
parent
43dd047c56
commit
404faa64bf
|
@ -101,7 +101,7 @@ pub enum ShowIcons {
|
|||
|
||||
/// Show icons next to file names, with the given number of spaces between
|
||||
/// the icon and the file name.
|
||||
On(u32),
|
||||
On(usize),
|
||||
}
|
||||
|
||||
/// Whether to embed hyperlinks.
|
||||
|
@ -182,11 +182,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
|
|||
|
||||
bits.push(style.paint(file_icon));
|
||||
|
||||
match spaces_count {
|
||||
1 => bits.push(style.paint(" ")),
|
||||
2 => bits.push(style.paint(" ")),
|
||||
n => bits.push(style.paint(spaces(n))),
|
||||
}
|
||||
bits.push(style.paint(" ".repeat(spaces_count)));
|
||||
}
|
||||
|
||||
if self.file.parent_dir.is_none() {
|
||||
|
@ -475,8 +471,3 @@ pub trait Colours: FiletypeColours {
|
|||
|
||||
fn colour_file(&self, file: &File<'_>) -> Style;
|
||||
}
|
||||
|
||||
/// Generate a string made of `n` spaces.
|
||||
fn spaces(width: u32) -> String {
|
||||
(0..width).map(|_| ' ').collect()
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a> Render<'a> {
|
|||
let contents = filename.paint();
|
||||
#[rustfmt::skip]
|
||||
let width = match (filename.options.embed_hyperlinks, filename.options.show_icons) {
|
||||
(EmbedHyperlinks::On, ShowIcons::On(spacing)) => filename.bare_width() + 1 + (spacing as usize),
|
||||
(EmbedHyperlinks::On, ShowIcons::On(spacing)) => filename.bare_width() + 1 + spacing,
|
||||
(EmbedHyperlinks::On, ShowIcons::Off) => filename.bare_width(),
|
||||
(EmbedHyperlinks::Off, _) => *contents.width(),
|
||||
};
|
||||
|
|
|
@ -164,7 +164,7 @@ impl<'a> Render<'a> {
|
|||
let contents = filename.paint();
|
||||
#[rustfmt::skip]
|
||||
let width = match (filename.options.embed_hyperlinks, filename.options.show_icons) {
|
||||
(EmbedHyperlinks::On, ShowIcons::On(spacing)) => filename.bare_width() + 1 + (spacing as usize),
|
||||
(EmbedHyperlinks::On, ShowIcons::On(spacing)) => filename.bare_width() + 1 + spacing,
|
||||
(EmbedHyperlinks::On, ShowIcons::Off) => filename.bare_width(),
|
||||
(EmbedHyperlinks::Off, _) => *contents.width(),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue