From 172590380af329ebcd04b24fa874bc765bc56f52 Mon Sep 17 00:00:00 2001 From: Patrick Sean Klein Date: Sun, 6 Oct 2024 15:24:13 +0100 Subject: [PATCH] fix: do not print parent filename with --absolute=on The parent path of a file was added even with absolute={on,follow}, causing the parent path being prepended to the resolved (absolute) filepath. Fixes: #1151 --- src/output/file_name.rs | 2 +- tests/cmd/absolute_file_all.stderr | 0 tests/cmd/absolute_file_all.stdout | 1 + tests/cmd/absolute_file_all.toml | 2 ++ 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/cmd/absolute_file_all.stderr create mode 100644 tests/cmd/absolute_file_all.stdout create mode 100644 tests/cmd/absolute_file_all.toml diff --git a/src/output/file_name.rs b/src/output/file_name.rs index ea4f5a00..ae232a3d 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -237,7 +237,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> { bits.push(style.paint(" ".repeat(spaces_count as usize))); } - if self.file.parent_dir.is_none() { + if self.file.parent_dir.is_none() && self.options.absolute == Absolute::Off { if let Some(parent) = self.file.path.parent() { self.add_parent_bits(&mut bits, parent); } diff --git a/tests/cmd/absolute_file_all.stderr b/tests/cmd/absolute_file_all.stderr new file mode 100644 index 00000000..e69de29b diff --git a/tests/cmd/absolute_file_all.stdout b/tests/cmd/absolute_file_all.stdout new file mode 100644 index 00000000..3bbe5cbb --- /dev/null +++ b/tests/cmd/absolute_file_all.stdout @@ -0,0 +1 @@ +[CWD]/tests/itest/index.svg diff --git a/tests/cmd/absolute_file_all.toml b/tests/cmd/absolute_file_all.toml new file mode 100644 index 00000000..4666e76d --- /dev/null +++ b/tests/cmd/absolute_file_all.toml @@ -0,0 +1,2 @@ +bin.name = "eza" +args = "tests/itest/index.svg --absolute"