diff --git a/codex-rs/tui/src/diff_render.rs b/codex-rs/tui/src/diff_render.rs index a7d0dfe134..aa0481d044 100644 --- a/codex-rs/tui/src/diff_render.rs +++ b/codex-rs/tui/src/diff_render.rs @@ -665,6 +665,8 @@ fn wrap_styled_spans(spans: &[RtSpan<'static>], max_cols: usize) -> Vec &'static RwLock { /// Swap the active syntax theme at runtime (for live preview). pub(crate) fn set_syntax_theme(theme: Theme) { - if let Ok(mut guard) = theme_lock().write() { - *guard = theme; - } + let mut guard = match theme_lock().write() { + Ok(guard) => guard, + Err(poisoned) => poisoned.into_inner(), + }; + *guard = theme; } /// Clone the current syntax theme (e.g. to save for cancel-restore). @@ -317,6 +319,9 @@ pub(crate) fn list_available_themes(codex_home: Option<&Path>) -> Vec = entries + .iter() + .map(|entry| (entry.is_custom, entry.name.clone())) + .collect(); + + let mut expected = actual.clone(); + expected.sort_by(|a, b| (a.0, a.1.as_str()).cmp(&(b.0, b.1.as_str()))); + + assert_eq!( + actual, expected, + "theme entries should be stable and sorted (builtins first, then custom by name)" + ); + } + #[test] fn parse_theme_name_is_exhaustive() { use two_face::theme::EmbeddedLazyThemeSet;