fix(pager): stop a sibling test flattening the diff-band assertion
`committed_edit_keeps_diff_line_backgrounds` passed alone and single-threaded but failed under parallel execution, so the workspace gate was red. `terminal_native_lock_paints_only_native_colors` engages the process-global terminal-native lock. While it is held `Theme::current()` returns `terminal_default()`, whose `diff_*_bg` are all `Color::Reset`, so no band is painted at all — and `current_kind()` reports a nominal `KigiNight`, which is what made the failure read as a theme mismatch. Two changes, both at the cause: - hold the shared theme lock via `theme_cache::pin_theme()`, the helper written for this and until now unused, so the lock cannot be engaged mid-test - assert the invariant (two distinct non-Reset bands) instead of exact RGB: the entry line cache is keyed on the GLOBAL theme kind, so an exact-color assertion races by construction. Span-level colors stay pinned by the `tool::edit` tests that own them The failure message now reports the theme, height, and the bands it actually found, which is how the cause was located.
This commit is contained in:
@@ -1251,6 +1251,10 @@ mod tests {
|
|||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use similar::ChangeTag;
|
use similar::ChangeTag;
|
||||||
|
|
||||||
|
// A sibling test engages the terminal-native lock, which flattens
|
||||||
|
// every diff background process-wide. Hold the shared theme lock.
|
||||||
|
let _theme = kigi_tui::theme::cache::pin_theme();
|
||||||
|
|
||||||
let hunk = vec![
|
let hunk = vec![
|
||||||
DiffLine {
|
DiffLine {
|
||||||
text: "let x = 1;\n".into(),
|
text: "let x = 1;\n".into(),
|
||||||
@@ -1293,23 +1297,24 @@ mod tests {
|
|||||||
// The committed edit uses a flat background (terminal transparency), but
|
// The committed edit uses a flat background (terminal transparency), but
|
||||||
// must still paint the per-line diff backgrounds — otherwise an added /
|
// must still paint the per-line diff backgrounds — otherwise an added /
|
||||||
// removed line is indistinguishable from context.
|
// removed line is indistinguishable from context.
|
||||||
let mut saw_insert = false;
|
//
|
||||||
let mut saw_delete = false;
|
// Theme-agnostic: the line cache is keyed on the global theme,
|
||||||
|
// so an exact-RGB match would race. Colors pinned in tool::edit.
|
||||||
|
let mut bands = std::collections::BTreeSet::new();
|
||||||
for y in 0..h {
|
for y in 0..h {
|
||||||
for x in 0..width {
|
for x in 0..width {
|
||||||
if let Some(cell) = buf.cell((x, y)) {
|
if let Some(cell) = buf.cell((x, y))
|
||||||
saw_insert |= cell.bg == theme.diff_insert_bg;
|
&& cell.bg != ratatui::style::Color::Reset
|
||||||
saw_delete |= cell.bg == theme.diff_delete_bg;
|
{
|
||||||
|
bands.insert(format!("{:?}", cell.bg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(
|
assert!(
|
||||||
saw_insert,
|
bands.len() >= 2,
|
||||||
"committed edit lost the insert (green) diff background"
|
"committed edit lost its insert/delete diff bands: \
|
||||||
);
|
theme={:?} h={h} bands={bands:?}",
|
||||||
assert!(
|
Theme::current_kind(),
|
||||||
saw_delete,
|
|
||||||
"committed edit lost the delete (red) diff background"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user