]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1276: inline word diff treats multibyte chars as word char v9.1.1276
authorYee Cheng Chin <ychin.git@gmail.com>
Fri, 4 Apr 2025 17:16:21 +0000 (19:16 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 4 Apr 2025 17:16:21 +0000 (19:16 +0200)
commit9aa120f7ada592ed03b37f4de8ee413c5385f123
treefda6de1c317402b17444ce43d76a6ddd110140ac
parentb8d5c8509998f3a97ffe42f674352b07749cd119
patch 9.1.1276: inline word diff treats multibyte chars as word char

Problem:  inline word diff treats multibyte chars as word char
          (after 9.1.1243)
Solution: treat all non-alphanumeric characters as non-word characters
          (Yee Cheng Chin)

Previously inline word diff simply used Vim's definition of keyword to
determine what is a word, which leads to multi-byte character classes
such as emojis and CJK (Chinese/Japanese/Korean) characters all
classifying as word characters, leading to entire sentences being
grouped as a single word which does not provide meaningful information
in a diff highlight.

Fix this by treating all non-alphanumeric characters (with class number
above 2) as non-word characters, as there is usually no benefit in using
word diff on them. These include CJK characters, emojis, and also
subscript/superscript numbers. Meanwhile, multi-byte characters like
Cyrillic and Greek letters will still continue to considered as words.

Note that this is slightly inconsistent with how words are defined
elsewhere, as Vim usually considers any character with class >=2 to be
a "word".

related: #16881 (diff inline highlight)
closes: #17050

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
src/diff.c
src/mbyte.c
src/testdir/dumps/Test_diff_inline_word_03.dump [new file with mode: 0644]
src/testdir/test_diffmode.vim
src/version.c