patch 8.2.1536: cannot get the class of a character; emoji widths are wrong
Problem: Cannot get the class of a character; emoji widths are wrong in
some environments.
Solution: Add charclass(). Update some emoji widths. Add script to check
emoji widths.
diff --git a/src/testdir/emoji_list.vim b/src/testdir/emoji_list.vim
new file mode 100644
index 0000000..e6a73c3
--- /dev/null
+++ b/src/testdir/emoji_list.vim
@@ -0,0 +1,22 @@
+" Script to fill the window with emoji characters, one per line.
+
+if &modified
+ new
+else
+ enew
+endif
+
+" Use a compiled Vim9 function for speed
+def DoIt()
+ let lnum = 1
+ for c in range(0x100, 0x1ffff)
+ let cs = nr2char(c)
+ if charclass(cs) == 3
+ setline(lnum, '|' .. cs .. '| ' .. strwidth(cs))
+ lnum += 1
+ endif
+ endfor
+enddef
+
+call DoIt()
+set nomodified
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index e15199b..fd9057d 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2077,6 +2077,13 @@
set encoding=utf-8
endfunc
+func Test_charclass()
+ call assert_equal(0, charclass(' '))
+ call assert_equal(1, charclass('.'))
+ call assert_equal(2, charclass('x'))
+ call assert_equal(3, charclass("\u203c"))
+endfunc
+
func Test_eventhandler()
call assert_equal(0, eventhandler())
endfunc