Skip to content

feat(inline): add view.inline.deletion_highlight option#144

Merged
dlyongemallo merged 1 commit intomainfrom
inline_delete_virtual_lines
May 3, 2026
Merged

feat(inline): add view.inline.deletion_highlight option#144
dlyongemallo merged 1 commit intomainfrom
inline_delete_virtual_lines

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

@dlyongemallo dlyongemallo commented May 1, 2026

Configure the extent of the DiffDelete background on deleted virt_lines in the diff1_inline layout: "text" (default — just the deleted chars), "full_width" (pad to min(&columns, 250) so the highlight spans the row, matching diff2_horizontal's native look), or "hanging" (skip the leading indent).

Copilot AI review requested due to automatic review settings May 1, 2026 20:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new view.inline.full_width_deletions configuration option to improve the visual consistency of deletions rendered via virt_lines in the diff1_inline layout by padding deletions out to the window text width, and triggers repaint on resize so padding stays accurate.

Changes:

  • Add optional padding of deleted virt_lines in inline_diff (full_width_deletions) using display width semantics (incl. tabs).
  • Add resize-driven repaints for active diff1_inline buffers on WinResized/VimResized (gated by the option).
  • Add functional coverage for padding behavior and document the new option in doc/diffview.txt.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lua/diffview/tests/functional/inline_diff_spec.lua Adds functional specs verifying padding chunks, tab display width handling, multi-window behavior, and “no window” behavior.
lua/diffview/scene/layouts/diff_1_inline.lua Registers a global resize autocmd that schedules per-buffer inline repaints when full_width_deletions is enabled.
lua/diffview/scene/inline_diff.lua Implements widest-window text width detection and pads deletion virt_lines with same highlight group to span row width.
lua/diffview/config.lua Introduces view.inline.full_width_deletions default + LuaLS type annotations.
doc/diffview.txt Documents the new view.inline.full_width_deletions option and its behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/diffview/config.lua Outdated
Comment thread lua/diffview/tests/functional/inline_diff_spec.lua Outdated
@dlyongemallo dlyongemallo force-pushed the inline_delete_virtual_lines branch 2 times, most recently from 77f3dba to 11eede3 Compare May 2, 2026 06:12
@dlyongemallo dlyongemallo changed the title feat(inline): add view.inline.full_width_deletions option feat(inline): pad deleted virt_lines so DiffDelete spans the row May 2, 2026
@dlyongemallo dlyongemallo force-pushed the inline_delete_virtual_lines branch from 11eede3 to 2514815 Compare May 2, 2026 07:06
@dlyongemallo dlyongemallo requested a review from Copilot May 2, 2026 14:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/diffview/scene/inline_diff.lua Outdated
Comment thread lua/diffview/scene/inline_diff.lua
Comment thread lua/diffview/tests/functional/inline_diff_spec.lua Outdated
@dlyongemallo dlyongemallo force-pushed the inline_delete_virtual_lines branch from 2514815 to ac03f37 Compare May 2, 2026 23:57
@dlyongemallo dlyongemallo changed the title feat(inline): pad deleted virt_lines so DiffDelete spans the row feat(inline): add view.inline.deletion_highlight option May 2, 2026
Configure the extent of the `DiffDelete` background on deleted virt_lines
in the `diff1_inline` layout: `"text"` (default — just the deleted chars),
`"full_width"` (pad to `min(&columns, 250)` so the highlight spans the
row, matching `diff2_horizontal`'s native look), or `"hanging"` (skip the
leading indent).
@dlyongemallo dlyongemallo force-pushed the inline_delete_virtual_lines branch from ac03f37 to 3679f3e Compare May 3, 2026 00:31
@dlyongemallo dlyongemallo merged commit 2ba7efe into main May 3, 2026
5 checks passed
@dlyongemallo dlyongemallo deleted the inline_delete_virtual_lines branch May 3, 2026 00:34
@charbelnicolas
Copy link
Copy Markdown

Hi @dlyongemallo, thanks for taking the time to make this better. Is there a reason why you are using virtual lines specifically? Virtual lines in neovim cannot be selected and copied in case one would like to do so (I don't know if it's my config only) and they also lose the tree-sitter highlights. Check the two examples below. One is using the virtual lines and the other is not. By the way, the virtual lines still do not reach the end of the line, they still get cut off. Would you still like for me to make a new issue about this?

diff1_inline
image_2026_05_03_18_40_12
diff2_horizontal
image_2026_05_03_18_40_20

@dlyongemallo
Copy link
Copy Markdown
Owner Author

dlyongemallo commented May 4, 2026

@charbelnicolas The reason diff2 layouts don't need virtual lines is because the deleted content is real text in the old buffer, so ext marks (e.g., highlighting) are attached to real line numbers. With the diff1 layout, there is no real buffer to diff against and only the new file's content is available. Inserting real lines in this layout would shift the line numbering and break everything that depends on line numbering. Virtual lines are the only way to add visible content without modifying the buffer.

The diff1 highlighting beyond the end of the actual lines is done by inserting spaces past the end. I had put a cap of 250 on the assumption that this was wider than any user would see, but apparently I was wrong about that. I can fix the cap. I can also run tree-sitter on each virt_lines chunk.

The inability to select/copy virt_lines is a Neovim design choice/hard limitation. If you need to copy the old content, either use a diff2 layout which puts that content into a real buffer, or a screen multiplexer like tmux.

@charbelnicolas
Copy link
Copy Markdown

@charbelnicolas The reason diff2 layouts don't need virtual lines is beacuse the deleted content is real text in the old buffer, so ext marks (e.g., highlighting) are attached to real line numbers. With the diff1 layout, there is no real buffer to diff against and only the new file's content is available. Inserting real lines in this layout would shift the line numbering and break everything that depends on line numbering. Virtual lines are the only way to add visible content without modifying the buffer.

The diff1 highlighting beyond the end of the actual lines is done by inserting spaces past the end. I had put a cap of 250 on the assumption that this was wider than any user would see, but apparently I was wrong about that. I can fix the cap. I can also run tree-sitter on each virt_lines chunk.

The inability to select/copy virt_lines is a Neovim design choice/hard limitation. If you need to copy the old content, either use a diff2 layout which puts that content into a real buffer, or a screen multiplexer like tmux.

That makes a lot of sense, thanks for taking the time to reply, I appreciate it. Tree-sitter support and full line highlight should be enough, thank you!

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.

3 participants