Repository navigation
Align corresponding rows between From and To (filler lines) - #16
Merged
Merged
Conversation
scrollbind/cursorbind only mirror scroll offsets, so with insertions or deletions the two sides drifted apart. With diff.align (default true) the scratch buffers are rewritten with real filler rows from vscode-diff's change blocks, so line N on the left corresponds to line N on the right and scrolling/cursor stay aligned like diff mode. - M.align_lines(): pure function building the aligned contents and original-line -> buffer-row maps; the shorter side of a block is padded at the end of the block. - All line/char/move highlights are computed on original line numbers and placed through the row maps; move markers keep original line numbers. - Filler rows use the new PartialDiffFiller group (links to DiffDelete) and the 'fillchars' diff character, fixed to the window. - Windows that show line numbers get a statuscolumn with original line numbers (blank on filler rows); reset when the view closes as the last tab. - diff.align = false keeps the buffers verbatim. Closes #10
ryutaro-asada
changed the base branch from
fix/line-add-delete-highlights
to
main
October 22, 2026 23:36
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.
Closes #10. Stacked on #15 (based on its branch because both change
highlight_line); merge #15 first.Summary
scrollbind/cursorbindonly mirror scroll offsets, so with insertions/deletions the two sides drifted apart. With the newdiff.align(defaulttrue), the scratch buffers are rewritten with real filler rows, so line N on the left always corresponds to line N on the right. Scrolling and cursor movement stay aligned, like diff mode.(excerpt of a headless screen dump of
test/demo.rb)M.align_lines()is a pure function that builds the aligned contents and the original-line → buffer-row maps from vscode-diff's change blocks. The shorter side of a block is padded at the end of the block.PartialDiffFillergroup (links toDiffDelete, configurable ashighlights.filler) and the'fillchars'diff character, fixed to the window so it doesn't scroll horizontally.statuscolumnwith original line numbers (blank on filler rows). It is reset if the view closes as the last tab.diff.align = falsekeeps the buffers verbatim (old behavior).Approach as discussed in #10. Rejected: diff mode for alignment (its own diff can disagree with vscode-diff) and
virt_linesfiller (scrollbinddoesn't count virtual lines).Testing
make test: 55/55 pass locally (Neovim 0.11.1).spec/align_spec.lua(14 cases):align_lineson insertions, deletions, uneven modified blocks, and multiple blocks.statuscolumnset only where numbers are shown.align = falsekeeps the buffers verbatim.statuscolumncallback assumedg:statusline_winid, which isn't set inside%{}items. It errored on every redraw. Fixed, and the test fails without the fix.test/demo.rbwithnumberon: filler rows, original line numbers, cursor stays on the same row after6jin one window.Behavior change
Alignment is on by default. Copying text out of the diff buffers now includes empty filler rows; set
diff.align = falseto get verbatim copies.