fix: retain semantic colors across editable diff updates
This commit is contained in:
+31
-2
@@ -13669,6 +13669,34 @@ end
|
||||
}
|
||||
editor.handle(Input::Char('\t'));
|
||||
}
|
||||
if writable {
|
||||
while editor.diff_buffer_focus() != Some(Focus::After)
|
||||
|| editor.diff().unwrap().focus != Focus::After
|
||||
{
|
||||
editor.handle(Input::Char('\t'));
|
||||
}
|
||||
assert!(editor.diff_editing());
|
||||
editor.handle(Input::Char('A'));
|
||||
assert_eq!(editor.mode(), Mode::Insert);
|
||||
for input in " // typing".chars().map(Input::Char).chain([
|
||||
Input::Escape,
|
||||
Input::Char('u'),
|
||||
Input::Char('U'),
|
||||
]) {
|
||||
editor.handle(input.clone());
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
let regions = views.panels.diff.as_ref().unwrap().regions;
|
||||
for (index, color) in [(1, Color::LightCyan), (2, Color::LightBlue)] {
|
||||
let pane = regions[index].0;
|
||||
let cell = &terminal.backend().buffer()[(pane.x + 8, pane.y + 1)];
|
||||
assert_eq!(cell.symbol(), "v");
|
||||
assert_eq!(cell.fg, color, "semantic color flashed after {input:?}");
|
||||
}
|
||||
}
|
||||
assert_eq!(editor.lines(), ["let value = 2; // typing"]);
|
||||
}
|
||||
editor
|
||||
.replace_semantic_tokens(editor.buffer_id(), editor.text_revision(), None)
|
||||
.unwrap();
|
||||
@@ -15084,8 +15112,9 @@ end
|
||||
assert_eq!(buffer[(0, 0)].fg, Color::Reset);
|
||||
assert_eq!(editor.lines(), &[source]);
|
||||
}
|
||||
editor.handle(Input::Char('x'));
|
||||
assert!(editor.semantic_tokens().is_empty());
|
||||
editor
|
||||
.replace_semantic_tokens(editor.buffer_id(), editor.text_revision(), None)
|
||||
.unwrap();
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(20, 4)).unwrap();
|
||||
let (mut top, mut left) = (0, 0);
|
||||
terminal
|
||||
|
||||
Reference in New Issue
Block a user