Skip to content

Commit 0a92b86

Browse files
committed
list: Don't color directories on accessible mode
1 parent e141617 commit 0a92b86

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/list.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,9 @@ fn print_entry(out: &mut impl Write, name: impl fmt::Display, file_type: &ListFi
101101
let name_str = name.to_string();
102102
let display_name = name_str.strip_suffix('/').unwrap_or(&name_str);
103103

104-
let output = if BLUE.is_empty() {
105-
// Colors are deactivated, print final / to mark directories
104+
let output = if *DISABLE_COLORED_TEXT || is_running_in_accessible_mode() {
105+
// Don't use colors and print trailing slash to mark directories
106106
format!("{display_name}/")
107-
} else if is_running_in_accessible_mode() {
108-
// Accessible mode: use colors but print final / for screen readers
109-
format!("{}{}{}/{}", *BLUE, *STYLE_BOLD, display_name, *ALL_RESET)
110107
} else {
111108
// Normal mode: use colors without trailing slash
112109
format!("{}{}{}{}", *BLUE, *STYLE_BOLD, display_name, *ALL_RESET)

src/utils/colors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
sync::LazyLock,
1010
};
1111

12-
static DISABLE_COLORED_TEXT: LazyLock<bool> = LazyLock::new(|| {
12+
pub static DISABLE_COLORED_TEXT: LazyLock<bool> = LazyLock::new(|| {
1313
io::stdout().is_terminal().not() || io::stderr().is_terminal().not() || env::var_os("NO_COLOR").is_some()
1414
});
1515

0 commit comments

Comments
 (0)