Repository navigation
Enable copy from the Review preview panel - #218
Merged
Merged
Conversation
The right-side Review diff is painted by a custom DiffRows element inside a virtualized list, so its text was not selectable. Add whole-line selection: drag to select lines across a file's diff chunks, then copy with Cmd/Ctrl-C or the header Copy button (e.g. to paste code into the chat). - diff_rows: optional RowSelection on DiffRows — paints a selection highlight behind the glyphs and registers pointer listeners that map a position to a flat line index (base_line + row under the cursor). - diff_card: thread an optional selection through render_diff_chunk / render_diff_rows (tool-card diffs stay non-selectable). - review_view: hold the selection per file, begin/extend/end on pointer events via a weak handle, copy the joined lines, clear it when the file leaves the listing or the session changes. Tests cover the y->row mapping and cross-chunk line joining.
Reuse the review panel's selectable-rows infrastructure for the edit/replace_in_file/write_file diff cards: drag-select whole lines, then copy via a header Copy button or Cmd/Ctrl-C. - BlockView owns the per-card selection (flat line indices across the card's diff sections) plus a focus handle for keyboard copy. - CardRenderContext carries the focus handle and current selection range. - render_prepared_diff/render_diff_lines thread a RowSelection per section, wired to the BlockView via a weak handle (mirrors ReviewView). - Header shows a Copy button while a selection exists; the card is focusable and handles Cmd/Ctrl-C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The right-side Review diff is painted by a custom
DiffRowsGPUI element (raw glyph painting) inside a virtualized list, so its text wasn't selectable — you couldn't copy anything out of it (e.g. to paste a snippet into the chat).This adds whole-line text selection to the Review diff:
Cmd/Ctrl+C(clicking a diff focuses the panel) or the Copy button that appears in the panel header while a selection exists.+/-gutters), joined by newlines.Selection is line-granular rather than character-level: it's the natural unit for grabbing code, and it keeps hit-testing and painting robust over wrapped, virtualized rows without regressing the perf-oriented
DiffRowsdesign.How
tool_cards/diff_rows.rs— optionalRowSelectiononDiffRows: paints a selection highlight behind the glyphs (above the add/delete tint, below the text) and registers pointer listeners that map a position to a flat line index (base_line+ the row under the cursor). Tool-card diffs stay non-selectable.tool_cards/diff_card.rs— thread the optional selection throughrender_diff_chunk/render_diff_rows.main_screen/right_panel/review_view.rs— hold the selection per file; begin/extend/end on pointer events via a weak entity handle (so the static element closures never borrow the view); copy the joined lines; clear the selection when the file leaves the listing or the session changes; header Copy button +Cmd/Ctrl+Con the focused panel.Notes
Tests
local_liney→row mapping (incl. clamping) indiff_rows.review_view.cargo fmt --check,cargo clippy -p ui_gpui, andcargo test -p ui_gpui(173 passed) all green.