feat: wrap diff review comments by default

This commit is contained in:
2026-10-17 01:27:38 +02:00
parent d8be35e3bd
commit e9a757adc5
5 changed files with 60 additions and 1 deletions
+52
View File
@@ -8030,6 +8030,58 @@ fn review_editor_floats_over_the_diff_without_changing_workspace_layout() {
}
}
#[test]
fn review_prose_wraps_by_default_without_changing_text_or_source_wrapping() {
for unified in [false, true] {
let mut editor = readonly_diff_editor(syntax_diff_file("file.txt", "old", "new"));
if unified {
editor.execute("diff.view.toggle");
}
editor.handle(Input::Char('\t'));
let text = format!("{}wrapped_tail", "prose ".repeat(20));
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(80, 30)).unwrap();
let mut views = BufferViewports::default();
for command in ["diff.comment", "diff.review.summary"] {
editor.execute(command);
editor.handle(Input::Char('i'));
editor.handle(Input::Paste(text.clone()));
editor.handle(Input::Escape);
editor.handle(Input::Home);
terminal
.draw(|frame| views.draw(frame, &mut editor))
.unwrap();
let screen = screen_text(&terminal);
let first = screen
.lines()
.position(|line| line.contains("prose"))
.unwrap();
let tail = screen
.lines()
.position(|line| line.contains("wrapped_tail"))
.expect("comment tail must be visible without horizontal scrolling");
assert!(tail > first, "{command}: {screen}");
assert_eq!(editor.context().text, text);
editor.handle(Input::Escape);
assert!(!editor.word_wrap());
}
editor.execute("diff.review.overview");
assert!(editor.word_wrap());
editor.handle(Input::Escape);
editor.execute("diff.review.edit 1");
editor.execute("word_wrap.toggle");
assert!(!editor.word_wrap());
editor.handle(Input::Escape);
editor.execute("diff.review.edit 1");
assert!(
!editor.word_wrap(),
"reopening must retain the user's toggle"
);
assert_eq!(editor.context().text, text);
editor.handle(Input::Escape);
assert!(!editor.word_wrap());
}
}
#[test]
fn scope_projection_keeps_unified_wrapped_caret_and_selection_source_only() {
let before = format!(