Highlight selected newlines in the transcript view (#47068)

## Why

Transcript selections could include a newline without showing it in the highlight, making `code` and `code\n` look identical.

## What changed

Highlight one trailing cell for selected hard line breaks when space permits, including newline separators between transcript entries. Track logical line endings so soft wraps and synthetic rows do not receive newline highlights.

## Testing

Add selection snapshots for hard breaks within and between entries, plus layout coverage for empty lines, wrapping, trailing whitespace, and synthetic rows. Update the app selection test to assert the leading newline highlight.

GitOrigin-RevId: d6f332c472598a3f79557b7ebb41730c6acc7820
This commit is contained in:
Eric Traut
2026-09-21 16:42:35 +00:00
committed by copyberry
parent a4c8fc7a6b
commit f07aaf920b
6 changed files with 151 additions and 7 deletions
@@ -62,7 +62,7 @@ async fn text_selection_temporarily_replaces_the_rendered_backtrack_highlight()
.await?;
let (_, highlighted) = render(&mut app);
assert_eq!(highlighted, "");
// The display-only blank before a user message may be the selection's first source row.
// The selection starts on the leading blank source row before the user message.
for _ in 0..2 {
app.handle_tui_event(
&mut tui,
@@ -72,9 +72,8 @@ async fn text_selection_temporarily_replaces_the_rendered_backtrack_highlight()
.await?;
}
let (_, highlighted) = render(&mut app);
assert!(!highlighted.is_empty());
assert!(prompt.starts_with(&highlighted));
assert!(highlighted.len() < prompt.len());
// The selected leading newline paints one blank cell before the first prompt character.
assert_eq!(highlighted, " S");
app.handle_tui_event(
&mut tui,