Skip to content

feat: display review comments inline in the diff view - #21

Open
KEY60228 wants to merge 2 commits into
mainfrom
feat/inline-comments
Open

feat: display review comments inline in the diff view#21
KEY60228 wants to merge 2 commits into
mainfrom
feat/inline-comments

Conversation

@KEY60228

@KEY60228 KEY60228 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Render each comment's full text inline below its anchor line in the split diff view using extmark virt_lines, as a bordered block (┌─ 💬 L10-12 ─ header with the line range, -prefixed text lines, └─ footer)
  • Anchor blocks at the comment's end_line on the matching side; multiple comments on the same line are stacked in start_line order
  • Wrap long comment lines by display width (min(80, window width - 10)) with multibyte-safe character iteration, so Japanese comments wrap correctly instead of being truncated
  • Add inline_comments config option (default: true); when disabled, behavior is exactly as before (only the eol 💬 sign)
  • Add theme-friendly highlight groups ReviewThemInlineComment (links to Comment) and ReviewThemInlineCommentBorder (links to NonText)
  • Keep the existing eol comment sign behavior; inline blocks refresh automatically on comment add/edit/delete via the existing decoration refresh path
  • Add a headless functional test (tests/inline_comments_spec.lua) covering multi-line comments, multibyte wrapping, stacking, and the config toggle
  • Document the feature in README and :help reviewthem

Test plan

  • nvim --headless -c "set rtp+=." -c "lua require('reviewthem').setup()" -c "q" loads cleanly
  • nvim --headless -l tests/inline_comments_spec.lua passes (13 checks)
  • Start a review session, add single-line and multi-line comments, and confirm inline blocks appear below the commented lines on the correct side
  • Add two comments ending on the same line and confirm they stack in order
  • Add a long Japanese comment and confirm it wraps readably
  • Set inline_comments = false and confirm only the 💬 eol sign is shown

🤖 Generated with Claude Code

KEY60228 and others added 2 commits July 5, 2026 01:21
Render each comment's full text as a bordered virtual-line block below
its anchor line (the comment's end_line on the matching side), in
addition to the existing eol comment sign. Multiple comments on the
same line are stacked in order, and long lines are wrapped by display
width so multibyte (e.g. Japanese) text stays readable.

- Add `inline_comments` config option (default: true) to toggle the
  feature
- Add ReviewThemInlineComment / ReviewThemInlineCommentBorder highlight
  groups linked to Comment / NonText for theme friendliness
- Add a headless functional test (tests/inline_comments_spec.lua)
- Document the feature in README and :help reviewthem

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Inline comment blocks are virtual lines on one side of the diff only, so the
other pane drifted upward on screen — 'scrollbind' syncs buffer lines, not
screen rows. With a 5-line block and 22-line panes the old side showed buffer
lines 1-22 while the new side showed 1-17.

- Mirror each block's height as blank filler lines in the opposite pane, so
  both buffers occupy the same screen rows. Decoration now runs for both
  panes at once, since fillers need the other side's block heights.
- Re-wrap comment text on WinResized/VimResized when the wrap width actually
  changes; the width used to be frozen at first render.
- Keep bytes that are not valid UTF-8 while wrapping. The old character
  pattern could not start a character on 0x00 or 0xF5-0xFF and dropped them.
- Expand tabs before measuring width. nvim_strwidth reports 1 for a tab while
  it draws as 'tabstop' columns, which split a line at every tab.
- Measure with nvim_strwidth instead of a strdisplaywidth call per character.
- Drop the |comment_sign| doc link: no such help tag exists.
- Tests: assert against the wrap width the renderer was given instead of a
  constant that passed trivially, verify both panes end up with equal virtual
  line height per row, cover tabs and invalid UTF-8, and make the ordering
  check fail instead of erroring when a pattern does not match.
- Add a make test target so the checks are runnable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QvF1sbz4NudDsjqzQDivGS
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.

2 participants