From e33c049c36cab1ea6ce61d8255f43c8d819a0ea0 Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Thu, 6 Nov 2025 13:35:45 -0800 Subject: [PATCH] fix lint/fmt issues --- codex-rs/tui/src/terminal_palette.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/codex-rs/tui/src/terminal_palette.rs b/codex-rs/tui/src/terminal_palette.rs index ed31808395..b6eb53baaf 100644 --- a/codex-rs/tui/src/terminal_palette.rs +++ b/codex-rs/tui/src/terminal_palette.rs @@ -1,6 +1,8 @@ use crate::color::perceptual_distance; use ratatui::style::Color; +#[cfg(not(test))] use std::sync::LazyLock; +#[cfg(not(test))] use std::sync::Mutex; #[cfg(windows)] use std::sync::OnceLock; @@ -74,10 +76,11 @@ pub fn stdout_supports_truecolor() -> bool { fn enable_vt_stdout() -> std::io::Result<()> { use std::io; use windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE; - use windows_sys::Win32::System::Console::{ - ENABLE_VIRTUAL_TERMINAL_PROCESSING, GetConsoleMode, GetStdHandle, STD_OUTPUT_HANDLE, - SetConsoleMode, - }; + use windows_sys::Win32::System::Console::ENABLE_VIRTUAL_TERMINAL_PROCESSING; + use windows_sys::Win32::System::Console::GetConsoleMode; + use windows_sys::Win32::System::Console::GetStdHandle; + use windows_sys::Win32::System::Console::STD_OUTPUT_HANDLE; + use windows_sys::Win32::System::Console::SetConsoleMode; unsafe { let handle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -131,11 +134,13 @@ pub fn default_bg() -> Option<(u8, u8, u8)> { /// `get_or_init_with` for the first successful query and `refresh_with` for a manual re-query. /// If a first query fails, we remember the failure to avoid repeated failed probes, unless /// a subsequent explicit refresh is performed. +#[cfg(not(test))] struct Cache { attempted: bool, value: Option, } +#[cfg(not(test))] impl Default for Cache { fn default() -> Self { Self { @@ -145,6 +150,7 @@ impl Default for Cache { } } +#[cfg(not(test))] impl Cache { /// Returns the cached value if available; otherwise runs `init` once and caches its result. fn get_or_init_with(&mut self, mut init: impl FnMut() -> Option) -> Option { @@ -163,6 +169,7 @@ impl Cache { } } +#[cfg(not(test))] fn default_terminal_colors_cache() -> &'static Mutex> { // LazyLock creates the single cache instance; the Mutex guards concurrent refreshes/reads. static CACHE: LazyLock>> =