Skip to content

feat(review): draw notes in the diff, in boxes under their lines - #208

Merged
backnotprop merged 14 commits into
mainfrom
feat/inline-notes
Nov 25, 2026
Merged

backnotprop merged 14 commits into
mainfrom
feat/inline-notes

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

Notes can now be drawn in the diff, each in a box under the lines it is about, the way a pull request shows its comments.

Depends on plannotator/diffs-rs#23 (insets). Until that is published, Cargo.toml takes diffs-rs, diffs-syntect and diffs-two-face from its feat/insets branch through [patch.crates-io]; that section goes away once a release has insets.

What changes

  • A Notes setting: panel (default, unchanged), inline (boxes in the diff) or both. It is a row in the settings menu after Wrap, [review] notes = "panel" | "inline" | "both" in the config, remembered like the other settings, and Reset clears it.
  • A box goes under the note's last line. In a split diff it sits over its own side, or spans both sides when that side is narrower than 48 columns. Notes on the same line stack in the order they were made. A file note goes under the file's heading. The box shows the kind and lines (comment · L40–45, suggestion · L42, … old), the author when it is not you, sent once sent, and at most six lines of text. A suggestion shows its code as -/+ lines.
  • Some notes get no box: whole-change notes, outdated notes, notes made in the whole-file view, notes in a hunk hidden with W and notes in files the filter hides. The footer counts them (2 notes not shown inline · z) and the panel lists them.
  • The cursor stops once on each box, and the box's border lights up. enter or e edits the note in place over the box. delete removes it. x still marks the file viewed. The footer hints change while the cursor is on a box. Clicking a box selects its note, in the panel too. A press on a box never starts a selection, and a drag across a box selects only code.
  • With inline the panel starts hidden; z opens it for this session only. both keeps the panel's usual rule.
  • Boxes never move the line you are reading. Adding, editing, removing or receiving a note, switching the setting, resizing, and other view changes keep the cursor's line on the same row and the code in the same columns.

Tests

  • review/tests/inline_flow.rs: the behaviour above, including that panel draws exactly as before and 300 notes.
  • review/tests/inline_view.rs: the view checks, run in unified, split 50:50 and split 30:70, with wrap on and off, the cursor at the top, the middle and the last page, and with 0, 1 or several notes. Every frame checks that each box is inside its rows, covers no code, sits under its own note's line and shows that note's text.
  • Unit tests for the box text, the config key and the remembered setting.

A Notes setting (panel, inline, both; [review] notes, the settings menu
after Wrap, remembered) draws each note in a box under the last line it
is about, over its side of a split diff, the file's notes under its
heading. The cursor stops on a box: enter or e edits it over the box,
delete removes it; a click picks its note. Boxes never move the line
the cursor is on. Uses the insets of diffs-rs (plannotator/diffs-rs#23).
… spans

Boxes over one side sit side by side under their row; a narrow side or a
file's note spans both. Widths come from the viewer before drawing, so
the hand-built split geometry and the opening workaround go. Suggested
code loses its shared indentation and breaks after punctuation; a new
comment lines up with the boxes; on a box, h/l move to the box beside.
…ooter and edit fixes

- U takes back the last note removed (from its box or the panel) as well as the
  last finish: the note goes back where it was, as sent as it was; the footer
  says "note removed · U undo" and the review menu's row "Undo remove".
- The key help lists the box keys only while notes show in the diff, as two
  rows whose keys fit the key column.
- The footer counts no notes in the whole file; a pane under 10 rows shows no
  boxes and says "pane too small for inline notes".
- A note being edited leaves its box's rows blank under the comment box.
- Tabs in a box take the comment box's four columns.
- c or s on a box comments on the lines it hangs under, on its side.
- A note saved on the pane's last row says "note saved · below, ↓ shows it".
…ks and resizes, and the cursor's side past a box

On diffs-rs feat/insets dc407e5.
…n a file box; undo kept per review; help fits 40 rows

- c on a file note's box opens the new file note under the heading's boxes,
  lined up with them, as a line's comment box opens under its boxes.
- s there says a suggestion needs lines of code and c adds a file comment.
- Each review's undo history is kept for the session: back on a review after
  picking another, U still takes back what was done there.
- The key help's U row joins the review menu's (m U), so the help fits 40 rows
  again with the notes panel's keys on screen.
@backnotprop
backnotprop added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 8afb7ec Nov 25, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/inline-notes branch November 25, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant