When using 'diffopt=inline:word', lines were excessively fragmented with punctuation creating separate highlight blocks, making it harder to read the diffs.
84319.png (view on web)This PR replaces the old behavior of fragmentation in between words separated by 'spaces' or 'punctuation' to joining those words together and add a new wordgap option for 'diffopt' to configure this behavior.
Which when enabled inline:word is enabled the default value of wordgap:2 is used to provide continuous block of diff.
set diffopt=internal,filler,inline:word,wordgap:0 (old behavior)set diffopt=internal,filler,inline:word,wordgap:2 (new default behavior)set diffopt=internal,filler,inline:word,wordgap:5 (max)Enable with:
:set diffopt+=inline:word,wordgap:(0-5)
diff_word_gap variable (default: 2)diffopt_changed() for wordgap:N syntaxdiff_refine_inline_word_highlight() merges adjacent blockstest_diffmode.vimThis feature is also being contributed to Neovim in parallel:
The Neovim PR contains additional comprehensive tests and discussion about
the feature design.
https://github.com/vim/vim/pull/19098
(8 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@chrisbra @ychin sorry for inconvenience, I had 2 branch's for this while porting it, and deleted the wrong one
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@zeertzjq commented on this pull request.
> + wordgap:{n} When highlighting inline differences with
+ 'diffopt' set to "inline:word", consider words
+ to be different only if they are separated
+ by at least {n} changed characters. This
+ helps avoid highlighting small changes
+ within words that are mostly the same.
+ The default setting is "wordgap:2".
+ The max setting is "wordgap:5".
The indent here is inconsistent. Try selecting these lines in Visual mode and running :retab!.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@HarshK97 pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@HarshK97 pushed 4 commits.
You are receiving this because you are subscribed to this thread.![]()
Hey @zeertzjq, can you rerun the CI tests, as the tests failed due to
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Rebase
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@HarshK97 pushed 6 commits.
You are receiving this because you are subscribed to this thread.![]()
Sorry for the slow response.
Personally, I kind of dread adding yet more options to diffopt itself, which is getting very heavily bloated. This is especially true for someoption:<number> style options which I think could be a bit unwieldy when it's added to the defaults. Vim doesn't really give you a way to remove the default in your vimrc via set-=, because Vim doesn't have a syntax to do something like set diffopt-=wordgaps:*. Instead, you have to know the exact tuning number used in the default.
And more options in general just makes it harder for a user to learn and I think we are approaching the point where diffopt is getting quite long and complicated (I do recognize that I was the last person to add the last two new options to diffopt…). When I was implementing inline:char I intentionally didn't add any tunable settings to the character refine step (which this PR based the word refine step on) for this reason.
If we want this, I wonder if it makes sense to just not expose this as an option (for now). I think sometimes too many options could be counter-productive and sets up long term support burdens, and lots of "why not expose this implementation detail too" requests. Most diff tools ultimately just pick some heuristics that they think is good for most people and go with them, and only expose high level options (e.g. algorithm type, whitespace handling, etc). But yes this will result in a slight change in behavior which may not please everyone, but at least this will force us to try to make sure the new behavior works well rather than just letting the user figure it out.
Otherwise I'm leaning on setting up another option along the lines of diffinlinewordgap to make it easier to use and tune. The main concern I still have is that exposing options like this is going to limit future changes we may want to make to the refinement step where we massage the output to look nice.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Personally, I kind of dread adding yet more options to
diffoptitself, which is getting very heavily bloated. This is especially true forsomeoption:<number>style options which I think could be a bit unwieldy when it's added to the defaults. Vim doesn't really give you a way to remove the default in your vimrc viaset-=, because Vim doesn't have a syntax to do something likeset diffopt-=wordgaps:*. Instead, you have to know the exact tuning number used in the default.
I get your concern, and I will remove the wordgap option, just a question, what should be heuristic for inline:word be for the number of gaps merged? Default 2? or 5 suggested by Lewis in Neovim PR or something in between?
For now I will use 5, let me know if I have to make any changes
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()