Skip to content

Commit

Permalink
✨ should not overwrite tree layout when tty not available
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Aug 13, 2024
1 parent 1bc6e13 commit 4fc6846
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
1 change: 1 addition & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4fc6846

Please sign in to comment.