diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-16 00:05:24 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-16 00:05:24 +0300 |
| commit | 2b4b3849ca7760d6fcff10cd560553bb8081a8e2 (patch) | |
| tree | ae2439467edc2595d632ade5f17affaaa558caf4 /src/terminal_theme.rs | |
| parent | 9166e07b31f920540802fe46cbe3c0d52eece2bd (diff) | |
fix(theme): skip host palette queries under wsl (#2852)
refs #2440
Diffstat (limited to 'src/terminal_theme.rs')
| -rw-r--r-- | src/terminal_theme.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/terminal_theme.rs b/src/terminal_theme.rs index 3f04cc4c..2460731e 100644 --- a/src/terminal_theme.rs +++ b/src/terminal_theme.rs @@ -79,12 +79,14 @@ impl TerminalTheme { } } -pub fn host_terminal_theme_query_sequence() -> String { +pub fn host_terminal_theme_query_sequence(include_palette: bool) -> String { use std::fmt::Write as _; let mut sequence = String::from(HOST_COLOR_QUERY_SEQUENCE); - for index in 0..=u8::MAX { - let _ = write!(sequence, "\x1b]4;{index};?\x1b\\"); + if include_palette { + for index in 0..=u8::MAX { + let _ = write!(sequence, "\x1b]4;{index};?\x1b\\"); + } } sequence } @@ -218,11 +220,16 @@ mod tests { )) ); - let query = host_terminal_theme_query_sequence(); + let query = host_terminal_theme_query_sequence(true); assert!(query.starts_with(HOST_COLOR_QUERY_SEQUENCE)); assert!(query.contains("\x1b]4;0;?\x1b\\")); assert!(query.ends_with("\x1b]4;255;?\x1b\\")); assert_eq!(query.matches("\x1b]4;").count(), 256); + + assert_eq!( + host_terminal_theme_query_sequence(false), + HOST_COLOR_QUERY_SEQUENCE + ); } #[test] |
