diff --git a/src/core.rs b/src/core.rs index 4ec4ee53b..97472ec40 100644 --- a/src/core.rs +++ b/src/core.rs @@ -64,12 +64,17 @@ impl Core { let icon_separator = flags.icons.separator.0.clone(); + // The output is not a tty, this means the command is piped. e.g. + // + // lsd -l | less + // + // Most of the programs does not handle correctly the ansi colors + // or require a raw output (like the `wc` command). if !tty_available { - // The output is not a tty, this means the command is piped. (ex: lsd -l | less) - // - // Most of the programs does not handle correctly the ansi colors - // or require a raw output (like the `wc` command). - flags.layout = Layout::OneLine; + // we should not overwrite the tree layout + if flags.layout != Layout::Tree { + flags.layout = Layout::OneLine; + } flags.literal = Literal(true); }; diff --git a/tests/integration.rs b/tests/integration.rs index 11ef41f0b..91fec677b 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -322,6 +322,7 @@ fn test_dereference_link_broken_link_output() { .stdout(predicate::str::starts_with("l????????? ? ? ? ?")); } +/// should work both tty available and not #[cfg(unix)] #[test] fn test_show_folder_content_of_symlink() {