word-diff for the plaintext fallback parser
Not a bug. Just a feature request (label: enhancement).
(1) A description of the issue. A screenshot is often helpful too.
Currently, difftastic treats plain text (the fallback) as a simple line-oriented diff. Would be nice if we can enable some kind of word-diff for it.
In real life, various config files are treated as plain text (fallback). And if we only
change a small part of a line (e.g. theme="onedark" -> theme="twodark"),
word-diff would make the output more pleasant than the plain line-diff.
Below are some screenshots of an "artificial" use case showing remove/change/insert.
difft a.txt b.txt:

difft --display inline a.txt b.txt:

git diff --no-index --color-words=. a.txt b.txt:

Since we are advertising difft as more than word-diff at our front page,
can we make it behave similarly for the fallback plain text?
(2) A copy of what you're diffing.
------a.txt-----
hi, this is a sample text.
you can edit it as freely as you can.
cheers
------b.txt-----
hi, this is a sample txt.
you can change it as freely as you can.
cheers!
(3) The version of difftastic you're using (see
difft --version) and your operating system.
Difftastic 0.45.0 WSL 2 on Windows 10
There is word-level diffing, but I'm guessing the bright and bold style isn't supported in your terminal.

That said, this is kinda subtle, especially for the changed !. Difftastic will underline changed words when diffing comments in code, but it can be overwhelming when most of the words on a line have changed.
Do those colors have meaning? (It looks to me as if the red means deleted and the green means added, but maybe that's a notion I got from somewhere else. To a color blind person or a terminal that doesn't do bold, it looks like the entire line changed.)
There is word-level diffing
Cool. So the functionality has already been there. :)
but I'm guessing the bright and bold style isn't supported in your terminal.
Yeah. Seems Windows Terminal doesn't enable it by default. Here for a fix.
That said, this is kinda subtle
Yes Indeed. How about we don't highlight those unchanged parts at all? Make it just like what we did for the "recognized" programming languages.
The --color-words (--word-diff-regex) is an extra feature -- it lets you define what a "word" is.
In the screenshot of git above, it treats each char as a word.
And probably an independent topic (but kinda related with word-diff):
Looks I was confused by the different modes of difft --display.
Now I realize that for difft:
side-by-sideis usuallyside-by-side-show-bothunless lhs_changes or rhs_changes is emptyside-by-side-show-bothis the REAL side by side for me, and theninlineis just good old "unified" diff.
A color-words (or merged) mode would be nice (see the git screenshot above).
(Well, personally I call it "inline" - probably just me).
Keeping old names and semantics unchanged to avoid compatible issues, I'd suggest these three names/modes:
both-- alias for the oldside-by-side-show-bothunified-- alias for the oldinlinemerged-- the oldside-by-sidewhen lhs/rhs empty + the newcolor-words
I for one would make both or merged as default.
It's kinda surprising (at least for me) that side-by-side sometimes only show one side
and we have to specify another suffix show-both to really show both sides.
Related: for changes in comments of programming languages.
e.g. a repro: uncomment code.
-
difft
-
git diff --color-words=.