diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-03-27 09:24:26 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2025-03-28 14:45:01 +0800 |
commit | 2331c52affe64070ad59c0ef63ddcc8f7ca41781 (patch) | |
tree | a2438a9e9cecad08f85890c959a02523a1861260 /runtime/lua/vim/provider/python.lua | |
parent | ae98d0a560b08d901ee9aae85df634de0ae3fe0a (diff) | |
download | rneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.tar.gz rneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.tar.bz2 rneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.zip |
vim-patch:9.1.1243: diff mode is lacking for changes within lines
Problem: Diff mode's inline highlighting is lackluster. It only
performs a line-by-line comparison, and calculates a single
shortest range within a line that could encompass all the
changes. In lines with multiple changes, or those that span
multiple lines, this approach tends to end up highlighting
much more than necessary.
Solution: Implement new inline highlighting modes by doing per-character
or per-word diff within the diff block, and highlight only the
relevant parts, add "inline:simple" to the defaults (which is
the old behaviour)
This change introduces a new diffopt option "inline:<type>". Setting to
"none" will disable all inline highlighting, "simple" (the default) will
use the old behavior, "char" / "word" will perform a character/word-wise
diff of the texts within each diff block and only highlight the
differences.
The new char/word inline diff only use the internal xdiff, and will
respect diff options such as algorithm choice, icase, and misc iwhite
options. indent-heuristics is always on to perform better sliding.
For character highlight, a post-process of the diff results is first
applied before we show the highlight. This is because a naive diff will
create a result with a lot of small diff chunks and gaps, due to the
repetitive nature of individual characters. The post-process is a
heuristic-based refinement that attempts to merge adjacent diff blocks
if they are separated by a short gap (1-3 characters), and can be
further tuned in the future for better results. This process results in
more characters than necessary being highlighted but overall less visual
noise.
For word highlight, always use first buffer's iskeyword definition.
Otherwise if each buffer has different iskeyword settings we would not
be able to group words properly.
The char/word diffing is always per-diff block, not per line, meaning
that changes that span multiple lines will show up correctly.
Added/removed newlines are not shown by default, but if the user has
'list' set (with "eol" listchar defined), the eol character will be be
highlighted correctly for the specific newline characters.
Also, add a new "DiffTextAdd" highlight group linked to "DiffText" by
default. It allows color schemes to use different colors for texts that
have been added within a line versus modified.
This doesn't interact with linematch perfectly currently. The linematch
feature splits up diff blocks into multiple smaller blocks for better
visual matching, which makes inline highlight less useful especially for
multi-line change (e.g. a line is broken into two lines). This could be
addressed in the future.
As a side change, this also removes the bounds checking introduced to
diff_read() as they were added to mask existing logic bugs that were
properly fixed in vim/vim#16768.
closes: vim/vim#16881
https://github.com/vim/vim/commit/9943d4790e42721a6777da9e12637aa595ba4965
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Diffstat (limited to 'runtime/lua/vim/provider/python.lua')
0 files changed, 0 insertions, 0 deletions