annotate src/testdir/test_utf8.vim @ 31782:a19ef442c77a v9.0.1223

patch 9.0.1223: cannot use setcellwidths() below 0x100 Commit: https://github.com/vim/vim/commit/7193323b7796c05573f3aa89d422e848feb3a8dc Author: K.Takata <kentkt@csc.jp> Date: Fri Jan 20 16:00:55 2023 +0000 patch 9.0.1223: cannot use setcellwidths() below 0x100 Problem: Cannot use setcellwidths() below 0x100. Solution: Also accept characters between 0x80 and 0x100. (Ken Takata, closes #11834)
author Bram Moolenaar <Bram@vim.org>
date Fri, 20 Jan 2023 21:01:44 +0100
parents f348559ce426
children dbec60b8c253
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for Unicode manipulations
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
26946
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
3 source check.vim
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
4 source view_util.vim
31678
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
5 source screendump.vim
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " Visual block Insert adjusts for multi-byte char
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_visual_block_insert()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 new
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call setline(1, ["aaa", "あああ", "bbb"])
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 exe ":norm! gg0l\<C-V>jjIx\<Esc>"
27247
0667f71ec335 patch 8.2.4152: block insert with double wide character fails
Bram Moolenaar <Bram@vim.org>
parents: 26946
diff changeset
12 call assert_equal(['axaa', ' xあああ', 'bxbb'], getline(1, '$'))
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 bwipeout!
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
24130
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
16 " Test for built-in functions strchars() and strcharlen()
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 func Test_strchars()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"]
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 for i in range(len(inp))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal(exp[i][0], strchars(inp[i]))
18017
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
22 call assert_equal(exp[i][1], inp[i]->strchars(0))
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(exp[i][2], strchars(inp[i], 1))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endfor
24130
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
25
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
26 let exp = [1, 3, 1, 1, 1]
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
27 for i in range(len(inp))
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
28 call assert_equal(exp[i], inp[i]->strcharlen())
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
29 call assert_equal(exp[i], strcharlen(inp[i]))
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
30 endfor
c3d1f65365c4 patch 8.2.2606: strchars() defaults to counting composing characters
Bram Moolenaar <Bram@vim.org>
parents: 23064
diff changeset
31
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
32 call assert_fails("let v=strchars('abc', [])", 'E745:')
22153
7aa10e8e7aec patch 8.2.1626: test for strchars() fails with different error number
Bram Moolenaar <Bram@vim.org>
parents: 21975
diff changeset
33 call assert_fails("let v=strchars('abc', 2)", 'E1023:')
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " Test for customlist completion
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
37 func CustomComplete1(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 return ['あ', 'い']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
39 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
41 func CustomComplete2(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 return ['あたし', 'あたま', 'あたりめ']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
43 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
45 func CustomComplete3(lead, line, pos)
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 return ['Nこ', 'Nん', 'Nぶ']
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10720
diff changeset
47 endfunc
10720
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 func Test_customlist_completion()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 call feedkeys(":Test1 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal('"Test1 ', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call feedkeys(":Test2 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call assert_equal('"Test2 あた', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call feedkeys(":Test3 \<C-L>\<C-B>\"\<CR>", 'itx')
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_equal('"Test3 N', getreg(':'))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call garbagecollect(1)
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 endfunc
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 " Yank one 3 byte character and check the mark columns.
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 func Test_getvcol()
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 new
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call setline(1, "x\u2500x")
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 normal 0lvy
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call assert_equal(2, col("'["))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 call assert_equal(4, col("']"))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call assert_equal(2, virtcol("'["))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call assert_equal(2, virtcol("']"))
44a1661f4cfa patch 8.0.0250: virtcol() does not work well for multi-byte characters
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 endfunc
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
75
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
76 func Test_list2str_str2list_utf8()
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
77 " One Unicode codepoint
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
78 let s = "\u3042\u3044"
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
79 let l = [0x3042, 0x3044]
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
80 call assert_equal(l, str2list(s, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
81 call assert_equal(s, list2str(l, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
82 if &enc ==# 'utf-8'
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
83 call assert_equal(str2list(s), str2list(s, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
84 call assert_equal(list2str(l), list2str(l, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
85 endif
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
86
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
87 " With composing characters
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
88 let s = "\u304b\u3099\u3044"
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
89 let l = [0x304b, 0x3099, 0x3044]
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
90 call assert_equal(l, str2list(s, 1))
17916
2e53305f2239 patch 8.1.1954: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 16235
diff changeset
91 call assert_equal(s, l->list2str(1))
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
92 if &enc ==# 'utf-8'
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
93 call assert_equal(str2list(s), str2list(s, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
94 call assert_equal(list2str(l), list2str(l, 1))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
95 endif
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
96
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
97 " Null list is the same as an empty list
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
98 call assert_equal('', list2str([]))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
99 call assert_equal('', list2str(test_null_list()))
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
100 endfunc
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
101
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
102 func Test_list2str_str2list_latin1()
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
103 " When 'encoding' is not multi-byte can still get utf-8 string.
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
104 " But we need to create the utf-8 string while 'encoding' is utf-8.
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
105 let s = "\u3042\u3044"
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
106 let l = [0x3042, 0x3044]
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
107
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
108 let save_encoding = &encoding
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
109 set encoding=latin1
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
110
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
111 let lres = str2list(s, 1)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
112 let sres = list2str(l, 1)
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
113 call assert_equal([65, 66, 67], str2list("ABC"))
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
114
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
115 " Try converting a list to a string in latin-1 encoding
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
116 call assert_equal([1, 2, 3], str2list(list2str([1, 2, 3])))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 19783
diff changeset
117
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
118 let &encoding = save_encoding
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
119 call assert_equal(l, lres)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
120 call assert_equal(s, sres)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
121 endfunc
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16148
diff changeset
122
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
123 func Test_screenchar_utf8()
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
124 new
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
125
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
126 " 1-cell, with composing characters
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
127 call setline(1, ["ABC\u0308"])
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
128 redraw
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
129 call assert_equal([0x0041], screenchars(1, 1))
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17916
diff changeset
130 call assert_equal([0x0042], 1->screenchars(2))
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
131 call assert_equal([0x0043, 0x0308], screenchars(1, 3))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
132 call assert_equal("A", screenstring(1, 1))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
133 call assert_equal("B", screenstring(1, 2))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
134 call assert_equal("C\u0308", screenstring(1, 3))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
135
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
136 " 2-cells, with composing characters
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
137 let text = "\u3042\u3044\u3046\u3099"
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
138 call setline(1, text)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
139 redraw
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
140 call assert_equal([0x3042], screenchars(1, 1))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
141 call assert_equal([0], screenchars(1, 2))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
142 call assert_equal([0x3044], screenchars(1, 3))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
143 call assert_equal([0], screenchars(1, 4))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
144 call assert_equal([0x3046, 0x3099], screenchars(1, 5))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
145
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
146 call assert_equal("\u3042", screenstring(1, 1))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
147 call assert_equal("", screenstring(1, 2))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
148 call assert_equal("\u3044", screenstring(1, 3))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
149 call assert_equal("", screenstring(1, 4))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
150 call assert_equal("\u3046\u3099", screenstring(1, 5))
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
151
16148
90b0f2227d73 patch 8.1.1079: no need for a separate ScreenLinesUtf8() test function
Bram Moolenaar <Bram@vim.org>
parents: 16133
diff changeset
152 call assert_equal([text . ' '], ScreenLines(1, 8))
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
153
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
154 bwipe!
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
155 endfunc
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
156
21971
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
157 func Test_setcellwidths()
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
158 call setcellwidths([
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
159 \ [0x1330, 0x1330, 2],
21975
2030f8267db9 patch 8.2.1537: memory acccess error when using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 21971
diff changeset
160 \ [9999, 10000, 1],
21971
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
161 \ [0x1337, 0x1339, 2],
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
162 \])
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
163
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
164 call assert_equal(2, strwidth("\u1330"))
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
165 call assert_equal(1, strwidth("\u1336"))
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
166 call assert_equal(2, strwidth("\u1337"))
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
167 call assert_equal(2, strwidth("\u1339"))
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
168 call assert_equal(1, strwidth("\u133a"))
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
169
31782
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
170 for aw in ['single', 'double']
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
171 exe 'set ambiwidth=' . aw
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
172 " Handle \u0080 to \u009F as control chars even on MS-Windows.
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
173 set isprint=@,161-255
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
174
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
175 call setcellwidths([])
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
176 " Control chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
177 call assert_equal(4, strwidth("\u0081"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
178 call assert_equal(6, strwidth("\uFEFF"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
179 " Ambiguous width chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
180 call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u00A1"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
181 call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u2010"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
182
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
183 call setcellwidths([[0x81, 0x81, 1], [0xA1, 0xA1, 1],
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
184 \ [0x2010, 0x2010, 1], [0xFEFF, 0xFEFF, 1]])
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
185 " Control chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
186 call assert_equal(4, strwidth("\u0081"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
187 call assert_equal(6, strwidth("\uFEFF"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
188 " Ambiguous width chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
189 call assert_equal(1, strwidth("\u00A1"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
190 call assert_equal(1, strwidth("\u2010"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
191
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
192 call setcellwidths([[0x81, 0x81, 2], [0xA1, 0xA1, 2],
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
193 \ [0x2010, 0x2010, 2], [0xFEFF, 0xFEFF, 2]])
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
194 " Control chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
195 call assert_equal(4, strwidth("\u0081"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
196 call assert_equal(6, strwidth("\uFEFF"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
197 " Ambiguous width chars
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
198 call assert_equal(2, strwidth("\u00A1"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
199 call assert_equal(2, strwidth("\u2010"))
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
200 endfor
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
201 set ambiwidth& isprint&
a19ef442c77a patch 9.0.1223: cannot use setcellwidths() below 0x100
Bram Moolenaar <Bram@vim.org>
parents: 31760
diff changeset
202
21971
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
203 call setcellwidths([])
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
204
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 27247
diff changeset
205 call assert_fails('call setcellwidths(1)', 'E1211:')
21971
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
206
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
207 call assert_fails('call setcellwidths([1, 2, 0])', 'E1109:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
208
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
209 call assert_fails('call setcellwidths([[0x101]])', 'E1110:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
210 call assert_fails('call setcellwidths([[0x101, 0x102]])', 'E1110:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
211 call assert_fails('call setcellwidths([[0x101, 0x102, 1, 4]])', 'E1110:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
212 call assert_fails('call setcellwidths([["a"]])', 'E1110:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
213
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
214 call assert_fails('call setcellwidths([[0x102, 0x101, 1]])', 'E1111:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
215
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
216 call assert_fails('call setcellwidths([[0x101, 0x102, 0]])', 'E1112:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
217 call assert_fails('call setcellwidths([[0x101, 0x102, 3]])', 'E1112:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
218
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
219 call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x115, 0x116, 2]])', 'E1113:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
220 call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:')
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
221
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
222 call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:')
26022
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
223
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
224 set listchars=tab:--\\u2192
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
225 call assert_fails('call setcellwidths([[0x2192, 0x2192, 2]])', 'E834:')
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
226
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
227 set fillchars=stl:\\u2501
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
228 call assert_fails('call setcellwidths([[0x2501, 0x2501, 2]])', 'E835:')
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
229
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
230 set listchars&
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
231 set fillchars&
30e60bfd5fb3 patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Bram Moolenaar <Bram@vim.org>
parents: 24130
diff changeset
232 call setcellwidths([])
21971
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
233 endfunc
0bc43a704f56 patch 8.2.1535: it is not possible to specify cell widths of characters
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
234
31760
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
235 func Test_getcellwidths()
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
236 call setcellwidths([])
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
237 call assert_equal([], getcellwidths())
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
238
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
239 let widthlist = [
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
240 \ [0x1330, 0x1330, 2],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
241 \ [9999, 10000, 1],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
242 \ [0x1337, 0x1339, 2],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
243 \]
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
244 let widthlistsorted = [
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
245 \ [0x1330, 0x1330, 2],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
246 \ [0x1337, 0x1339, 2],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
247 \ [9999, 10000, 1],
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
248 \]
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
249 call setcellwidths(widthlist)
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
250 call assert_equal(widthlistsorted, getcellwidths())
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
251
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
252 call setcellwidths([])
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
253 endfunc
f348559ce426 patch 9.0.1212: cannot read back what setcellwidths() has done
Bram Moolenaar <Bram@vim.org>
parents: 31678
diff changeset
254
31678
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
255 func Test_setcellwidths_dump()
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
256 CheckRunVimInTerminal
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
257
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
258 let lines =<< trim END
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
259 call setline(1, "\ue5ffDesktop")
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
260 END
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
261 call writefile(lines, 'XCellwidths', 'D')
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
262 let buf = RunVimInTerminal('-S XCellwidths', {'rows': 6})
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
263 call VerifyScreenDump(buf, 'Test_setcellwidths_dump_1', {})
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
264
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
265 call term_sendkeys(buf, ":call setcellwidths([[0xe5ff, 0xe5ff, 2]])\<CR>")
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
266 call VerifyScreenDump(buf, 'Test_setcellwidths_dump_2', {})
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
267
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
268 call StopVimInTerminal(buf)
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
269 endfunc
9e1062b4aa94 patch 9.0.1171: screen is not redrawn after using setcellwidths()
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
270
23064
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
271 func Test_print_overlong()
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
272 " Text with more composing characters than MB_MAXBYTES.
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
273 new
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
274 call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
275 s/x/\=nr2char(1629)/g
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
276 print
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
277 bwipe!
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
278 endfunc
89c324e327c0 patch 8.2.2078: illegal memory access when using :print on invalid text
Bram Moolenaar <Bram@vim.org>
parents: 22153
diff changeset
279
26946
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
280 func Test_recording_with_select_mode_utf8()
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
281 call Run_test_recording_with_select_mode_utf8()
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
282 endfunc
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
283
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
284 func Run_test_recording_with_select_mode_utf8()
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
285 new
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
286
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
287 " No escaping
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
288 call feedkeys("qacc12345\<Esc>gH哦\<Esc>q", "tx")
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
289 call assert_equal("哦", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
290 call assert_equal("cc12345\<Esc>gH哦\<Esc>", @a)
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
291 call setline(1, 'asdf')
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
292 normal! @a
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
293 call assert_equal("哦", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
294
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
295 " 固 is 0xE5 0x9B 0xBA where 0x9B is CSI
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
296 call feedkeys("qacc12345\<Esc>gH固\<Esc>q", "tx")
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
297 call assert_equal("固", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
298 call assert_equal("cc12345\<Esc>gH固\<Esc>", @a)
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
299 call setline(1, 'asdf')
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
300 normal! @a
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
301 call assert_equal("固", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
302
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
303 " 四 is 0xE5 0x9B 0x9B where 0x9B is CSI
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
304 call feedkeys("qacc12345\<Esc>gH四\<Esc>q", "tx")
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
305 call assert_equal("四", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
306 call assert_equal("cc12345\<Esc>gH四\<Esc>", @a)
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
307 call setline(1, 'asdf')
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
308 normal! @a
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
309 call assert_equal("四", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
310
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
311 " 倒 is 0xE5 0x80 0x92 where 0x80 is K_SPECIAL
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
312 call feedkeys("qacc12345\<Esc>gH倒\<Esc>q", "tx")
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
313 call assert_equal("倒", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
314 call assert_equal("cc12345\<Esc>gH倒\<Esc>", @a)
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
315 call setline(1, 'asdf')
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
316 normal! @a
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
317 call assert_equal("倒", getline(1))
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
318
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
319 bwipe!
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
320 endfunc
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
321
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
322 " This must be done as one of the last tests, because it starts the GUI, which
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
323 " cannot be undone.
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
324 func Test_zz_recording_with_select_mode_utf8_gui()
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
325 CheckCanRunGui
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
326
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
327 gui -f
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
328 call Run_test_recording_with_select_mode_utf8()
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
329 endfunc
8d4b44cc324e patch 8.2.4002: first char typed in Select mode can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 26022
diff changeset
330
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
331 " vim: shiftwidth=2 sts=2 expandtab