Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 1 | " Tests for Unicode manipulations |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 2 | |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 3 | source util/screendump.vim |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 4 | |
| 5 | " Visual block Insert adjusts for multi-byte char |
| 6 | func Test_visual_block_insert() |
| 7 | new |
| 8 | call setline(1, ["aaa", "あああ", "bbb"]) |
| 9 | exe ":norm! gg0l\<C-V>jjIx\<Esc>" |
Bram Moolenaar | fc6cceb | 2022-01-20 12:22:35 +0000 | [diff] [blame] | 10 | call assert_equal(['axaa', ' xあああ', 'bxbb'], getline(1, '$')) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 11 | bwipeout! |
| 12 | endfunc |
| 13 | |
Bram Moolenaar | 70ce8a1 | 2021-03-14 19:02:09 +0100 | [diff] [blame] | 14 | " Test for built-in functions strchars() and strcharlen() |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 15 | func Test_strchars() |
| 16 | let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"] |
| 17 | let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]] |
| 18 | for i in range(len(inp)) |
| 19 | call assert_equal(exp[i][0], strchars(inp[i])) |
Bram Moolenaar | f6ed61e | 2019-09-07 19:05:09 +0200 | [diff] [blame] | 20 | call assert_equal(exp[i][1], inp[i]->strchars(0)) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 21 | call assert_equal(exp[i][2], strchars(inp[i], 1)) |
| 22 | endfor |
Bram Moolenaar | 70ce8a1 | 2021-03-14 19:02:09 +0100 | [diff] [blame] | 23 | |
| 24 | let exp = [1, 3, 1, 1, 1] |
| 25 | for i in range(len(inp)) |
| 26 | call assert_equal(exp[i], inp[i]->strcharlen()) |
| 27 | call assert_equal(exp[i], strcharlen(inp[i])) |
| 28 | endfor |
| 29 | |
zeertzjq | 8cf5137 | 2023-05-08 15:31:38 +0100 | [diff] [blame] | 30 | call assert_fails("call strchars('abc', 2)", ['E1023:', 'E1023:']) |
| 31 | call assert_fails("call strchars('abc', -1)", ['E1023:', 'E1023:']) |
| 32 | call assert_fails("call strchars('abc', {})", ['E728:', 'E728:']) |
| 33 | call assert_fails("call strchars('abc', [])", ['E745:', 'E745:']) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 34 | endfunc |
| 35 | |
| 36 | " Test for customlist completion |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 37 | func CustomComplete1(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 38 | return ['あ', 'い'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 39 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 40 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 41 | func CustomComplete2(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 42 | return ['あたし', 'あたま', 'あたりめ'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 43 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 44 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 45 | func CustomComplete3(lead, line, pos) |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 46 | return ['Nこ', 'Nん', 'Nぶ'] |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 47 | endfunc |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 48 | |
| 49 | func Test_customlist_completion() |
| 50 | command -nargs=1 -complete=customlist,CustomComplete1 Test1 echo |
| 51 | call feedkeys(":Test1 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 52 | call assert_equal('"Test1 ', getreg(':')) |
| 53 | |
| 54 | command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo |
| 55 | call feedkeys(":Test2 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 56 | call assert_equal('"Test2 あた', getreg(':')) |
| 57 | |
| 58 | command -nargs=1 -complete=customlist,CustomComplete3 Test3 echo |
| 59 | call feedkeys(":Test3 \<C-L>\<C-B>\"\<CR>", 'itx') |
| 60 | call assert_equal('"Test3 N', getreg(':')) |
| 61 | |
| 62 | call garbagecollect(1) |
zeertzjq | a59e031 | 2024-04-15 19:14:38 +0200 | [diff] [blame] | 63 | delcommand Test1 |
| 64 | delcommand Test2 |
| 65 | delcommand Test3 |
Bram Moolenaar | 0c0590d | 2017-01-28 13:48:10 +0100 | [diff] [blame] | 66 | endfunc |
| 67 | |
| 68 | " Yank one 3 byte character and check the mark columns. |
| 69 | func Test_getvcol() |
| 70 | new |
| 71 | call setline(1, "x\u2500x") |
| 72 | normal 0lvy |
| 73 | call assert_equal(2, col("'[")) |
| 74 | call assert_equal(4, col("']")) |
| 75 | call assert_equal(2, virtcol("'[")) |
| 76 | call assert_equal(2, virtcol("']")) |
| 77 | endfunc |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 78 | |
Bram Moolenaar | 9d40128 | 2019-04-06 13:18:12 +0200 | [diff] [blame] | 79 | func Test_list2str_str2list_utf8() |
| 80 | " One Unicode codepoint |
| 81 | let s = "\u3042\u3044" |
| 82 | let l = [0x3042, 0x3044] |
| 83 | call assert_equal(l, str2list(s, 1)) |
| 84 | call assert_equal(s, list2str(l, 1)) |
| 85 | if &enc ==# 'utf-8' |
| 86 | call assert_equal(str2list(s), str2list(s, 1)) |
| 87 | call assert_equal(list2str(l), list2str(l, 1)) |
| 88 | endif |
| 89 | |
| 90 | " With composing characters |
| 91 | let s = "\u304b\u3099\u3044" |
| 92 | let l = [0x304b, 0x3099, 0x3044] |
| 93 | call assert_equal(l, str2list(s, 1)) |
Bram Moolenaar | 02b3111 | 2019-08-31 22:16:38 +0200 | [diff] [blame] | 94 | call assert_equal(s, l->list2str(1)) |
Bram Moolenaar | 9d40128 | 2019-04-06 13:18:12 +0200 | [diff] [blame] | 95 | if &enc ==# 'utf-8' |
| 96 | call assert_equal(str2list(s), str2list(s, 1)) |
| 97 | call assert_equal(list2str(l), list2str(l, 1)) |
| 98 | endif |
| 99 | |
| 100 | " Null list is the same as an empty list |
| 101 | call assert_equal('', list2str([])) |
| 102 | call assert_equal('', list2str(test_null_list())) |
| 103 | endfunc |
| 104 | |
| 105 | func Test_list2str_str2list_latin1() |
| 106 | " When 'encoding' is not multi-byte can still get utf-8 string. |
| 107 | " But we need to create the utf-8 string while 'encoding' is utf-8. |
| 108 | let s = "\u3042\u3044" |
| 109 | let l = [0x3042, 0x3044] |
| 110 | |
| 111 | let save_encoding = &encoding |
| 112 | set encoding=latin1 |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 113 | |
Bram Moolenaar | 9d40128 | 2019-04-06 13:18:12 +0200 | [diff] [blame] | 114 | let lres = str2list(s, 1) |
| 115 | let sres = list2str(l, 1) |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 116 | call assert_equal([65, 66, 67], str2list("ABC")) |
Bram Moolenaar | 9d40128 | 2019-04-06 13:18:12 +0200 | [diff] [blame] | 117 | |
Bram Moolenaar | 08f4157 | 2020-04-20 16:50:00 +0200 | [diff] [blame] | 118 | " Try converting a list to a string in latin-1 encoding |
| 119 | call assert_equal([1, 2, 3], str2list(list2str([1, 2, 3]))) |
| 120 | |
Bram Moolenaar | 9d40128 | 2019-04-06 13:18:12 +0200 | [diff] [blame] | 121 | let &encoding = save_encoding |
| 122 | call assert_equal(l, lres) |
| 123 | call assert_equal(s, sres) |
| 124 | endfunc |
| 125 | |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 126 | func Test_screenchar_utf8() |
| 127 | new |
| 128 | |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 129 | " 1-cell, with composing characters |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 130 | call setline(1, ["ABC\u0308"]) |
| 131 | redraw |
| 132 | call assert_equal([0x0041], screenchars(1, 1)) |
Bram Moolenaar | 196b466 | 2019-09-06 21:34:30 +0200 | [diff] [blame] | 133 | call assert_equal([0x0042], 1->screenchars(2)) |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 134 | call assert_equal([0x0043, 0x0308], screenchars(1, 3)) |
| 135 | call assert_equal("A", screenstring(1, 1)) |
| 136 | call assert_equal("B", screenstring(1, 2)) |
| 137 | call assert_equal("C\u0308", screenstring(1, 3)) |
| 138 | |
zeertzjq | 47eec67 | 2023-06-01 20:26:55 +0100 | [diff] [blame] | 139 | " 1-cell, with 6 composing characters |
| 140 | set maxcombine=6 |
| 141 | call setline(1, ["ABC" .. repeat("\u0308", 6)]) |
| 142 | redraw |
| 143 | call assert_equal([0x0041], screenchars(1, 1)) |
| 144 | call assert_equal([0x0042], 1->screenchars(2)) |
| 145 | " This should not use uninitialized memory |
| 146 | call assert_equal([0x0043] + repeat([0x0308], 6), screenchars(1, 3)) |
| 147 | call assert_equal("A", screenstring(1, 1)) |
| 148 | call assert_equal("B", screenstring(1, 2)) |
| 149 | call assert_equal("C" .. repeat("\u0308", 6), screenstring(1, 3)) |
| 150 | set maxcombine& |
| 151 | |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 152 | " 2-cells, with composing characters |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 153 | let text = "\u3042\u3044\u3046\u3099" |
| 154 | call setline(1, text) |
| 155 | redraw |
| 156 | call assert_equal([0x3042], screenchars(1, 1)) |
| 157 | call assert_equal([0], screenchars(1, 2)) |
| 158 | call assert_equal([0x3044], screenchars(1, 3)) |
| 159 | call assert_equal([0], screenchars(1, 4)) |
| 160 | call assert_equal([0x3046, 0x3099], screenchars(1, 5)) |
| 161 | |
| 162 | call assert_equal("\u3042", screenstring(1, 1)) |
| 163 | call assert_equal("", screenstring(1, 2)) |
| 164 | call assert_equal("\u3044", screenstring(1, 3)) |
| 165 | call assert_equal("", screenstring(1, 4)) |
| 166 | call assert_equal("\u3046\u3099", screenstring(1, 5)) |
| 167 | |
Bram Moolenaar | 48aed08 | 2019-03-30 15:44:17 +0100 | [diff] [blame] | 168 | call assert_equal([text . ' '], ScreenLines(1, 8)) |
Bram Moolenaar | 2912abb | 2019-03-29 14:16:42 +0100 | [diff] [blame] | 169 | |
| 170 | bwipe! |
| 171 | endfunc |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 172 | |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 173 | func Test_setcellwidths() |
zeertzjq | 05aacec | 2024-04-14 18:52:49 +0200 | [diff] [blame] | 174 | new |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 175 | call setcellwidths([ |
| 176 | \ [0x1330, 0x1330, 2], |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 177 | \ [9999, 10000, 1], |
Bram Moolenaar | b06a6d5 | 2020-08-28 23:27:20 +0200 | [diff] [blame] | 178 | \ [0x1337, 0x1339, 2], |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 179 | \]) |
| 180 | |
| 181 | call assert_equal(2, strwidth("\u1330")) |
| 182 | call assert_equal(1, strwidth("\u1336")) |
| 183 | call assert_equal(2, strwidth("\u1337")) |
| 184 | call assert_equal(2, strwidth("\u1339")) |
| 185 | call assert_equal(1, strwidth("\u133a")) |
| 186 | |
K.Takata | 7193323 | 2023-01-20 16:00:55 +0000 | [diff] [blame] | 187 | for aw in ['single', 'double'] |
| 188 | exe 'set ambiwidth=' . aw |
| 189 | " Handle \u0080 to \u009F as control chars even on MS-Windows. |
| 190 | set isprint=@,161-255 |
| 191 | |
| 192 | call setcellwidths([]) |
| 193 | " Control chars |
| 194 | call assert_equal(4, strwidth("\u0081")) |
| 195 | call assert_equal(6, strwidth("\uFEFF")) |
| 196 | " Ambiguous width chars |
| 197 | call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u00A1")) |
| 198 | call assert_equal((aw == 'single') ? 1 : 2, strwidth("\u2010")) |
| 199 | |
| 200 | call setcellwidths([[0x81, 0x81, 1], [0xA1, 0xA1, 1], |
| 201 | \ [0x2010, 0x2010, 1], [0xFEFF, 0xFEFF, 1]]) |
| 202 | " Control chars |
| 203 | call assert_equal(4, strwidth("\u0081")) |
| 204 | call assert_equal(6, strwidth("\uFEFF")) |
| 205 | " Ambiguous width chars |
| 206 | call assert_equal(1, strwidth("\u00A1")) |
| 207 | call assert_equal(1, strwidth("\u2010")) |
| 208 | |
| 209 | call setcellwidths([[0x81, 0x81, 2], [0xA1, 0xA1, 2], |
| 210 | \ [0x2010, 0x2010, 2], [0xFEFF, 0xFEFF, 2]]) |
| 211 | " Control chars |
| 212 | call assert_equal(4, strwidth("\u0081")) |
| 213 | call assert_equal(6, strwidth("\uFEFF")) |
| 214 | " Ambiguous width chars |
| 215 | call assert_equal(2, strwidth("\u00A1")) |
| 216 | call assert_equal(2, strwidth("\u2010")) |
zeertzjq | 05aacec | 2024-04-14 18:52:49 +0200 | [diff] [blame] | 217 | |
| 218 | call setcellwidths([]) |
| 219 | call setline(1, repeat("\u2103", 10)) |
| 220 | normal! $ |
| 221 | redraw |
| 222 | call assert_equal((aw == 'single') ? 10 : 19, wincol()) |
| 223 | call setcellwidths([[0x2103, 0x2103, 1]]) |
| 224 | redraw |
| 225 | call assert_equal(10, wincol()) |
| 226 | call setcellwidths([[0x2103, 0x2103, 2]]) |
| 227 | redraw |
| 228 | call assert_equal(19, wincol()) |
Ken Takata | 539e9b5 | 2024-09-05 17:19:34 +0200 | [diff] [blame] | 229 | call setcellwidths([]) |
| 230 | redraw |
| 231 | call assert_equal((aw == 'single') ? 10 : 19, wincol()) |
K.Takata | 7193323 | 2023-01-20 16:00:55 +0000 | [diff] [blame] | 232 | endfor |
| 233 | set ambiwidth& isprint& |
| 234 | |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 235 | call setcellwidths([]) |
| 236 | |
Bram Moolenaar | d83392a | 2022-09-01 12:22:46 +0100 | [diff] [blame] | 237 | call assert_fails('call setcellwidths(1)', 'E1211:') |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 238 | |
| 239 | call assert_fails('call setcellwidths([1, 2, 0])', 'E1109:') |
| 240 | |
| 241 | call assert_fails('call setcellwidths([[0x101]])', 'E1110:') |
| 242 | call assert_fails('call setcellwidths([[0x101, 0x102]])', 'E1110:') |
| 243 | call assert_fails('call setcellwidths([[0x101, 0x102, 1, 4]])', 'E1110:') |
| 244 | call assert_fails('call setcellwidths([["a"]])', 'E1110:') |
| 245 | |
| 246 | call assert_fails('call setcellwidths([[0x102, 0x101, 1]])', 'E1111:') |
| 247 | |
| 248 | call assert_fails('call setcellwidths([[0x101, 0x102, 0]])', 'E1112:') |
| 249 | call assert_fails('call setcellwidths([[0x101, 0x102, 3]])', 'E1112:') |
| 250 | |
| 251 | call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x115, 0x116, 2]])', 'E1113:') |
| 252 | call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:') |
| 253 | |
| 254 | call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:') |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 255 | |
zeertzjq | 66f65a4 | 2024-09-06 16:24:41 +0200 | [diff] [blame] | 256 | set listchars=tab:--\\u2192 fillchars=stl:\\u2501 |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 257 | call assert_fails('call setcellwidths([[0x2192, 0x2192, 2]])', 'E834:') |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 258 | call assert_fails('call setcellwidths([[0x2501, 0x2501, 2]])', 'E835:') |
| 259 | |
zeertzjq | 66f65a4 | 2024-09-06 16:24:41 +0200 | [diff] [blame] | 260 | call setcellwidths([[0x201c, 0x201d, 1]]) |
| 261 | set listchars& fillchars& ambiwidth=double |
| 262 | |
| 263 | set listchars=nbsp:\\u201c fillchars=vert:\\u201d |
| 264 | call assert_fails('call setcellwidths([])', 'E834:') |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 265 | set listchars& |
zeertzjq | 66f65a4 | 2024-09-06 16:24:41 +0200 | [diff] [blame] | 266 | call assert_fails('call setcellwidths([])', 'E835:') |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 267 | set fillchars& |
zeertzjq | 66f65a4 | 2024-09-06 16:24:41 +0200 | [diff] [blame] | 268 | |
zeertzjq | 94358a1 | 2021-10-20 11:01:15 +0100 | [diff] [blame] | 269 | call setcellwidths([]) |
zeertzjq | 66f65a4 | 2024-09-06 16:24:41 +0200 | [diff] [blame] | 270 | set ambiwidth& |
zeertzjq | 05aacec | 2024-04-14 18:52:49 +0200 | [diff] [blame] | 271 | bwipe! |
Bram Moolenaar | 08aac3c | 2020-08-28 21:04:24 +0200 | [diff] [blame] | 272 | endfunc |
| 273 | |
Kota Kato | 66bb9ae | 2023-01-17 18:31:56 +0000 | [diff] [blame] | 274 | func Test_getcellwidths() |
| 275 | call setcellwidths([]) |
| 276 | call assert_equal([], getcellwidths()) |
| 277 | |
| 278 | let widthlist = [ |
| 279 | \ [0x1330, 0x1330, 2], |
| 280 | \ [9999, 10000, 1], |
| 281 | \ [0x1337, 0x1339, 2], |
| 282 | \] |
| 283 | let widthlistsorted = [ |
| 284 | \ [0x1330, 0x1330, 2], |
| 285 | \ [0x1337, 0x1339, 2], |
| 286 | \ [9999, 10000, 1], |
| 287 | \] |
| 288 | call setcellwidths(widthlist) |
| 289 | call assert_equal(widthlistsorted, getcellwidths()) |
| 290 | |
| 291 | call setcellwidths([]) |
| 292 | endfunc |
| 293 | |
Yasuhiro Matsumoto | 2bc849f | 2023-01-10 16:03:08 +0000 | [diff] [blame] | 294 | func Test_setcellwidths_dump() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 295 | CheckScreendump |
Yasuhiro Matsumoto | 2bc849f | 2023-01-10 16:03:08 +0000 | [diff] [blame] | 296 | CheckRunVimInTerminal |
| 297 | |
| 298 | let lines =<< trim END |
| 299 | call setline(1, "\ue5ffDesktop") |
| 300 | END |
| 301 | call writefile(lines, 'XCellwidths', 'D') |
| 302 | let buf = RunVimInTerminal('-S XCellwidths', {'rows': 6}) |
| 303 | call VerifyScreenDump(buf, 'Test_setcellwidths_dump_1', {}) |
| 304 | |
| 305 | call term_sendkeys(buf, ":call setcellwidths([[0xe5ff, 0xe5ff, 2]])\<CR>") |
| 306 | call VerifyScreenDump(buf, 'Test_setcellwidths_dump_2', {}) |
| 307 | |
| 308 | call StopVimInTerminal(buf) |
| 309 | endfunc |
| 310 | |
zeertzjq | 094c439 | 2024-04-18 22:09:37 +0200 | [diff] [blame] | 311 | " Test setcellwidths() on characters that are not targets of 'ambiwidth'. |
mikoto2000 | e20fa59 | 2024-04-17 22:06:54 +0200 | [diff] [blame] | 312 | func Test_setcellwidths_with_non_ambiwidth_character_dump() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 313 | CheckScreendump |
mikoto2000 | e20fa59 | 2024-04-17 22:06:54 +0200 | [diff] [blame] | 314 | CheckRunVimInTerminal |
| 315 | |
| 316 | let lines =<< trim END |
| 317 | call setline(1, [repeat("\u279c", 60), repeat("\u279c", 60)]) |
| 318 | set ambiwidth=single |
| 319 | END |
| 320 | call writefile(lines, 'XCellwidthsWithNonAmbiwidthCharacter', 'D') |
| 321 | let buf = RunVimInTerminal('-S XCellwidthsWithNonAmbiwidthCharacter', {'rows': 6, 'cols': 50}) |
| 322 | call term_sendkeys(buf, ":call setcellwidths([[0x279c, 0x279c, 1]])\<CR>") |
| 323 | call term_sendkeys(buf, ":echo\<CR>") |
| 324 | call VerifyScreenDump(buf, 'Test_setcellwidths_with_non_ambiwidth_character_dump_1', {}) |
| 325 | |
| 326 | call term_sendkeys(buf, ":call setcellwidths([[0x279c, 0x279c, 2]])\<CR>") |
| 327 | call term_sendkeys(buf, ":echo\<CR>") |
| 328 | call VerifyScreenDump(buf, 'Test_setcellwidths_with_non_ambiwidth_character_dump_2', {}) |
| 329 | |
| 330 | call StopVimInTerminal(buf) |
| 331 | endfunc |
| 332 | |
zeertzjq | a59e031 | 2024-04-15 19:14:38 +0200 | [diff] [blame] | 333 | " For some reason this test causes Test_customlist_completion() to fail on CI, |
| 334 | " so run it as the last test. |
| 335 | func Test_zz_ambiwidth_hl_dump() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 336 | CheckScreendump |
zeertzjq | a59e031 | 2024-04-15 19:14:38 +0200 | [diff] [blame] | 337 | CheckRunVimInTerminal |
| 338 | |
| 339 | let lines =<< trim END |
| 340 | call setline(1, [repeat("\u2103", 60), repeat("\u2103", 60)]) |
| 341 | set ambiwidth=single cursorline list display=lastline |
| 342 | END |
| 343 | call writefile(lines, 'XAmbiwidthHl', 'D') |
| 344 | let buf = RunVimInTerminal('-S XAmbiwidthHl', {'rows': 6, 'cols': 50}) |
| 345 | call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {}) |
| 346 | |
| 347 | call term_sendkeys(buf, ":set ambiwidth=double\<CR>") |
| 348 | call term_sendkeys(buf, ":echo\<CR>") |
| 349 | call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_2', {}) |
| 350 | |
| 351 | call term_sendkeys(buf, ":set ambiwidth=single\<CR>") |
| 352 | call term_sendkeys(buf, ":echo\<CR>") |
| 353 | call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {}) |
| 354 | |
zeertzjq | a59e031 | 2024-04-15 19:14:38 +0200 | [diff] [blame] | 355 | call term_sendkeys(buf, ":call setcellwidths([[0x2103, 0x2103, 2]])\<CR>") |
| 356 | call term_sendkeys(buf, ":echo\<CR>") |
| 357 | call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_2', {}) |
| 358 | |
| 359 | call term_sendkeys(buf, ":call setcellwidths([[0x2103, 0x2103, 1]])\<CR>") |
| 360 | call term_sendkeys(buf, ":echo\<CR>") |
| 361 | call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {}) |
zeertzjq | a59e031 | 2024-04-15 19:14:38 +0200 | [diff] [blame] | 362 | |
| 363 | call StopVimInTerminal(buf) |
| 364 | endfunc |
| 365 | |
Bram Moolenaar | 1cbfc99 | 2020-12-02 12:37:37 +0100 | [diff] [blame] | 366 | func Test_print_overlong() |
| 367 | " Text with more composing characters than MB_MAXBYTES. |
| 368 | new |
| 369 | call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
| 370 | s/x/\=nr2char(1629)/g |
| 371 | print |
| 372 | bwipe! |
| 373 | endfunc |
| 374 | |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 375 | " vim: shiftwidth=2 sts=2 expandtab |