fix: clip inline blame instead of hiding long metadata

The full-label width check hid current-line attribution when only part of the commit metadata fit. Render into the remaining cells without covering source text; preserve offscreen and no-space guards.
This commit is contained in:
Valdemar Lorenzen
2026-10-20 12:06:54 +02:00
parent 4fb1be7972
commit eae3bdba16
5 changed files with 49 additions and 3 deletions
+42
View File
@@ -6500,6 +6500,48 @@ fn inline_blame_is_visible_in_focused_diff_buffers() {
}
}
#[test]
fn inline_blame_remains_visible_on_lines_with_room_for_partial_metadata() {
let directory = Directory::new();
for (context, width) in [("document", 80), ("split", 180), ("unified", 120)] {
let text = "short\nlet meaningful_identifier = call_with_arguments();\ntail";
let mut editor = if context == "document" {
Editor::open(Some(directory.file("file.txt", text)), vec![]).unwrap()
} else {
let mut editor = readonly_diff_editor(syntax_diff_file("file.txt", text, "changed"));
if context == "unified" {
editor.execute("diff.view.toggle");
}
editor.handle(Input::Char('\t'));
editor
};
let source = editor.blame_source().unwrap();
let blame = Arc::new(crate::blame::LineBlame {
commit: "0123456789abcdef".into(),
author: "界 e\u{301} Author".into(),
summary: "A detailed commit summary describing the source change".into(),
uncommitted: false,
});
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(width, 12)).unwrap();
let mut views = BufferViewports::default();
for row in 0..3 {
assert_eq!(editor.cursor().row, row);
editor.set_cached_line_blame(&source, blame.clone());
terminal
.draw(|frame| views.draw(frame, &mut editor))
.unwrap();
let caret = terminal.get_cursor_position().unwrap();
let line = pane_screen(&terminal, Rect::new(0, caret.y, width, 1));
assert!(
line.contains("Author") && line.contains("e\u{301}"),
"{context}, source row={row}: {line}"
);
assert!(line.contains(editor.lines()[row].as_str()), "{line}");
editor.handle(Input::Down);
}
}
}
#[test]
fn diff_blame_uses_final_wrap_and_survives_a_historical_tab() {
for unified in [false, true] {