should not overwrite tree layout when tty not available

Signed-off-by: Wei Zhang <kweizh@gmail.com>
This commit is contained in:
Wei Zhang 2024-08-14 00:48:55 +08:00
parent b64905709a
commit c433da0dfd
2 changed files with 11 additions and 5 deletions

View file

@ -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);
};

View file

@ -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() {