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>
diff --git a/src/diff.c b/src/diff.c
index 3adcdb7..e694cf2 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -3309,10 +3309,17 @@
 	    char_u *s;
 	    for (s = curline; *s != NUL;)
 	    {
-		// Always use the first buffer's 'iskeyword' to have a consistent diff
 		int new_in_keyword = FALSE;
 		if (diff_flags & DIFF_INLINE_WORD)
-		    new_in_keyword = vim_iswordp_buf(s, curtab->tp_diffbuf[file1_idx]);
+		{
+		    // Always use the first buffer's 'iskeyword' to have a
+		    // consistent diff.
+		    // For multibyte chars, only treat alphanumeric chars
+		    // (class 2) as "word", as other classes such as emojis and
+		    // CJK ideographs do not usually benefit from word diff as
+		    // Vim doesn't have a good way to segment them.
+		    new_in_keyword = (mb_get_class_buf(s, curtab->tp_diffbuf[file1_idx]) == 2);
+		}
 		if (in_keyword && !new_in_keyword)
 		{
 		    ga_append(curstr, NL);