From 2b4b3849ca7760d6fcff10cd560553bb8081a8e2 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Sun, 16 Aug 2026 00:05:24 +0300 Subject: fix(theme): skip host palette queries under wsl (#2852) refs #2440 --- src/terminal_theme.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/terminal_theme.rs') 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] -- cgit v1.2.3