blob: ba0808956da0455147bfd008bdb6bd372e1d5170 [file] [log] [blame]
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02001" Test for options
2
Bram Moolenaarb00ef052020-09-12 14:53:53 +02003source shared.vim
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02004source check.vim
Bram Moolenaarcde0ff32020-04-04 14:00:39 +02005source view_util.vim
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02006
Bram Moolenaar1e115362019-01-09 23:01:02 +01007func Test_whichwrap()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02008 set whichwrap=b,s
9 call assert_equal('b,s', &whichwrap)
10
11 set whichwrap+=h,l
12 call assert_equal('b,s,h,l', &whichwrap)
13
14 set whichwrap+=h,l
15 call assert_equal('b,s,h,l', &whichwrap)
16
17 set whichwrap+=h,l
18 call assert_equal('b,s,h,l', &whichwrap)
19
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +010020 set whichwrap=h,h
21 call assert_equal('h', &whichwrap)
22
23 set whichwrap=h,h,h
24 call assert_equal('h', &whichwrap)
25
Bram Moolenaar004a6782020-04-11 17:09:31 +020026 " For compatibility with Vim 3.0 and before, number values are also
27 " supported for 'whichwrap'
28 set whichwrap=1
29 call assert_equal('b', &whichwrap)
30 set whichwrap=2
31 call assert_equal('s', &whichwrap)
32 set whichwrap=4
33 call assert_equal('h,l', &whichwrap)
34 set whichwrap=8
35 call assert_equal('<,>', &whichwrap)
36 set whichwrap=16
37 call assert_equal('[,]', &whichwrap)
38 set whichwrap=31
39 call assert_equal('b,s,h,l,<,>,[,]', &whichwrap)
40
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020041 set whichwrap&
Bram Moolenaar1e115362019-01-09 23:01:02 +010042endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020043
Bram Moolenaar1e115362019-01-09 23:01:02 +010044func Test_isfname()
Bram Moolenaar187a4f22017-02-23 17:07:14 +010045 " This used to cause Vim to access uninitialized memory.
46 set isfname=
47 call assert_equal("~X", expand("~X"))
48 set isfname&
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +000049 " Test for setting 'isfname' to an unsupported character
50 let save_isfname = &isfname
51 call assert_fails('exe $"set isfname+={"\u1234"}"', 'E474:')
52 call assert_equal(save_isfname, &isfname)
Bram Moolenaar1e115362019-01-09 23:01:02 +010053endfunc
Bram Moolenaar187a4f22017-02-23 17:07:14 +010054
zeertzjq0519ce02022-05-09 12:16:19 +010055" Test for getting the value of 'pastetoggle'
56func Test_pastetoggle()
57 " character with K_SPECIAL byte
58 let &pastetoggle = '…'
59 call assert_equal('…', &pastetoggle)
60 call assert_equal("\n pastetoggle=…", execute('set pastetoggle?'))
61
62 " modified character with K_SPECIAL byte
63 let &pastetoggle = '<M-…>'
64 call assert_equal('<M-…>', &pastetoggle)
65 call assert_equal("\n pastetoggle=<M-…>", execute('set pastetoggle?'))
66
67 " illegal bytes
68 let str = ":\x7f:\x80:\x90:\xd0:"
69 let &pastetoggle = str
70 call assert_equal(str, &pastetoggle)
71 call assert_equal("\n pastetoggle=" .. strtrans(str), execute('set pastetoggle?'))
zeertzjqbb404f52022-07-23 06:25:29 +010072
zeertzjq0519ce02022-05-09 12:16:19 +010073 unlet str
zeertzjqbb404f52022-07-23 06:25:29 +010074 set pastetoggle&
zeertzjq0519ce02022-05-09 12:16:19 +010075endfunc
76
Bram Moolenaar1e115362019-01-09 23:01:02 +010077func Test_wildchar()
Bram Moolenaara12e4032017-02-25 21:37:57 +010078 " Empty 'wildchar' used to access invalid memory.
79 call assert_fails('set wildchar=', 'E521:')
80 call assert_fails('set wildchar=abc', 'E521:')
81 set wildchar=<Esc>
82 let a=execute('set wildchar?')
83 call assert_equal("\n wildchar=<Esc>", a)
84 set wildchar=27
85 let a=execute('set wildchar?')
86 call assert_equal("\n wildchar=<Esc>", a)
87 set wildchar&
Bram Moolenaar1e115362019-01-09 23:01:02 +010088endfunc
Bram Moolenaara12e4032017-02-25 21:37:57 +010089
Bram Moolenaar2e61e2d2020-05-22 14:10:36 +020090func Test_wildoptions()
91 set wildoptions=
92 set wildoptions+=tagfile
93 set wildoptions+=tagfile
94 call assert_equal('tagfile', &wildoptions)
95endfunc
96
Bram Moolenaar6b915c02020-01-18 15:53:19 +010097func Test_options_command()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020098 let caught = 'ok'
99 try
100 options
101 catch
102 let caught = v:throwpoint . "\n" . v:exception
103 endtry
104 call assert_equal('ok', caught)
105
Bram Moolenaare0b59492019-05-21 20:54:45 +0200106 " Check if the option-window is opened horizontally.
107 wincmd j
108 call assert_notequal('option-window', bufname(''))
109 wincmd k
110 call assert_equal('option-window', bufname(''))
111 " close option-window
112 close
113
114 " Open the option-window vertically.
115 vert options
116 " Check if the option-window is opened vertically.
117 wincmd l
118 call assert_notequal('option-window', bufname(''))
119 wincmd h
120 call assert_equal('option-window', bufname(''))
121 " close option-window
122 close
123
Bram Moolenaar7a1637f2020-04-13 21:16:21 +0200124 " Open the option-window at the top.
125 set splitbelow
126 topleft options
127 call assert_equal(1, winnr())
128 close
129
130 " Open the option-window at the bottom.
131 set nosplitbelow
132 botright options
133 call assert_equal(winnr('$'), winnr())
134 close
135 set splitbelow&
136
Bram Moolenaare0b59492019-05-21 20:54:45 +0200137 " Open the option-window in a new tab.
138 tab options
139 " Check if the option-window is opened in a tab.
140 normal gT
141 call assert_notequal('option-window', bufname(''))
142 normal gt
143 call assert_equal('option-window', bufname(''))
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200144 " close option-window
145 close
Bram Moolenaar004a6782020-04-11 17:09:31 +0200146
147 " Open the options window browse
148 if has('browse')
149 browse set
150 call assert_equal('option-window', bufname(''))
151 close
152 endif
Bram Moolenaar1e115362019-01-09 23:01:02 +0100153endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200154
Bram Moolenaar1e115362019-01-09 23:01:02 +0100155func Test_path_keep_commas()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200156 " Test that changing 'path' keeps two commas.
157 set path=foo,,bar
158 set path-=bar
159 set path+=bar
160 call assert_equal('foo,,bar', &path)
161
162 set path&
Bram Moolenaar1e115362019-01-09 23:01:02 +0100163endfunc
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200164
Dominique Pellef645ee42021-12-05 13:21:18 +0000165func Test_path_too_long()
166 exe 'set path=' .. repeat('x', 10000)
167 call assert_fails('find x', 'E854:')
168 set path&
169endfunc
170
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200171func Test_signcolumn()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200172 CheckFeature signs
173 call assert_equal("auto", &signcolumn)
174 set signcolumn=yes
175 set signcolumn=no
176 call assert_fails('set signcolumn=nope')
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200177endfunc
178
Bram Moolenaard0b51382016-11-04 15:23:45 +0100179func Test_filetype_valid()
180 set ft=valid_name
181 call assert_equal("valid_name", &filetype)
182 set ft=valid-name
183 call assert_equal("valid-name", &filetype)
184
185 call assert_fails(":set ft=wrong;name", "E474:")
186 call assert_fails(":set ft=wrong\\\\name", "E474:")
187 call assert_fails(":set ft=wrong\\|name", "E474:")
188 call assert_fails(":set ft=wrong/name", "E474:")
189 call assert_fails(":set ft=wrong\\\nname", "E474:")
190 call assert_equal("valid-name", &filetype)
191
192 exe "set ft=trunc\x00name"
193 call assert_equal("trunc", &filetype)
194endfunc
195
196func Test_syntax_valid()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200197 CheckFeature syntax
Bram Moolenaard0b51382016-11-04 15:23:45 +0100198 set syn=valid_name
199 call assert_equal("valid_name", &syntax)
200 set syn=valid-name
201 call assert_equal("valid-name", &syntax)
202
203 call assert_fails(":set syn=wrong;name", "E474:")
204 call assert_fails(":set syn=wrong\\\\name", "E474:")
205 call assert_fails(":set syn=wrong\\|name", "E474:")
206 call assert_fails(":set syn=wrong/name", "E474:")
207 call assert_fails(":set syn=wrong\\\nname", "E474:")
208 call assert_equal("valid-name", &syntax)
209
210 exe "set syn=trunc\x00name"
211 call assert_equal("trunc", &syntax)
212endfunc
213
214func Test_keymap_valid()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200215 CheckFeature keymap
Bram Moolenaard0b51382016-11-04 15:23:45 +0100216 call assert_fails(":set kmp=valid_name", "E544:")
217 call assert_fails(":set kmp=valid_name", "valid_name")
218 call assert_fails(":set kmp=valid-name", "E544:")
219 call assert_fails(":set kmp=valid-name", "valid-name")
220
221 call assert_fails(":set kmp=wrong;name", "E474:")
222 call assert_fails(":set kmp=wrong\\\\name", "E474:")
223 call assert_fails(":set kmp=wrong\\|name", "E474:")
224 call assert_fails(":set kmp=wrong/name", "E474:")
225 call assert_fails(":set kmp=wrong\\\nname", "E474:")
226
227 call assert_fails(":set kmp=trunc\x00name", "E544:")
228 call assert_fails(":set kmp=trunc\x00name", "trunc")
229endfunc
Bram Moolenaar7554da42016-11-25 22:04:13 +0100230
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100231func Check_dir_option(name)
Bram Moolenaar7554da42016-11-25 22:04:13 +0100232 " Check that it's possible to set the option.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100233 exe 'set ' . a:name . '=/usr/share/dict/words'
234 call assert_equal('/usr/share/dict/words', eval('&' . a:name))
235 exe 'set ' . a:name . '=/usr/share/dict/words,/and/there'
236 call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name))
237 exe 'set ' . a:name . '=/usr/share/dict\ words'
238 call assert_equal('/usr/share/dict words', eval('&' . a:name))
Bram Moolenaar7554da42016-11-25 22:04:13 +0100239
240 " Check rejecting weird characters.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100241 call assert_fails("set " . a:name . "=/not&there", "E474:")
242 call assert_fails("set " . a:name . "=/not>there", "E474:")
243 call assert_fails("set " . a:name . "=/not.*there", "E474:")
244endfunc
245
Bram Moolenaar60629d62017-02-23 18:08:56 +0100246func Test_cinkeys()
247 " This used to cause invalid memory access
248 set cindent cinkeys=0
249 norm a
250 set cindent& cinkeys&
251endfunc
252
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100253func Test_dictionary()
254 call Check_dir_option('dictionary')
255endfunc
256
257func Test_thesaurus()
258 call Check_dir_option('thesaurus')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100259endfun
260
Bram Moolenaar226c5342017-02-17 14:53:15 +0100261func Test_complete()
262 " Trailing single backslash used to cause invalid memory access.
263 set complete=s\
264 new
265 call feedkeys("i\<C-N>\<Esc>", 'xt')
266 bwipe!
Bram Moolenaaree4e0c12020-04-06 21:35:05 +0200267 call assert_fails('set complete=ix', 'E535:')
Bram Moolenaar226c5342017-02-17 14:53:15 +0100268 set complete&
269endfun
270
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100271func Test_set_completion()
272 call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
273 call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
274
Bram Moolenaar297610b2019-12-27 17:20:55 +0100275 call feedkeys(":setlocal di\<C-A>\<C-B>\"\<CR>", 'tx')
276 call assert_equal('"setlocal dictionary diff diffexpr diffopt digraph directory display', @:)
277
278 call feedkeys(":setglobal di\<C-A>\<C-B>\"\<CR>", 'tx')
279 call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:)
280
Bram Moolenaar048d9d22023-05-06 22:21:11 +0100281 " Expand boolean options. When doing :set no<Tab> Vim prefixes the option
282 " names with "no".
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100283 call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaar048d9d22023-05-06 22:21:11 +0100284 call assert_equal('"set nodiff nodigraph', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100285
286 call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaar048d9d22023-05-06 22:21:11 +0100287 call assert_equal('"set invdiff invdigraph', @:)
288
289 " Expanding "set noinv" does nothing.
290 call feedkeys(":set noinv\<C-A>\<C-B>\"\<CR>", 'tx')
291 call assert_equal('"set noinv', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100292
293 " Expand abbreviation of options.
294 call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaarabdcfd12021-10-16 16:48:27 +0100295 call assert_equal('"set tabstop thesaurus thesaurusfunc ttyscroll', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100296
297 " Expand current value
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200298 call feedkeys(":set suffixes=\<C-A>\<C-B>\"\<CR>", 'tx')
299 call assert_equal('"set suffixes=.bak,~,.o,.h,.info,.swp,.obj', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100300
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200301 call feedkeys(":set suffixes:\<C-A>\<C-B>\"\<CR>", 'tx')
302 call assert_equal('"set suffixes:.bak,~,.o,.h,.info,.swp,.obj', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100303
304 " Expand key codes.
305 call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
306 call assert_equal('"set <Help> <Home>', @:)
307
308 " Expand terminal options.
309 call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaare023e882020-05-31 16:42:30 +0200310 call assert_equal('"set t_AB t_AF t_AU t_AL', @:)
Bram Moolenaar0ff5ded2020-05-07 18:43:44 +0200311 call assert_fails('call feedkeys(":set <t_afoo>=\<C-A>\<CR>", "xt")', 'E474:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100312
313 " Expand directories.
314 call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
315 call assert_match(' ./samples/ ', @:)
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200316 call assert_notmatch(' ./summarize.vim ', @:)
Yee Cheng Chin54844852023-10-09 18:12:31 +0200317 set cdpath&
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100318
319 " Expand files and directories.
320 call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200321 call assert_match(' ./samples/.* ./summarize.vim', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100322
323 call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
324 call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
Yee Cheng Chin54844852023-10-09 18:12:31 +0200325
326 " Expand files with spaces/commas in them. Make sure we delimit correctly.
327 "
328 " 'tags' allow for for spaces/commas to both act as delimiters, with actual
329 " spaces requiring double escape, and commas need a single escape.
330 " 'dictionary' is a normal comma-separated option where only commas act as
331 " delimiters, and both space/comma need one single escape.
332 " 'makeprg' is a non-comma-separated option. Commas don't need escape.
333 defer delete('Xfoo Xspace.txt')
334 defer delete('Xsp_dummy')
335 defer delete('Xbar,Xcomma.txt')
336 defer delete('Xcom_dummy')
337 call writefile([], 'Xfoo Xspace.txt')
338 call writefile([], 'Xsp_dummy')
339 call writefile([], 'Xbar,Xcomma.txt')
340 call writefile([], 'Xcom_dummy')
341
342 call feedkeys(':set tags=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
343 call assert_equal('"set tags=./Xfoo\ Xsp_dummy', @:)
344 call feedkeys(':set tags=./Xfoo\\\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
345 call assert_equal('"set tags=./Xfoo\\\ Xspace.txt', @:)
346 call feedkeys(':set dictionary=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
347 call assert_equal('"set dictionary=./Xfoo\ Xspace.txt', @:)
348
349 call feedkeys(':set dictionary=./Xbar,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
350 call assert_equal('"set dictionary=./Xbar,Xcom_dummy', @:)
351 if has('win32')
352 " In Windows, '\,' is literal, see `:help filename-backslash`, so this
353 " means we treat it as one file name.
354 call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
355 call assert_equal('"set dictionary=Xbar\,Xcomma.txt', @:)
356 else
357 " In other platforms, '\,' simply escape to ',', and indicate a delimiter
358 " to split into a separate file name. You need '\\,' to escape the comma
359 " as part of the file name.
360 call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
361 call assert_equal('"set dictionary=Xbar\,Xcom_dummy', @:)
362
363 call feedkeys(':set dictionary=Xbar\\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
364 call assert_equal('"set dictionary=Xbar\\,Xcomma.txt', @:)
365 endif
366 call feedkeys(":set makeprg=./Xbar,Xcom\<C-A>\<C-B>\"\<CR>", 'tx')
367 call assert_equal('"set makeprg=./Xbar,Xcomma.txt', @:)
368 set tags& dictionary& makeprg&
Bram Moolenaar1363a302020-04-12 13:50:26 +0200369
370 " Expanding the option names
371 call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')
372 call assert_equal('"set all', @:)
373
374 " Expanding a second set of option names
375 call feedkeys(":set wrapscan \<Tab>\<C-B>\"\<CR>", 'xt')
376 call assert_equal('"set wrapscan all', @:)
377
378 " Expanding a special keycode
379 call feedkeys(":set <Home>\<Tab>\<C-B>\"\<CR>", 'xt')
380 call assert_equal('"set <Home>', @:)
381
382 " Expanding an invalid special keycode
383 call feedkeys(":set <abcd>\<Tab>\<C-B>\"\<CR>", 'xt')
384 call assert_equal("\"set <abcd>\<Tab>", @:)
385
386 " Expanding a terminal keycode
387 call feedkeys(":set t_AB\<Tab>\<C-B>\"\<CR>", 'xt')
388 call assert_equal("\"set t_AB", @:)
389
390 " Expanding an invalid option name
391 call feedkeys(":set abcde=\<Tab>\<C-B>\"\<CR>", 'xt')
392 call assert_equal("\"set abcde=\<Tab>", @:)
393
394 " Expanding after a = for a boolean option
395 call feedkeys(":set wrapscan=\<Tab>\<C-B>\"\<CR>", 'xt')
396 call assert_equal("\"set wrapscan=\<Tab>", @:)
397
398 " Expanding a numeric option
399 call feedkeys(":set tabstop+=\<Tab>\<C-B>\"\<CR>", 'xt')
400 call assert_equal("\"set tabstop+=" .. &tabstop, @:)
401
402 " Expanding a non-boolean option
403 call feedkeys(":set invtabstop=\<Tab>\<C-B>\"\<CR>", 'xt')
404 call assert_equal("\"set invtabstop=", @:)
405
406 " Expand options for 'spellsuggest'
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200407 call feedkeys(":set spellsuggest=file:test_options.v\<Tab>\<C-B>\"\<CR>", 'xt')
408 call assert_equal("\"set spellsuggest=file:test_options.vim", @:)
409 call feedkeys(":set spellsuggest=best,file:test_options.v\<Tab>\<C-B>\"\<CR>", 'xt')
410 call assert_equal("\"set spellsuggest=best,file:test_options.vim", @:)
Bram Moolenaar1363a302020-04-12 13:50:26 +0200411
Yee Cheng Chin6ee7b522023-10-01 09:13:22 +0200412 " Expanding value for 'key' is disallowed
413 if exists('+key')
414 set key=abcd
415 call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
416 call assert_equal('"set key=', @:)
417 call feedkeys(":set key-=\<Tab>\<C-B>\"\<CR>", 'xt')
418 call assert_equal('"set key-=', @:)
419 set key=
420 endif
Bram Moolenaard5e8c922021-02-02 21:10:01 +0100421
422 " Expand values for 'filetype'
423 call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
424 call assert_equal('"set filetype=sshdconfig', @:)
425 call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
426 call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
Doug Kearns6dfdff32023-08-27 18:48:51 +0200427
428 " Expand values for 'syntax'
429 call feedkeys(":set syntax=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
430 call assert_equal('"set syntax=sshdconfig', @:)
431 call feedkeys(":set syntax=a\<C-A>\<C-B>\"\<CR>", 'xt')
432 call assert_equal('"set syntax=' .. getcompletion('a*', 'syntax')->join(), @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100433endfunc
434
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200435" Test handling of expanding individual string option values
436func Test_set_completion_string_values()
437 "
438 " Test basic enum string options that have well-defined enum names
439 "
440
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200441 call assert_equal(['lastline', 'truncate', 'uhex'], getcompletion('set display=', 'cmdline'))
442 call assert_equal(['truncate'], getcompletion('set display=t', 'cmdline'))
443 call assert_equal(['uhex'], getcompletion('set display=*ex*', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200444
445 " Test that if a value is set, it will populate the results, but only if
446 " typed value is empty.
447 set display=uhex,lastline
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200448 call assert_equal(['uhex,lastline', 'lastline', 'truncate', 'uhex'], getcompletion('set display=', 'cmdline'))
449 call assert_equal(['uhex'], getcompletion('set display=u', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200450 " If the set value is part of the enum list, it will show as the first
451 " result with no duplicate.
452 set display=uhex
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200453 call assert_equal(['uhex', 'lastline', 'truncate'], getcompletion('set display=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200454 " If empty value, will just show the normal list without an empty item
455 set display=
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200456 call assert_equal(['lastline', 'truncate', 'uhex'], getcompletion('set display=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200457 " Test escaping of the values
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200458 call assert_equal('vert:\|,fold:-,eob:~,lastline:@', getcompletion('set fillchars=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200459
460 " Test comma-separated lists will expand after a comma.
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200461 call assert_equal(['uhex'], getcompletion('set display=truncate,*ex*', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200462 " Also test the positioning of the expansion is correct
463 call feedkeys(":set display=truncate,l\<Tab>\<C-B>\"\<CR>", 'xt')
464 call assert_equal('"set display=truncate,lastline', @:)
465 set display&
466
467 " Test single-value options will not expand after a comma
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200468 call assert_equal([], getcompletion('set ambw=single,', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200469
470 " Test the other simple options to make sure they have basic auto-complete,
471 " but don't exhaustively validate their results.
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200472 call assert_equal('single', getcompletion('set ambw=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200473 call assert_match('light\|dark', getcompletion('set bg=', 'cmdline')[1])
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200474 call assert_equal('indent', getcompletion('set backspace=', 'cmdline')[0])
475 call assert_equal('yes', getcompletion('set backupcopy=', 'cmdline')[1])
476 call assert_equal('backspace', getcompletion('set belloff=', 'cmdline')[1])
477 call assert_equal('min:', getcompletion('set briopt=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200478 if exists('+browsedir')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200479 call assert_equal('current', getcompletion('set browsedir=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200480 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200481 call assert_equal('unload', getcompletion('set bufhidden=', 'cmdline')[1])
482 call assert_equal('nowrite', getcompletion('set buftype=', 'cmdline')[1])
483 call assert_equal('internal', getcompletion('set casemap=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200484 if exists('+clipboard')
485 call assert_match('unnamed', getcompletion('set clipboard=', 'cmdline')[1])
486 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200487 call assert_equal('.', getcompletion('set complete=', 'cmdline')[1])
488 call assert_equal('menu', getcompletion('set completeopt=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200489 if exists('+completeslash')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200490 call assert_equal('backslash', getcompletion('set completeslash=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200491 endif
492 if exists('+cryptmethod')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200493 call assert_equal('zip', getcompletion('set cryptmethod=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200494 endif
495 if exists('+cursorlineopt')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200496 call assert_equal('line', getcompletion('set cursorlineopt=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200497 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200498 call assert_equal('throw', getcompletion('set debug=', 'cmdline')[1])
499 call assert_equal('ver', getcompletion('set eadirection=', 'cmdline')[1])
500 call assert_equal('mac', getcompletion('set fileformat=', 'cmdline')[2])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200501 if exists('+foldclose')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200502 call assert_equal('all', getcompletion('set foldclose=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200503 endif
504 if exists('+foldmethod')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200505 call assert_equal('expr', getcompletion('set foldmethod=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200506 endif
507 if exists('+foldopen')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200508 call assert_equal('all', getcompletion('set foldopen=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200509 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200510 call assert_equal('stack', getcompletion('set jumpoptions=', 'cmdline')[0])
511 call assert_equal('stopsel', getcompletion('set keymodel=', 'cmdline')[1])
512 call assert_equal('expr:1', getcompletion('set lispoptions=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200513 call assert_match('popup', getcompletion('set mousemodel=', 'cmdline')[2])
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200514 call assert_equal('bin', getcompletion('set nrformats=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200515 if exists('+rightleftcmd')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200516 call assert_equal('search', getcompletion('set rightleftcmd=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200517 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200518 call assert_equal('ver', getcompletion('set scrollopt=', 'cmdline')[1])
519 call assert_equal('exclusive', getcompletion('set selection=', 'cmdline')[1])
520 call assert_equal('key', getcompletion('set selectmode=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200521 if exists('+ssop')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200522 call assert_equal('buffers', getcompletion('set ssop=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200523 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200524 call assert_equal('statusline', getcompletion('set showcmdloc=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200525 if exists('+signcolumn')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200526 call assert_equal('yes', getcompletion('set signcolumn=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200527 endif
528 if exists('+spelloptions')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200529 call assert_equal('camel', getcompletion('set spelloptions=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200530 endif
531 if exists('+spellsuggest')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200532 call assert_equal('best', getcompletion('set spellsuggest+=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200533 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200534 call assert_equal('screen', getcompletion('set splitkeep=', 'cmdline')[1])
535 call assert_equal('sync', getcompletion('set swapsync=', 'cmdline')[1])
536 call assert_equal('usetab', getcompletion('set switchbuf=', 'cmdline')[1])
537 call assert_equal('ignore', getcompletion('set tagcase=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200538 if exists('+termwintype')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200539 call assert_equal('conpty', getcompletion('set termwintype=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200540 endif
541 if exists('+toolbar')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200542 call assert_equal('text', getcompletion('set toolbar=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200543 endif
544 if exists('+tbis')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200545 call assert_equal('medium', getcompletion('set tbis=', 'cmdline')[2])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200546 endif
547 if exists('+ttymouse')
548 set ttymouse=
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200549 call assert_equal('xterm2', getcompletion('set ttymouse=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200550 set ttymouse&
551 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200552 call assert_equal('insert', getcompletion('set virtualedit=', 'cmdline')[1])
553 call assert_equal('longest', getcompletion('set wildmode=', 'cmdline')[1])
554 call assert_equal('full', getcompletion('set wildmode=list,longest:', 'cmdline')[0])
555 call assert_equal('tagfile', getcompletion('set wildoptions=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200556 if exists('+winaltkeys')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200557 call assert_equal('yes', getcompletion('set winaltkeys=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200558 endif
559
560 " Other string options that queries the system rather than fixed enum names
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200561 call assert_equal(['all', 'BufAdd'], getcompletion('set eventignore=', 'cmdline')[0:1])
562 call assert_equal('latin1', getcompletion('set fileencodings=', 'cmdline')[1])
563 call assert_equal('top', getcompletion('set printoptions=', 'cmdline')[0])
564 call assert_equal('SpecialKey', getcompletion('set wincolor=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200565
zeertzjq1f025b02023-09-30 12:43:07 +0200566 call assert_equal('eol', getcompletion('set listchars+=', 'cmdline')[0])
567 call assert_equal(['multispace', 'leadmultispace'], getcompletion('set listchars+=', 'cmdline')[-2:])
568 call assert_equal('eol', getcompletion('setl listchars+=', 'cmdline')[0])
569 call assert_equal(['multispace', 'leadmultispace'], getcompletion('setl listchars+=', 'cmdline')[-2:])
570 call assert_equal('stl', getcompletion('set fillchars+=', 'cmdline')[0])
571 call assert_equal('stl', getcompletion('setl fillchars+=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200572
573 "
574 " Unique string options below
575 "
576
577 " keyprotocol: only auto-complete when after ':' with known protocol types
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200578 call assert_equal([&keyprotocol], getcompletion('set keyprotocol=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200579 call feedkeys(":set keyprotocol+=someterm:m\<Tab>\<C-B>\"\<CR>", 'xt')
580 call assert_equal('"set keyprotocol+=someterm:mok2', @:)
581 set keyprotocol&
582
583 " previewpopup / completepopup
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200584 call assert_equal('height:', getcompletion('set previewpopup=', 'cmdline')[0])
585 call assert_equal('EndOfBuffer', getcompletion('set previewpopup=highlight:End*Buffer', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200586 call feedkeys(":set previewpopup+=border:\<Tab>\<C-B>\"\<CR>", 'xt')
587 call assert_equal('"set previewpopup+=border:on', @:)
588 call feedkeys(":set completepopup=height:10,align:\<Tab>\<C-B>\"\<CR>", 'xt')
589 call assert_equal('"set completepopup=height:10,align:item', @:)
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200590 call assert_equal([], getcompletion('set completepopup=bogusname:', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200591 set previewpopup& completepopup&
592
593 " diffopt: special handling of algorithm:<alg_list>
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200594 call assert_equal('filler', getcompletion('set diffopt+=', 'cmdline')[0])
595 call assert_equal([], getcompletion('set diffopt+=iblank,foldcolumn:', 'cmdline'))
596 call assert_equal('patience', getcompletion('set diffopt+=iblank,algorithm:pat*', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200597
598 " highlight: special parsing, including auto-completing highlight groups
599 " after ':'
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200600 call assert_equal([&hl, '8'], getcompletion('set hl=', 'cmdline')[0:1])
601 call assert_equal('8', getcompletion('set hl+=', 'cmdline')[0])
602 call assert_equal(['8:', '8b', '8i'], getcompletion('set hl+=8', 'cmdline')[0:2])
603 call assert_equal('8bi', getcompletion('set hl+=8b', 'cmdline')[0])
604 call assert_equal('NonText', getcompletion('set hl+=8:No*ext', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200605 " If all the display modes are used up we should be suggesting nothing. Make
606 " a hl typed option with all the modes which will look like '8bi-nrsuc2d=t',
607 " and make sure nothing is suggested from that.
608 let hl_display_modes = join(
609 \ filter(map(getcompletion('set hl+=8', 'cmdline'),
610 \ {idx, val -> val[1]}),
611 \ {idx, val -> val != ':'}),
612 \ '')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200613 call assert_equal([], getcompletion('set hl+=8'..hl_display_modes, 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200614
615 "
616 " Test flag lists
617 "
618
619 " Test set=. Show the original value if nothing is typed after '='.
620 " Otherwise, the list should avoid showing what's already typed.
621 set mouse=v
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200622 call assert_equal(['v','a','n','i','c','h','r'], getcompletion('set mouse=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200623 set mouse=nvi
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200624 call assert_equal(['nvi','a','n','v','i','c','h','r'], getcompletion('set mouse=', 'cmdline'))
625 call assert_equal(['a','v','i','c','r'], getcompletion('set mouse=hn', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200626
627 " Test set+=. Never show original value, and it also tries to avoid listing
628 " flags that's already in the option value.
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200629 call assert_equal(['a','c','h','r'], getcompletion('set mouse+=', 'cmdline'))
630 call assert_equal(['a','c','r'], getcompletion('set mouse+=hn', 'cmdline'))
631 call assert_equal([], getcompletion('set mouse+=acrhn', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200632
633 " Test that the position of the expansion is correct (even if there are
634 " additional values after the current cursor)
635 call feedkeys(":set mouse=hn\<Left>\<Tab>\<C-B>\"\<CR>", 'xt')
636 call assert_equal('"set mouse=han', @:)
637 set mouse&
638
639 " Test that other flag list options have auto-complete, but don't
640 " exhaustively validate their results.
641 if exists('+concealcursor')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200642 call assert_equal('n', getcompletion('set cocu=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200643 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200644 call assert_equal('a', getcompletion('set cpo=', 'cmdline')[1])
645 call assert_equal('t', getcompletion('set fo=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200646 if exists('+guioptions')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200647 call assert_equal('!', getcompletion('set go=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200648 endif
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200649 call assert_equal('r', getcompletion('set shortmess=', 'cmdline')[1])
650 call assert_equal('b', getcompletion('set whichwrap=', 'cmdline')[1])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200651
652 "
653 "Test set-=
654 "
655
656 " Normal single-value option just shows the existing value
657 set ambiwidth=double
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200658 call assert_equal(['double'], getcompletion('set ambw-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200659 set ambiwidth&
660
661 " Works on numbers and term options as well
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200662 call assert_equal([string(&laststatus)], getcompletion('set laststatus-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200663 set t_Ce=testCe
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200664 call assert_equal(['testCe'], getcompletion('set t_Ce-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200665 set t_Ce&
666
667 " Comma-separated lists should present each option
668 set diffopt=context:123,,,,,iblank,iwhiteall
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200669 call assert_equal(['context:123', 'iblank', 'iwhiteall'], getcompletion('set diffopt-=', 'cmdline'))
670 call assert_equal(['context:123', 'iblank'], getcompletion('set diffopt-=*n*', 'cmdline'))
671 call assert_equal(['iblank', 'iwhiteall'], getcompletion('set diffopt-=i', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200672 " Don't present more than one option as it doesn't make sense in set-=
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200673 call assert_equal([], getcompletion('set diffopt-=iblank,', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200674 " Test empty option
675 set diffopt=
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200676 call assert_equal([], getcompletion('set diffopt-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200677 set diffopt&
678
679 " Test escaping output
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200680 call assert_equal('vert:\|', getcompletion('set fillchars-=', 'cmdline')[0])
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200681
682 " Test files with commas in name are being parsed and escaped properly
683 set path=has\\\ space,file\\,with\\,comma,normal_file
684 if exists('+completeslash')
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200685 call assert_equal(['has\\\ space', 'file\,with\,comma', 'normal_file'], getcompletion('set path-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200686 else
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200687 call assert_equal(['has\\\ space', 'file\\,with\\,comma', 'normal_file'], getcompletion('set path-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200688 endif
689 set path&
690
691 " Flag list should present orig value, then individual flags
692 set mouse=v
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200693 call assert_equal(['v'], getcompletion('set mouse-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200694 set mouse=avn
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200695 call assert_equal(['avn','a','v','n'], getcompletion('set mouse-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200696 " Don't auto-complete when we have at least one flags already
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200697 call assert_equal([], getcompletion('set mouse-=n', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200698 " Test empty option
699 set mouse=
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200700 call assert_equal([], getcompletion('set mouse-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200701 set mouse&
702
703 " 'whichwrap' is an odd case where it's both flag list and comma-separated
704 set ww=b,h
Yee Cheng Chin6d113472023-10-02 21:38:39 +0200705 call assert_equal(['b','h'], getcompletion('set ww-=', 'cmdline'))
Yee Cheng Chin900894b2023-09-29 20:42:32 +0200706 set ww&
707endfunc
708
zeertzjq4c7cb372023-06-14 16:39:54 +0100709func Test_set_option_errors()
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100710 call assert_fails('set scroll=-1', 'E49:')
711 call assert_fails('set backupcopy=', 'E474:')
712 call assert_fails('set regexpengine=3', 'E474:')
713 call assert_fails('set history=10001', 'E474:')
Bram Moolenaarf8a07122019-07-01 22:06:07 +0200714 call assert_fails('set numberwidth=21', 'E474:')
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100715 call assert_fails('set colorcolumn=-a', 'E474:')
716 call assert_fails('set colorcolumn=a', 'E474:')
717 call assert_fails('set colorcolumn=1,', 'E474:')
718 call assert_fails('set colorcolumn=1;', 'E474:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100719 call assert_fails('set cmdheight=-1', 'E487:')
720 call assert_fails('set cmdwinheight=-1', 'E487:')
721 if has('conceal')
722 call assert_fails('set conceallevel=-1', 'E487:')
723 call assert_fails('set conceallevel=4', 'E474:')
724 endif
725 call assert_fails('set helpheight=-1', 'E487:')
726 call assert_fails('set history=-1', 'E487:')
727 call assert_fails('set report=-1', 'E487:')
728 call assert_fails('set shiftwidth=-1', 'E487:')
729 call assert_fails('set sidescroll=-1', 'E487:')
730 call assert_fails('set tabstop=-1', 'E487:')
Bram Moolenaar652dee42022-01-28 20:47:49 +0000731 call assert_fails('set tabstop=10000', 'E474:')
Bram Moolenaar8ccbbeb2022-03-02 19:49:38 +0000732 call assert_fails('let &tabstop = 10000', 'E474:')
Bram Moolenaar652dee42022-01-28 20:47:49 +0000733 call assert_fails('set tabstop=5500000000', 'E474:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100734 call assert_fails('set textwidth=-1', 'E487:')
735 call assert_fails('set timeoutlen=-1', 'E487:')
736 call assert_fails('set updatecount=-1', 'E487:')
737 call assert_fails('set updatetime=-1', 'E487:')
738 call assert_fails('set winheight=-1', 'E487:')
739 call assert_fails('set tabstop!', 'E488:')
740 call assert_fails('set xxx', 'E518:')
741 call assert_fails('set beautify?', 'E519:')
742 call assert_fails('set undolevels=x', 'E521:')
743 call assert_fails('set tabstop=', 'E521:')
744 call assert_fails('set comments=-', 'E524:')
745 call assert_fails('set comments=a', 'E525:')
746 call assert_fails('set foldmarker=x', 'E536:')
747 call assert_fails('set commentstring=x', 'E537:')
Bram Moolenaar8ccbbeb2022-03-02 19:49:38 +0000748 call assert_fails('let &commentstring = "x"', 'E537:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100749 call assert_fails('set complete=x', 'E539:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100750 call assert_fails('set rulerformat=%-', 'E539:')
751 call assert_fails('set rulerformat=%(', 'E542:')
752 call assert_fails('set rulerformat=%15(%%', 'E542:')
753 call assert_fails('set statusline=%$', 'E539:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100754 call assert_fails('set statusline=%{', 'E540:')
zeertzjq5dc294a2022-04-15 13:17:57 +0100755 call assert_fails('set statusline=%{%', 'E540:')
756 call assert_fails('set statusline=%{%}', 'E539:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100757 call assert_fails('set statusline=%(', 'E542:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100758 call assert_fails('set statusline=%)', 'E542:')
zeertzjq5dc294a2022-04-15 13:17:57 +0100759 call assert_fails('set tabline=%$', 'E539:')
760 call assert_fails('set tabline=%{', 'E540:')
761 call assert_fails('set tabline=%{%', 'E540:')
762 call assert_fails('set tabline=%{%}', 'E539:')
763 call assert_fails('set tabline=%(', 'E542:')
764 call assert_fails('set tabline=%)', 'E542:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100765
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100766 if has('cursorshape')
767 " This invalid value for 'guicursor' used to cause Vim to crash.
768 call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
769 call assert_fails('set guicursor=i-ci', 'E545:')
770 call assert_fails('set guicursor=x', 'E545:')
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100771 call assert_fails('set guicursor=x:', 'E546:')
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100772 call assert_fails('set guicursor=r-cr:horx', 'E548:')
773 call assert_fails('set guicursor=r-cr:hor0', 'E549:')
774 endif
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100775 if has('mouseshape')
776 call assert_fails('se mouseshape=i-r:x', 'E547:')
777 endif
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +0000778
779 " Test for 'backupext' and 'patchmode' set to the same value
780 set backupext=.bak
781 set patchmode=.patch
782 call assert_fails('set patchmode=.bak', 'E589:')
783 call assert_equal('.patch', &patchmode)
784 call assert_fails('set backupext=.patch', 'E589:')
785 call assert_equal('.bak', &backupext)
786 set backupext& patchmode&
787
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100788 call assert_fails('set winminheight=10 winheight=9', 'E591:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200789 set winminheight& winheight&
790 set winheight=10 winminheight=10
791 call assert_fails('set winheight=9', 'E591:')
792 set winminheight& winheight&
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100793 call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200794 set winminwidth& winwidth&
795 call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
796 set winwidth& winminwidth&
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100797 call assert_fails("set showbreak=\x01", 'E595:')
798 call assert_fails('set t_foo=', 'E846:')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200799 call assert_fails('set tabstop??', 'E488:')
800 call assert_fails('set wrapscan!!', 'E488:')
801 call assert_fails('set tabstop&&', 'E488:')
802 call assert_fails('set wrapscan<<', 'E488:')
803 call assert_fails('set wrapscan=1', 'E474:')
804 call assert_fails('set autoindent@', 'E488:')
805 call assert_fails('set wildchar=<abc>', 'E474:')
806 call assert_fails('set cmdheight=1a', 'E521:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200807 call assert_fails('set invcmdheight', 'E474:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100808 if has('python') || has('python3')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200809 call assert_fails('set pyxversion=6', 'E474:')
810 endif
zeertzjq4c7cb372023-06-14 16:39:54 +0100811 call assert_fails("let &tabstop='ab'", ['E521:', 'E521:'])
Bram Moolenaar531be472020-09-23 22:38:05 +0200812 call assert_fails('set spellcapcheck=%\\(', 'E54:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100813 call assert_fails('set sessionoptions=curdir,sesdir', 'E474:')
814 call assert_fails('set foldmarker={{{,', 'E474:')
815 call assert_fails('set sessionoptions=sesdir,curdir', 'E474:')
zeertzjq8ca29b62022-08-09 12:53:14 +0100816 setlocal listchars=trail:·
817 call assert_fails('set ambiwidth=double', 'E834:')
818 setlocal listchars=trail:-
819 setglobal listchars=trail:·
820 call assert_fails('set ambiwidth=double', 'E834:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100821 set listchars&
zeertzjq8ca29b62022-08-09 12:53:14 +0100822 setlocal fillchars=stl:·
823 call assert_fails('set ambiwidth=double', 'E835:')
824 setlocal fillchars=stl:-
825 setglobal fillchars=stl:·
826 call assert_fails('set ambiwidth=double', 'E835:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100827 set fillchars&
828 call assert_fails('set fileencoding=latin1,utf-8', 'E474:')
829 set nomodifiable
830 call assert_fails('set fileencoding=latin1', 'E21:')
831 set modifiable&
Yegappan Lakshmanan59585492021-06-12 13:46:41 +0200832 call assert_fails('set t_#-&', 'E522:')
Yegappan Lakshmanan32ff96e2023-02-13 16:10:04 +0000833 call assert_fails('let &formatoptions = "?"', 'E539:')
834 call assert_fails('call setbufvar("", "&formatoptions", "?")', 'E539:')
zeertzjq4c7cb372023-06-14 16:39:54 +0100835 call assert_fails('call setwinvar(0, "&scrolloff", [])', ['E745:', 'E745:'])
836 call assert_fails('call setwinvar(0, "&list", [])', ['E745:', 'E745:'])
837 call assert_fails('call setwinvar(0, "&listchars", [])', ['E730:', 'E730:'])
838 call assert_fails('call setwinvar(0, "&nosuchoption", 0)', ['E355:', 'E355:'])
839 call assert_fails('call setwinvar(0, "&nosuchoption", "")', ['E355:', 'E355:'])
840 call assert_fails('call setwinvar(0, "&nosuchoption", [])', ['E355:', 'E355:'])
Bram Moolenaar7554da42016-11-25 22:04:13 +0100841endfunc
Bram Moolenaar67391142017-02-19 21:07:04 +0100842
Bram Moolenaar1349bd72022-02-22 12:34:28 +0000843func Test_set_encoding()
844 let save_encoding = &encoding
845
846 set enc=iso8859-1
847 call assert_equal('latin1', &enc)
848 set enc=iso8859_1
849 call assert_equal('latin1', &enc)
850 set enc=iso-8859-1
851 call assert_equal('latin1', &enc)
852 set enc=iso_8859_1
853 call assert_equal('latin1', &enc)
854 set enc=iso88591
855 call assert_equal('latin1', &enc)
856 set enc=iso8859
857 call assert_equal('latin1', &enc)
858 set enc=iso-8859
859 call assert_equal('latin1', &enc)
860 set enc=iso_8859
861 call assert_equal('latin1', &enc)
862 call assert_fails('set enc=iso8858', 'E474:')
863 call assert_equal('latin1', &enc)
864
865 let &encoding = save_encoding
866endfunc
867
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200868func CheckWasSet(name)
869 let verb_cm = execute('verbose set ' .. a:name .. '?')
870 call assert_match('Last set from.*test_options.vim', verb_cm)
871endfunc
872func CheckWasNotSet(name)
873 let verb_cm = execute('verbose set ' .. a:name .. '?')
874 call assert_notmatch('Last set from', verb_cm)
875endfunc
876
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200877" Must be executed before other tests that set 'term'.
878func Test_000_term_option_verbose()
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200879 CheckNotGui
880
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200881 call CheckWasNotSet('t_cm')
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200882
883 let term_save = &term
884 set term=ansi
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200885 call CheckWasSet('t_cm')
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200886 let &term = term_save
887endfunc
888
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200889func Test_copy_context()
890 setlocal list
891 call CheckWasSet('list')
892 split
893 call CheckWasSet('list')
894 quit
895 setlocal nolist
896
897 set ai
898 call CheckWasSet('ai')
899 set filetype=perl
900 call CheckWasSet('filetype')
901 set fo=tcroq
902 call CheckWasSet('fo')
903
904 split Xsomebuf
905 call CheckWasSet('ai')
906 call CheckWasNotSet('filetype')
907 call CheckWasSet('fo')
908endfunc
909
Bram Moolenaar67391142017-02-19 21:07:04 +0100910func Test_set_ttytype()
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200911 CheckUnix
912 CheckNotGui
Bram Moolenaarf803a762017-04-09 22:54:13 +0200913
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200914 " Setting 'ttytype' used to cause a double-free when exiting vim and
915 " when vim is compiled with -DEXITFREE.
916 set ttytype=ansi
917 call assert_equal('ansi', &ttytype)
918 call assert_equal(&ttytype, &term)
919 set ttytype=xterm
920 call assert_equal('xterm', &ttytype)
921 call assert_equal(&ttytype, &term)
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200922 try
923 set ttytype=
924 call assert_report('set ttytype= did not fail')
Bram Moolenaar5daa9112021-02-01 18:39:47 +0100925 catch /E529/
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200926 endtry
Bram Moolenaarf803a762017-04-09 22:54:13 +0200927
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200928 " Some systems accept any terminal name and return dumb settings,
929 " check for failure of finding the entry and for missing 'cm' entry.
930 try
931 set ttytype=xxx
932 call assert_report('set ttytype=xxx did not fail')
933 catch /E522\|E437/
934 endtry
935
936 set ttytype&
937 call assert_equal(&ttytype, &term)
Bram Moolenaaree4e0c12020-04-06 21:35:05 +0200938
939 if has('gui') && !has('gui_running')
940 call assert_fails('set term=gui', 'E531:')
941 endif
Bram Moolenaar67391142017-02-19 21:07:04 +0100942endfunc
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100943
944func Test_set_all()
945 set tw=75
946 set iskeyword=a-z,A-Z
947 set nosplitbelow
948 let out = execute('set all')
949 call assert_match('textwidth=75', out)
950 call assert_match('iskeyword=a-z,A-Z', out)
951 call assert_match('nosplitbelow', out)
952 set tw& iskeyword& splitbelow&
953endfunc
954
Bram Moolenaar6b915c02020-01-18 15:53:19 +0100955func Test_set_one_column()
956 let out_mult = execute('set all')->split("\n")
957 let out_one = execute('set! all')->split("\n")
Bram Moolenaarab505b12020-03-23 19:28:44 +0100958 call assert_true(len(out_mult) < len(out_one))
Bram Moolenaar6b915c02020-01-18 15:53:19 +0100959endfunc
960
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100961func Test_set_values()
Bram Moolenaarbdd2c292020-06-22 21:34:30 +0200962 " opt_test.vim is generated from ../optiondefs.h using gen_opt_test.vim
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100963 if filereadable('opt_test.vim')
964 source opt_test.vim
Bram Moolenaare8512d72017-03-07 22:33:32 +0100965 else
966 throw 'Skipped: opt_test.vim does not exist'
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100967 endif
968endfunc
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200969
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100970func Test_renderoptions()
971 " Only do this for Windows Vista and later, fails on Windows XP and earlier.
972 " Doesn't hurt to do this on a non-Windows system.
973 if windowsversion() !~ '^[345]\.'
974 set renderoptions=type:directx
975 set rop=type:directx
976 endif
977endfunc
978
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200979func ResetIndentexpr()
980 set indentexpr=
981endfunc
982
983func Test_set_indentexpr()
984 " this was causing usage of freed memory
985 set indentexpr=ResetIndentexpr()
986 new
987 call feedkeys("i\<c-f>", 'x')
988 call assert_equal('', &indentexpr)
989 bwipe!
990endfunc
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200991
992func Test_backupskip()
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100993 " Option 'backupskip' may contain several comma-separated path
994 " specifications if one or more of the environment variables TMPDIR, TMP,
995 " or TEMP is defined. To simplify testing, convert the string value into a
996 " list.
997 let bsklist = split(&bsk, ',')
998
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200999 if has("mac")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +01001000 let found = (index(bsklist, '/private/tmp/*') >= 0)
1001 call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02001002 elseif has("unix")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +01001003 let found = (index(bsklist, '/tmp/*') >= 0)
1004 call assert_true(found, '/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02001005 endif
1006
Bram Moolenaar98ad1e12019-01-30 21:51:27 +01001007 " If our test platform is Windows, the path(s) in option bsk will use
1008 " backslash for the path separator and the components could be in short
1009 " (8.3) format. As such, we need to replace the backslashes with forward
1010 " slashes and convert the path components to long format. The expand()
1011 " function will do this but it cannot handle comma-separated paths. This is
1012 " why bsk was converted from a string into a list of strings above.
1013 "
1014 " One final complication is that the wildcard "/*" is at the end of each
1015 " path and so expand() might return a list of matching files. To prevent
1016 " this, we need to remove the wildcard before calling expand() and then
1017 " append it afterwards.
1018 if has('win32')
1019 let item_nbr = 0
1020 while item_nbr < len(bsklist)
1021 let path_spec = bsklist[item_nbr]
1022 let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
1023 let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
1024 let bsklist[item_nbr] = path_spec . '/*'
1025 let item_nbr += 1
1026 endwhile
1027 endif
1028
1029 " Option bsk will also include these environment variables if defined.
1030 " If they're defined, verify they appear in the option value.
1031 for var in ['$TMPDIR', '$TMP', '$TEMP']
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02001032 if exists(var)
1033 let varvalue = substitute(expand(var), '\\', '/', 'g')
Bram Moolenaarcbbd0f62019-01-30 22:36:18 +01001034 let varvalue = substitute(varvalue, '/$', '', '')
1035 let varvalue .= '/*'
1036 let found = (index(bsklist, varvalue) >= 0)
1037 call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02001038 endif
1039 endfor
Bram Moolenaar06e2c812019-06-12 19:05:48 +02001040
Bram Moolenaarb00ef052020-09-12 14:53:53 +02001041 " Duplicates from environment variables should be filtered out (option has
1042 " P_NODUP). Run this in a separate instance and write v:errors in a file,
1043 " so that we see what happens on startup.
1044 let after =<< trim [CODE]
1045 let bsklist = split(&backupskip, ',')
1046 call assert_equal(uniq(copy(bsklist)), bsklist)
1047 call writefile(['errors:'] + v:errors, 'Xtestout')
1048 qall
1049 [CODE]
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001050 call writefile(after, 'Xafter', 'D')
Bram Moolenaarb00ef052020-09-12 14:53:53 +02001051 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
1052
1053 let saveenv = {}
1054 for var in ['TMPDIR', 'TMP', 'TEMP']
1055 let saveenv[var] = getenv(var)
1056 call setenv(var, '/duplicate/path')
1057 endfor
1058
1059 exe 'silent !' . cmd
1060 call assert_equal(['errors:'], readfile('Xtestout'))
1061
1062 " restore environment variables
1063 for var in ['TMPDIR', 'TMP', 'TEMP']
1064 call setenv(var, saveenv[var])
1065 endfor
1066
1067 call delete('Xtestout')
Bram Moolenaarb00ef052020-09-12 14:53:53 +02001068
Bram Moolenaar06e2c812019-06-12 19:05:48 +02001069 " Duplicates should be filtered out (option has P_NODUP)
1070 let backupskip = &backupskip
1071 set backupskip=
1072 set backupskip+=/test/dir
1073 set backupskip+=/other/dir
1074 set backupskip+=/test/dir
1075 call assert_equal('/test/dir,/other/dir', &backupskip)
1076 let &backupskip = backupskip
Bram Moolenaarb8e22a02018-04-12 21:37:34 +02001077endfunc
Bram Moolenaar25782a72018-05-13 18:05:33 +02001078
Bram Moolenaarb1fd26d2022-10-03 11:23:02 +01001079func Test_buf_copy_winopt()
Bram Moolenaar7cb33a12018-08-23 22:20:35 +02001080 set hidden
Bram Moolenaar25782a72018-05-13 18:05:33 +02001081
Bram Moolenaar7cb33a12018-08-23 22:20:35 +02001082 " Test copy option from current buffer in window
1083 split
1084 enew
1085 setlocal numberwidth=5
1086 wincmd w
1087 call assert_equal(4,&numberwidth)
1088 bnext
1089 call assert_equal(5,&numberwidth)
1090 bw!
1091 call assert_equal(4,&numberwidth)
Bram Moolenaar25782a72018-05-13 18:05:33 +02001092
Bram Moolenaar7cb33a12018-08-23 22:20:35 +02001093 " Test copy value from window that used to be display the buffer
1094 split
1095 enew
1096 setlocal numberwidth=6
1097 bnext
1098 wincmd w
1099 call assert_equal(4,&numberwidth)
1100 bnext
1101 call assert_equal(6,&numberwidth)
1102 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +02001103
Bram Moolenaar7cb33a12018-08-23 22:20:35 +02001104 " Test that if buffer is current, don't use the stale cached value
1105 " from the last time the buffer was displayed.
1106 split
1107 enew
1108 setlocal numberwidth=7
1109 bnext
1110 bnext
1111 setlocal numberwidth=8
1112 wincmd w
1113 call assert_equal(4,&numberwidth)
1114 bnext
1115 call assert_equal(8,&numberwidth)
1116 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +02001117
Bram Moolenaar7cb33a12018-08-23 22:20:35 +02001118 " Test value is not copied if window already has seen the buffer
1119 enew
1120 split
1121 setlocal numberwidth=9
1122 bnext
1123 setlocal numberwidth=10
1124 wincmd w
1125 call assert_equal(4,&numberwidth)
1126 bnext
1127 call assert_equal(4,&numberwidth)
1128 bw!
1129
1130 set hidden&
Bram Moolenaar25782a72018-05-13 18:05:33 +02001131endfunc
Bram Moolenaarfc089602018-06-24 16:53:35 +02001132
Bram Moolenaarb1fd26d2022-10-03 11:23:02 +01001133def Test_split_copy_options()
1134 var values = [
1135 ['cursorbind', true, false],
1136 ['fillchars', '"vert:-"', '"' .. &fillchars .. '"'],
1137 ['list', true, 0],
1138 ['listchars', '"space:-"', '"' .. &listchars .. '"'],
1139 ['number', true, 0],
1140 ['relativenumber', true, false],
1141 ['scrollbind', true, false],
1142 ['smoothscroll', true, false],
1143 ['virtualedit', '"block"', '"' .. &virtualedit .. '"'],
1144 ['wincolor', '"Search"', '"' .. &wincolor .. '"'],
1145 ['wrap', false, true],
1146 ]
1147 if has('linebreak')
1148 values += [
1149 ['breakindent', true, false],
1150 ['breakindentopt', '"min:5"', '"' .. &breakindentopt .. '"'],
1151 ['linebreak', true, false],
1152 ['numberwidth', 7, 4],
1153 ['showbreak', '"++"', '"' .. &showbreak .. '"'],
1154 ]
1155 endif
1156 if has('rightleft')
1157 values += [
1158 ['rightleft', true, false],
1159 ['rightleftcmd', '"search"', '"' .. &rightleftcmd .. '"'],
1160 ]
1161 endif
1162 if has('statusline')
1163 values += [
1164 ['statusline', '"---%f---"', '"' .. &statusline .. '"'],
1165 ]
1166 endif
1167 if has('spell')
1168 values += [
1169 ['spell', true, false],
1170 ]
1171 endif
1172 if has('syntax')
1173 values += [
1174 ['cursorcolumn', true, false],
1175 ['cursorline', true, false],
1176 ['cursorlineopt', '"screenline"', '"' .. &cursorlineopt .. '"'],
1177 ['colorcolumn', '"+1"', '"' .. &colorcolumn .. '"'],
1178 ]
1179 endif
1180 if has('diff')
1181 values += [
1182 ['diff', true, false],
1183 ]
1184 endif
1185 if has('conceal')
1186 values += [
1187 ['concealcursor', '"nv"', '"' .. &concealcursor .. '"'],
1188 ['conceallevel', '3', &conceallevel],
1189 ]
1190 endif
1191 if has('terminal')
1192 values += [
1193 ['termwinkey', '"<C-X>"', '"' .. &termwinkey .. '"'],
1194 ['termwinsize', '"10x20"', '"' .. &termwinsize .. '"'],
1195 ]
1196 endif
1197 if has('folding')
1198 values += [
1199 ['foldcolumn', 5, &foldcolumn],
1200 ['foldenable', false, true],
1201 ['foldexpr', '"2 + 3"', '"' .. &foldexpr .. '"'],
1202 ['foldignore', '"+="', '"' .. &foldignore .. '"'],
1203 ['foldlevel', 4, &foldlevel],
1204 ['foldmarker', '">>,<<"', '"' .. &foldmarker .. '"'],
1205 ['foldmethod', '"marker"', '"' .. &foldmethod .. '"'],
1206 ['foldminlines', 3, &foldminlines],
1207 ['foldnestmax', 17, &foldnestmax],
1208 ['foldtext', '"closed"', '"' .. &foldtext .. '"'],
1209 ]
1210 endif
1211 if has('signs')
1212 values += [
1213 ['signcolumn', '"number"', '"' .. &signcolumn .. '"'],
1214 ]
1215 endif
1216
1217 # set options to non-default value
1218 for item in values
1219 exe $'&l:{item[0]} = {item[1]}'
1220 endfor
1221
1222 # check values are set in new window
1223 split
1224 for item in values
1225 exe $'assert_equal({item[1]}, &{item[0]}, "{item[0]}")'
1226 endfor
1227
1228 # restore
1229 close
1230 for item in values
1231 exe $'&l:{item[0]} = {item[2]}'
1232 endfor
1233enddef
1234
Bram Moolenaarfc089602018-06-24 16:53:35 +02001235func Test_shortmess_F()
1236 new
1237 call assert_match('\[No Name\]', execute('file'))
1238 set shortmess+=F
1239 call assert_match('\[No Name\]', execute('file'))
1240 call assert_match('^\s*$', execute('file foo'))
1241 call assert_match('foo', execute('file'))
1242 set shortmess-=F
1243 call assert_match('bar', execute('file bar'))
1244 call assert_match('bar', execute('file'))
1245 set shortmess&
1246 bwipe
1247endfunc
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001248
1249func Test_shortmess_F2()
1250 e file1
1251 e file2
1252 call assert_match('file1', execute('bn', ''))
1253 call assert_match('file2', execute('bn', ''))
1254 set shortmess+=F
1255 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +02001256 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001257 call assert_true(empty(execute('bn', '')))
Bram Moolenaarce90e362019-09-08 18:58:44 +02001258 call assert_false('need_fileinfo'->test_getvalue())
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001259 set hidden
1260 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +02001261 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001262 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +02001263 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001264 set nohidden
1265 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +02001266 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001267 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +02001268 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001269 set shortmess&
1270 call assert_match('file1', execute('bn', ''))
1271 call assert_match('file2', execute('bn', ''))
1272 bwipe
1273 bwipe
Yegappan Lakshmanane24b5e02022-09-22 13:44:00 +01001274 call assert_fails('call test_getvalue("abc")', 'E475:')
Bram Moolenaar2f0f8712018-08-21 18:50:18 +02001275endfunc
Bram Moolenaar375e3392019-01-31 18:26:10 +01001276
1277func Test_local_scrolloff()
1278 set so=5
1279 set siso=7
1280 split
1281 call assert_equal(5, &so)
1282 setlocal so=3
1283 call assert_equal(3, &so)
1284 wincmd w
1285 call assert_equal(5, &so)
1286 wincmd w
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001287 call assert_equal(3, &so)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001288 setlocal so<
1289 call assert_equal(5, &so)
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001290 setglob so=8
1291 call assert_equal(8, &so)
1292 call assert_equal(-1, &l:so)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001293 setlocal so=0
1294 call assert_equal(0, &so)
1295 setlocal so=-1
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001296 call assert_equal(8, &so)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001297
1298 call assert_equal(7, &siso)
1299 setlocal siso=3
1300 call assert_equal(3, &siso)
1301 wincmd w
1302 call assert_equal(7, &siso)
1303 wincmd w
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001304 call assert_equal(3, &siso)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001305 setlocal siso<
1306 call assert_equal(7, &siso)
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001307 setglob siso=4
1308 call assert_equal(4, &siso)
1309 call assert_equal(-1, &l:siso)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001310 setlocal siso=0
1311 call assert_equal(0, &siso)
1312 setlocal siso=-1
Bram Moolenaarbf5f1892023-06-27 21:51:07 +01001313 call assert_equal(4, &siso)
Bram Moolenaar375e3392019-01-31 18:26:10 +01001314
1315 close
1316 set so&
1317 set siso&
1318endfunc
Bram Moolenaar449ac472019-04-03 21:42:35 +02001319
1320func Test_writedelay()
Bram Moolenaar5feabe02020-01-30 18:24:53 +01001321 CheckFunction reltimefloat
1322
Bram Moolenaar449ac472019-04-03 21:42:35 +02001323 new
1324 call setline(1, 'empty')
1325 redraw
1326 set writedelay=10
1327 let start = reltime()
1328 call setline(1, repeat('x', 70))
1329 redraw
1330 let elapsed = reltimefloat(reltime(start))
1331 set writedelay=0
1332 " With 'writedelay' set should take at least 30 * 10 msec
1333 call assert_inrange(30 * 0.01, 999.0, elapsed)
1334
1335 bwipe!
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +02001336endfunc
1337
1338func Test_visualbell()
Bram Moolenaar7a666272019-04-03 22:52:34 +02001339 set belloff=
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +02001340 set visualbell
1341 call assert_beeps('normal 0h')
1342 set novisualbell
Bram Moolenaar7a666272019-04-03 22:52:34 +02001343 set belloff=all
Bram Moolenaar449ac472019-04-03 21:42:35 +02001344endfunc
Bram Moolenaar5d98dc22020-01-29 21:57:34 +01001345
1346" Test for the 'write' option
1347func Test_write()
1348 new
1349 call setline(1, ['L1'])
1350 set nowrite
Bram Moolenaarb18b4962022-09-02 21:55:50 +01001351 call assert_fails('write Xwrfile', 'E142:')
Bram Moolenaar5d98dc22020-01-29 21:57:34 +01001352 set write
1353 close!
1354endfunc
1355
1356" Test for 'buftype' option
1357func Test_buftype()
1358 new
1359 call setline(1, ['L1'])
1360 set buftype=nowrite
1361 call assert_fails('write', 'E382:')
Bram Moolenaara3a9c8e2020-03-19 12:38:34 +01001362
1363 for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
1364 exe 'set buftype=' .. val
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001365 call writefile(['something'], 'XBuftype', 'D')
Bram Moolenaara3a9c8e2020-03-19 12:38:34 +01001366 call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
1367 endfor
1368
Bram Moolenaara3a9c8e2020-03-19 12:38:34 +01001369 bwipe!
Bram Moolenaar5d98dc22020-01-29 21:57:34 +01001370endfunc
1371
Bram Moolenaar578fe942020-02-27 21:32:51 +01001372" Test for the 'rightleftcmd' option
1373func Test_rightleftcmd()
1374 CheckFeature rightleft
1375 set rightleft
Bram Moolenaar578fe942020-02-27 21:32:51 +01001376
1377 let g:l = []
1378 func AddPos()
1379 call add(g:l, screencol())
1380 return ''
1381 endfunc
1382 cmap <expr> <F2> AddPos()
1383
zeertzjqbb404f52022-07-23 06:25:29 +01001384 set rightleftcmd=
1385 call feedkeys("/\<F2>abc\<Right>\<F2>\<Left>\<Left>\<F2>" ..
1386 \ "\<Right>\<F2>\<Esc>", 'xt')
1387 call assert_equal([2, 5, 3, 4], g:l)
1388
1389 let g:l = []
1390 set rightleftcmd=search
Bram Moolenaar578fe942020-02-27 21:32:51 +01001391 call feedkeys("/\<F2>abc\<Left>\<F2>\<Right>\<Right>\<F2>" ..
1392 \ "\<Left>\<F2>\<Esc>", 'xt')
1393 call assert_equal([&co - 1, &co - 4, &co - 2, &co - 3], g:l)
1394
1395 cunmap <F2>
1396 unlet g:l
1397 set rightleftcmd&
1398 set rightleft&
1399endfunc
1400
zeertzjq28c162f2022-08-14 14:49:50 +01001401" Test for the 'debug' option
Bram Moolenaarcde0ff32020-04-04 14:00:39 +02001402func Test_debug_option()
zeertzjq28c162f2022-08-14 14:49:50 +01001403 " redraw to avoid matching previous messages
1404 redraw
Bram Moolenaarcde0ff32020-04-04 14:00:39 +02001405 set debug=beep
1406 exe "normal \<C-c>"
1407 call assert_equal('Beep!', Screenline(&lines))
zeertzjq28c162f2022-08-14 14:49:50 +01001408 call assert_equal('line 4:', Screenline(&lines - 1))
zeertzjq30585e02023-03-06 08:10:04 +00001409 " also check a line above, with a certain window width the colon is there
1410 call assert_match('Test_debug_option:$',
1411 \ Screenline(&lines - 3) .. Screenline(&lines - 2))
Bram Moolenaarcde0ff32020-04-04 14:00:39 +02001412 set debug&
1413endfunc
1414
Bram Moolenaar004a6782020-04-11 17:09:31 +02001415" Test for the default CDPATH option
1416func Test_opt_default_cdpath()
Bram Moolenaar004a6782020-04-11 17:09:31 +02001417 let after =<< trim [CODE]
1418 call assert_equal(',/path/to/dir1,/path/to/dir2', &cdpath)
1419 call writefile(v:errors, 'Xtestout')
1420 qall
1421 [CODE]
1422 if has('unix')
1423 let $CDPATH='/path/to/dir1:/path/to/dir2'
1424 else
1425 let $CDPATH='/path/to/dir1;/path/to/dir2'
1426 endif
1427 if RunVim([], after, '')
1428 call assert_equal([], readfile('Xtestout'))
1429 call delete('Xtestout')
1430 endif
1431endfunc
1432
1433" Test for setting keycodes using set
1434func Test_opt_set_keycode()
1435 call assert_fails('set <t_k1=l', 'E474:')
1436 call assert_fails('set <Home=l', 'E474:')
1437 set <t_k9>=abcd
1438 call assert_equal('abcd', &t_k9)
1439 set <t_k9>&
1440 set <F9>=xyz
1441 call assert_equal('xyz', &t_k9)
1442 set <t_k9>&
Bram Moolenaar84f54632022-06-29 18:39:11 +01001443
1444 " should we test all of them?
1445 set t_Ce=testCe
1446 set t_Cs=testCs
1447 set t_Us=testUs
1448 set t_ds=testds
1449 set t_Ds=testDs
1450 call assert_equal('testCe', &t_Ce)
1451 call assert_equal('testCs', &t_Cs)
1452 call assert_equal('testUs', &t_Us)
1453 call assert_equal('testds', &t_ds)
1454 call assert_equal('testDs', &t_Ds)
Bram Moolenaar004a6782020-04-11 17:09:31 +02001455endfunc
1456
1457" Test for changing options in a sandbox
1458func Test_opt_sandbox()
1459 for opt in ['backupdir', 'cdpath', 'exrc']
1460 call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
Bram Moolenaar1363a302020-04-12 13:50:26 +02001461 call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:')
Bram Moolenaar004a6782020-04-11 17:09:31 +02001462 endfor
Bram Moolenaar1363a302020-04-12 13:50:26 +02001463 call assert_fails('sandbox let &modelineexpr = 1', 'E48:')
Bram Moolenaar004a6782020-04-11 17:09:31 +02001464endfunc
1465
1466" Test for setting an option with local value to global value
1467func Test_opt_local_to_global()
1468 setglobal equalprg=gprg
1469 setlocal equalprg=lprg
1470 call assert_equal('gprg', &g:equalprg)
1471 call assert_equal('lprg', &l:equalprg)
1472 call assert_equal('lprg', &equalprg)
1473 set equalprg<
1474 call assert_equal('', &l:equalprg)
1475 call assert_equal('gprg', &equalprg)
1476 setglobal equalprg=gnewprg
1477 setlocal equalprg=lnewprg
1478 setlocal equalprg<
1479 call assert_equal('gnewprg', &l:equalprg)
1480 call assert_equal('gnewprg', &equalprg)
1481 set equalprg&
Yegappan Lakshmanan59585492021-06-12 13:46:41 +02001482
1483 " Test for setting the global/local value of a boolean option
1484 setglobal autoread
1485 setlocal noautoread
1486 call assert_false(&autoread)
1487 set autoread<
1488 call assert_true(&autoread)
1489 setglobal noautoread
1490 setlocal autoread
1491 setlocal autoread<
1492 call assert_false(&autoread)
1493 set autoread&
Bram Moolenaar004a6782020-04-11 17:09:31 +02001494endfunc
1495
Dominique Pelle042414f2021-07-12 21:43:19 +02001496func Test_set_in_sandbox()
1497 " Some boolean options cannot be set in sandbox, some can.
1498 call assert_fails('sandbox set modelineexpr', 'E48:')
1499 sandbox set number
1500 call assert_true(&number)
1501 set number&
1502
1503 " Some boolean options cannot be set in sandbox, some can.
1504 if has('python') || has('python3')
1505 call assert_fails('sandbox set pyxversion=3', 'E48:')
1506 endif
1507 sandbox set tabstop=4
1508 call assert_equal(4, &tabstop)
1509 set tabstop&
1510
1511 " Some string options cannot be set in sandbox, some can.
1512 call assert_fails('sandbox set backupdir=/tmp', 'E48:')
1513 sandbox set filetype=perl
1514 call assert_equal('perl', &filetype)
1515 set filetype&
1516endfunc
1517
Bram Moolenaar004a6782020-04-11 17:09:31 +02001518" Test for incrementing, decrementing and multiplying a number option value
1519func Test_opt_num_op()
1520 set shiftwidth=4
1521 set sw+=2
1522 call assert_equal(6, &sw)
1523 set sw-=2
1524 call assert_equal(4, &sw)
1525 set sw^=2
1526 call assert_equal(8, &sw)
1527 set shiftwidth&
1528endfunc
1529
Bram Moolenaar65d032c2020-04-24 20:57:01 +02001530" Test for setting option values using v:false and v:true
1531func Test_opt_boolean()
1532 set number&
1533 set number
1534 call assert_equal(1, &nu)
1535 set nonu
1536 call assert_equal(0, &nu)
1537 let &nu = v:true
1538 call assert_equal(1, &nu)
1539 let &nu = v:false
1540 call assert_equal(0, &nu)
1541 set number&
1542endfunc
1543
Bram Moolenaarbdd2c292020-06-22 21:34:30 +02001544" Test for the 'window' option
1545func Test_window_opt()
1546 " Needs only one open widow
1547 %bw!
1548 call setline(1, range(1, 8))
1549 set window=5
1550 exe "normal \<C-F>"
1551 call assert_equal(4, line('w0'))
1552 exe "normal \<C-F>"
1553 call assert_equal(7, line('w0'))
1554 exe "normal \<C-F>"
1555 call assert_equal(8, line('w0'))
1556 exe "normal \<C-B>"
1557 call assert_equal(5, line('w0'))
1558 exe "normal \<C-B>"
1559 call assert_equal(2, line('w0'))
1560 exe "normal \<C-B>"
1561 call assert_equal(1, line('w0'))
1562 set window=1
1563 exe "normal gg\<C-F>"
1564 call assert_equal(2, line('w0'))
1565 exe "normal \<C-F>"
1566 call assert_equal(3, line('w0'))
1567 exe "normal \<C-B>"
1568 call assert_equal(2, line('w0'))
1569 exe "normal \<C-B>"
1570 call assert_equal(1, line('w0'))
1571 enew!
1572 set window&
1573endfunc
1574
Bram Moolenaar5d3c9f82020-06-26 20:41:39 +02001575" Test for the 'winminheight' option
1576func Test_opt_winminheight()
1577 only!
1578 let &winheight = &lines + 4
1579 call assert_fails('let &winminheight = &lines + 2', 'E36:')
1580 call assert_true(&winminheight <= &lines)
1581 set winminheight&
1582 set winheight&
1583endfunc
1584
Bram Moolenaar39d4cab2021-03-01 21:02:46 +01001585func Test_opt_winminheight_term()
1586 CheckRunVimInTerminal
1587
1588 " The tabline should be taken into account.
1589 let lines =<< trim END
1590 set wmh=0 stal=2
1591 below sp | wincmd _
1592 below sp | wincmd _
1593 below sp | wincmd _
1594 below sp
1595 END
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001596 call writefile(lines, 'Xwinminheight', 'D')
Bram Moolenaar39d4cab2021-03-01 21:02:46 +01001597 let buf = RunVimInTerminal('-S Xwinminheight', #{rows: 11})
1598 call term_sendkeys(buf, ":set wmh=1\n")
1599 call WaitForAssert({-> assert_match('E36: Not enough room', term_getline(buf, 11))})
1600
1601 call StopVimInTerminal(buf)
Bram Moolenaar39d4cab2021-03-01 21:02:46 +01001602endfunc
1603
Bram Moolenaar9e813b32021-03-13 14:29:05 +01001604func Test_opt_winminheight_term_tabs()
1605 CheckRunVimInTerminal
1606
1607 " The tabline should be taken into account.
1608 let lines =<< trim END
1609 set wmh=0 stal=2
1610 split
1611 split
1612 split
1613 split
1614 tabnew
1615 END
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001616 call writefile(lines, 'Xwinminheight', 'D')
Bram Moolenaar9e813b32021-03-13 14:29:05 +01001617 let buf = RunVimInTerminal('-S Xwinminheight', #{rows: 11})
1618 call term_sendkeys(buf, ":set wmh=1\n")
1619 call WaitForAssert({-> assert_match('E36: Not enough room', term_getline(buf, 11))})
1620
1621 call StopVimInTerminal(buf)
Bram Moolenaar9e813b32021-03-13 14:29:05 +01001622endfunc
1623
Bram Moolenaar5d3c9f82020-06-26 20:41:39 +02001624" Test for the 'winminwidth' option
1625func Test_opt_winminwidth()
1626 only!
1627 let &winwidth = &columns + 4
1628 call assert_fails('let &winminwidth = &columns + 2', 'E36:')
1629 call assert_true(&winminwidth <= &columns)
1630 set winminwidth&
1631 set winwidth&
1632endfunc
1633
Bram Moolenaar994b89d2020-08-07 19:12:41 +02001634" Test for setting option value containing spaces with isfname+=32
1635func Test_isfname_with_options()
1636 set isfname+=32
1637 setlocal keywordprg=:term\ help.exe
1638 call assert_equal(':term help.exe', &keywordprg)
1639 set isfname&
1640 setlocal keywordprg&
1641endfunc
1642
Bram Moolenaar74667062020-12-28 15:41:41 +01001643" Test that resetting laststatus does change scroll option
1644func Test_opt_reset_scroll()
1645 CheckRunVimInTerminal
1646 let vimrc =<< trim [CODE]
1647 set scroll=2
1648 set laststatus=2
1649 [CODE]
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001650 call writefile(vimrc, 'Xscroll', 'D')
Bram Moolenaar74667062020-12-28 15:41:41 +01001651 let buf = RunVimInTerminal('-S Xscroll', {'rows': 16, 'cols': 45})
1652 call term_sendkeys(buf, ":verbose set scroll?\n")
1653 call WaitForAssert({-> assert_match('Last set.*window size', term_getline(buf, 15))})
1654 call assert_match('^\s*scroll=7$', term_getline(buf, 14))
Bram Moolenaar74667062020-12-28 15:41:41 +01001655
1656 " clean up
Bram Moolenaar145d1fd2022-09-30 21:57:11 +01001657 call StopVimInTerminal(buf)
Bram Moolenaar74667062020-12-28 15:41:41 +01001658endfunc
1659
Dominique Pelle6d37e8e2021-05-06 17:36:55 +02001660" Check that VIM_POSIX env variable influences default value of 'cpo' and 'shm'
1661func Test_VIM_POSIX()
1662 let saved_VIM_POSIX = getenv("VIM_POSIX")
1663
1664 call setenv('VIM_POSIX', "1")
1665 let after =<< trim [CODE]
1666 call writefile([&cpo, &shm], 'X_VIM_POSIX')
1667 qall
1668 [CODE]
1669 if RunVim([], after, '')
1670 call assert_equal(['aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>#{|&/\.;',
1671 \ 'AS'], readfile('X_VIM_POSIX'))
1672 endif
1673
1674 call setenv('VIM_POSIX', v:null)
1675 let after =<< trim [CODE]
1676 call writefile([&cpo, &shm], 'X_VIM_POSIX')
1677 qall
1678 [CODE]
1679 if RunVim([], after, '')
1680 call assert_equal(['aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>;',
1681 \ 'S'], readfile('X_VIM_POSIX'))
1682 endif
1683
1684 call delete('X_VIM_POSIX')
1685 call setenv('VIM_POSIX', saved_VIM_POSIX)
1686endfunc
1687
Yegappan Lakshmanan59585492021-06-12 13:46:41 +02001688" Test for setting an option to a Vi or Vim default
1689func Test_opt_default()
1690 set formatoptions&vi
1691 call assert_equal('vt', &formatoptions)
1692 set formatoptions&vim
1693 call assert_equal('tcq', &formatoptions)
Bram Moolenaar5ffefbb2021-06-13 20:27:36 +02001694
1695 call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
1696 set fencs=latin1
1697 set fencs&
1698 call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
1699 set fencs=latin1
1700 set all&
1701 call assert_equal('ucs-bom,utf-8,default,latin1', &fencs)
Yegappan Lakshmanan59585492021-06-12 13:46:41 +02001702endfunc
1703
1704" Test for the 'cmdheight' option
1705func Test_cmdheight()
1706 %bw!
1707 let ht = &lines
1708 set cmdheight=9999
1709 call assert_equal(1, winheight(0))
1710 call assert_equal(ht - 1, &cmdheight)
1711 set cmdheight&
1712endfunc
1713
Dominique Pelle923dce22021-11-21 11:36:04 +00001714" To specify a control character as an option value, '^' can be used
Yegappan Lakshmanan2d6d7182021-06-13 21:52:48 +02001715func Test_opt_control_char()
1716 set wildchar=^v
1717 call assert_equal("\<C-V>", nr2char(&wildchar))
1718 set wildcharm=^r
1719 call assert_equal("\<C-R>", nr2char(&wildcharm))
1720 " Bug: This doesn't work for the 'cedit' and 'termwinkey' options
1721 set wildchar& wildcharm&
1722endfunc
1723
1724" Test for the 'errorbells' option
1725func Test_opt_errorbells()
1726 set errorbells
1727 call assert_beeps('s/a1b2/x1y2/')
1728 set noerrorbells
1729endfunc
1730
Dominique Pelle042414f2021-07-12 21:43:19 +02001731func Test_opt_scrolljump()
1732 help
1733 resize 10
1734
1735 " Test with positive 'scrolljump'.
1736 set scrolljump=2
1737 norm! Lj
1738 call assert_equal({'lnum':11, 'leftcol':0, 'col':0, 'topfill':0,
1739 \ 'topline':3, 'coladd':0, 'skipcol':0, 'curswant':0},
1740 \ winsaveview())
1741
1742 " Test with negative 'scrolljump' (percentage of window height).
1743 set scrolljump=-40
1744 norm! ggLj
1745 call assert_equal({'lnum':11, 'leftcol':0, 'col':0, 'topfill':0,
1746 \ 'topline':5, 'coladd':0, 'skipcol':0, 'curswant':0},
1747 \ winsaveview())
1748
1749 set scrolljump&
1750 bw
1751endfunc
1752
Bakudankun29f3a452021-12-11 12:28:08 +00001753" Test for the 'cdhome' option
1754func Test_opt_cdhome()
1755 if has('unix') || has('vms')
1756 throw 'Skipped: only works on non-Unix'
1757 endif
1758
1759 set cdhome&
1760 call assert_equal(0, &cdhome)
1761 set cdhome
1762
1763 " This paragraph is copied from Test_cd_no_arg().
1764 let path = getcwd()
1765 cd
1766 call assert_equal($HOME, getcwd())
1767 call assert_notequal(path, getcwd())
1768 exe 'cd ' .. fnameescape(path)
1769 call assert_equal(path, getcwd())
1770
1771 set cdhome&
1772endfunc
1773
Yee Cheng Chin900894b2023-09-29 20:42:32 +02001774func Test_set_completion_fuzzy()
Christian Brabandtcb747892022-05-08 21:10:56 +01001775 CheckOption termguicolors
1776
1777 " Test default option completion
1778 set wildoptions=
1779 call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
1780 call assert_equal('"set termguicolors', @:)
1781
1782 call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
1783 call assert_equal('"set notermguicolors', @:)
1784
1785 " Test fuzzy option completion
1786 set wildoptions=fuzzy
1787 call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
1788 call assert_equal('"set termguicolors termencoding', @:)
1789
1790 call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
1791 call assert_equal('"set notermguicolors', @:)
1792
1793 set wildoptions=
1794endfunc
1795
Sean Dewar39c46b42022-05-12 17:44:29 +01001796func Test_switchbuf_reset()
1797 set switchbuf=useopen
1798 sblast
1799 call assert_equal(1, winnr('$'))
1800 set all&
1801 call assert_equal('', &switchbuf)
1802 sblast
1803 call assert_equal(2, winnr('$'))
1804 only!
1805endfunc
1806
zeertzjqfcba86c2022-09-22 13:57:32 +01001807" :set empty string for global 'keywordprg' falls back to ":help"
1808func Test_keywordprg_empty()
1809 let k = &keywordprg
1810 set keywordprg=man
1811 call assert_equal('man', &keywordprg)
1812 set keywordprg=
1813 call assert_equal(':help', &keywordprg)
1814 set keywordprg=man
1815 call assert_equal('man', &keywordprg)
1816 call assert_equal("\n keywordprg=:help", execute('set kp= kp?'))
1817 let &keywordprg = k
1818endfunc
1819
Bram Moolenaar0aad88f2022-11-12 11:54:26 +00001820" check that the very first buffer created does not have 'endoffile' set
1821func Test_endoffile_default()
1822 let after =<< trim [CODE]
1823 call writefile([execute('set eof?')], 'Xtestout')
1824 qall!
1825 [CODE]
1826 if RunVim([], after, '')
1827 call assert_equal(["\nnoendoffile"], readfile('Xtestout'))
1828 endif
1829 call delete('Xtestout')
1830endfunc
1831
Yegappan Lakshmanan32ff96e2023-02-13 16:10:04 +00001832" Test for setting the 'lines' and 'columns' options to a minimum value
1833func Test_set_min_lines_columns()
1834 let save_lines = &lines
1835 let save_columns = &columns
1836
1837 let after =<< trim END
1838 set nomore
1839 let msg = []
1840 let v:errmsg = ''
1841 silent! let &columns=0
1842 call add(msg, v:errmsg)
1843 silent! set columns=0
1844 call add(msg, v:errmsg)
1845 silent! call setbufvar('', '&columns', 0)
1846 call add(msg, v:errmsg)
1847 "call writefile(msg, 'XResultsetminlines')
1848 silent! let &lines=0
1849 call add(msg, v:errmsg)
1850 silent! set lines=0
1851 call add(msg, v:errmsg)
1852 silent! call setbufvar('', '&lines', 0)
1853 call add(msg, v:errmsg)
1854 call writefile(msg, 'XResultsetminlines')
1855 qall!
1856 END
1857 if RunVim([], after, '')
1858 call assert_equal(['E594: Need at least 12 columns',
1859 \ 'E594: Need at least 12 columns: columns=0',
1860 \ 'E594: Need at least 12 columns',
1861 \ 'E593: Need at least 2 lines',
1862 \ 'E593: Need at least 2 lines: lines=0',
1863 \ 'E593: Need at least 2 lines',], readfile('XResultsetminlines'))
1864 endif
1865
1866 call delete('XResultsetminlines')
1867 let &lines = save_lines
1868 let &columns = save_columns
1869endfunc
zeertzjqfcba86c2022-09-22 13:57:32 +01001870
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +00001871" Test for reverting a string option value if the new value is invalid.
1872func Test_string_option_revert_on_failure()
1873 new
1874 let optlist = [
1875 \ ['ambiwidth', 'double', 'a123'],
1876 \ ['background', 'dark', 'a123'],
1877 \ ['backspace', 'eol', 'a123'],
1878 \ ['backupcopy', 'no', 'a123'],
1879 \ ['belloff', 'showmatch', 'a123'],
1880 \ ['breakindentopt', 'min:10', 'list'],
1881 \ ['bufhidden', 'wipe', 'a123'],
1882 \ ['buftype', 'nowrite', 'a123'],
1883 \ ['casemap', 'keepascii', 'a123'],
1884 \ ['cedit', "\<C-Y>", 'z'],
1885 \ ['colorcolumn', '10', 'z'],
1886 \ ['commentstring', '#%s', 'a123'],
1887 \ ['complete', '.,t', 'a'],
1888 \ ['completefunc', 'MyCmplFunc', '1a-'],
1889 \ ['completeopt', 'popup', 'a123'],
1890 \ ['completepopup', 'width:20', 'border'],
1891 \ ['concealcursor', 'v', 'xyz'],
1892 \ ['cpoptions', 'HJ', '~'],
1893 \ ['cryptmethod', 'zip', 'a123'],
1894 \ ['cursorlineopt', 'screenline', 'a123'],
1895 \ ['debug', 'throw', 'a123'],
1896 \ ['diffopt', 'iwhite', 'a123'],
1897 \ ['display', 'uhex', 'a123'],
1898 \ ['eadirection', 'hor', 'a123'],
1899 \ ['encoding', 'utf-8', 'a123'],
1900 \ ['eventignore', 'TextYankPost', 'a123'],
1901 \ ['fileencoding', 'utf-8', 'a123,'],
1902 \ ['fileformat', 'mac', 'a123'],
1903 \ ['fileformats', 'mac', 'a123'],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001904 \ ['filetype', 'abc', 'a^b'],
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +00001905 \ ['fillchars', 'diff:~', 'a123'],
1906 \ ['foldclose', 'all', 'a123'],
1907 \ ['foldmarker', '[[[,]]]', '[[['],
1908 \ ['foldmethod', 'marker', 'a123'],
1909 \ ['foldopen', 'percent', 'a123'],
1910 \ ['formatoptions', 'an', '*'],
1911 \ ['guicursor', 'n-v-c:block-Cursor/lCursor', 'n-v-c'],
1912 \ ['helplang', 'en', 'a'],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001913 \ ['highlight', '!:CursorColumn', '8:'],
1914 \ ['keymodel', 'stopsel', 'a123'],
1915 \ ['keyprotocol', 'kitty:kitty', 'kitty:'],
1916 \ ['lispoptions', 'expr:1', 'a123'],
1917 \ ['listchars', 'tab:->', 'tab:'],
1918 \ ['matchpairs', '<:>', '<:'],
1919 \ ['mkspellmem', '100000,1000,100', '100000'],
1920 \ ['mouse', 'nvi', 'z'],
1921 \ ['mousemodel', 'extend', 'a123'],
1922 \ ['nrformats', 'alpha', 'a123'],
1923 \ ['omnifunc', 'MyOmniFunc', '1a-'],
1924 \ ['operatorfunc', 'MyOpFunc', '1a-'],
1925 \ ['previewpopup', 'width:20', 'a123'],
1926 \ ['printoptions', 'paper:A4', 'a123:'],
1927 \ ['quickfixtextfunc', 'MyQfFunc', '1a-'],
1928 \ ['rulerformat', '%l', '%['],
1929 \ ['scrollopt', 'hor,jump', 'a123'],
1930 \ ['selection', 'exclusive', 'a123'],
1931 \ ['selectmode', 'cmd', 'a123'],
1932 \ ['sessionoptions', 'options', 'a123'],
1933 \ ['shortmess', 'w', '2'],
1934 \ ['showbreak', '>>', "\x01"],
1935 \ ['showcmdloc', 'statusline', 'a123'],
1936 \ ['signcolumn', 'no', 'a123'],
1937 \ ['spellcapcheck', '[.?!]\+', '%\{'],
1938 \ ['spellfile', 'MySpell.en.add', "\x01"],
1939 \ ['spelllang', 'en', "#"],
1940 \ ['spelloptions', 'camel', 'a123'],
1941 \ ['spellsuggest', 'double', 'a123'],
1942 \ ['splitkeep', 'topline', 'a123'],
1943 \ ['statusline', '%f', '%['],
1944 \ ['swapsync', 'sync', 'a123'],
1945 \ ['switchbuf', 'usetab', 'a123'],
1946 \ ['syntax', 'abc', 'a^b'],
1947 \ ['tabline', '%f', '%['],
1948 \ ['tagcase', 'ignore', 'a123'],
1949 \ ['tagfunc', 'MyTagFunc', '1a-'],
1950 \ ['thesaurusfunc', 'MyThesaurusFunc', '1a-'],
1951 \ ['viewoptions', 'options', 'a123'],
1952 \ ['virtualedit', 'onemore', 'a123'],
1953 \ ['whichwrap', '<,>', '{,}'],
1954 \ ['wildmode', 'list', 'a123'],
1955 \ ['wildoptions', 'pum', 'a123']
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +00001956 \ ]
1957 if has('gui')
1958 call add(optlist, ['browsedir', 'buffer', 'a123'])
1959 endif
1960 if has('clipboard_working')
1961 call add(optlist, ['clipboard', 'unnamed', 'a123'])
1962 endif
1963 if has('win32')
1964 call add(optlist, ['completeslash', 'slash', 'a123'])
1965 endif
1966 if has('cscope')
1967 call add(optlist, ['cscopequickfix', 't-', 'z-'])
1968 endif
1969 if !has('win32')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001970 call add(optlist, ['imactivatefunc', 'MyActFunc', '1a-'])
1971 call add(optlist, ['imstatusfunc', 'MyStatusFunc', '1a-'])
1972 endif
1973 if has('keymap')
1974 call add(optlist, ['keymap', 'greek', '[]'])
1975 endif
1976 if has('mouseshape')
1977 call add(optlist, ['mouseshape', 'm:no', 'a123:'])
1978 endif
1979 if has('win32') && has('gui')
1980 call add(optlist, ['renderoptions', 'type:directx', 'type:directx,a123'])
1981 endif
1982 if has('rightleft')
1983 call add(optlist, ['rightleftcmd', 'search', 'a123'])
1984 endif
1985 if has('terminal')
1986 call add(optlist, ['termwinkey', '<C-L>', '<C'])
1987 call add(optlist, ['termwinsize', '24x80', '100'])
1988 endif
1989 if has('win32') && has('terminal')
1990 call add(optlist, ['termwintype', 'winpty', 'a123'])
1991 endif
Yegappan Lakshmananc6ff21e2023-03-02 14:46:48 +00001992 if exists('+toolbar')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001993 call add(optlist, ['toolbar', 'text', 'a123'])
James McCoydb1887c2023-03-02 18:36:33 +00001994 endif
1995 if exists('+toolbariconsize')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001996 call add(optlist, ['toolbariconsize', 'medium', 'a123'])
1997 endif
Yegappan Lakshmananc6ff21e2023-03-02 14:46:48 +00001998 if exists('+ttymouse') && !has('gui')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00001999 call add(optlist, ['ttymouse', 'xterm', 'a123'])
2000 endif
Yegappan Lakshmananc6ff21e2023-03-02 14:46:48 +00002001 if exists('+vartabs')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00002002 call add(optlist, ['varsofttabstop', '12', 'a123'])
2003 call add(optlist, ['vartabstop', '4,20', '4,'])
2004 endif
Yegappan Lakshmananc6ff21e2023-03-02 14:46:48 +00002005 if exists('+winaltkeys')
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00002006 call add(optlist, ['winaltkeys', 'no', 'a123'])
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +00002007 endif
2008 for opt in optlist
2009 exe $"let save_opt = &{opt[0]}"
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +00002010 try
2011 exe $"let &{opt[0]} = '{opt[1]}'"
2012 catch
2013 call assert_report($"Caught {v:exception} with {opt->string()}")
2014 endtry
Yegappan Lakshmanan8ad862a2023-02-23 15:05:22 +00002015 call assert_fails($"let &{opt[0]} = '{opt[2]}'", '', opt[0])
2016 call assert_equal(opt[1], eval($"&{opt[0]}"), opt[0])
2017 exe $"let &{opt[0]} = save_opt"
2018 endfor
2019 bw!
2020endfunc
2021
Christian Brabandt4a8eb6e2023-08-13 19:43:42 +02002022func Test_set_option_window_global_local()
2023 new Xbuffer1
2024 let [ _gso, _lso ] = [ &g:scrolloff, &l:scrolloff ]
2025 setlocal scrolloff=2
2026 setglobal scrolloff=3
2027 setl modified
2028 " A new buffer has its own window-local options
2029 hide enew
2030 call assert_equal(-1, &l:scrolloff)
2031 call assert_equal(3, &g:scrolloff)
2032 " A new window opened with its own buffer-local options
2033 new
2034 call assert_equal(-1, &l:scrolloff)
2035 call assert_equal(3, &g:scrolloff)
2036 " Re-open Xbuffer1 and it should use
2037 " the previous set window-local options
2038 b Xbuffer1
2039 call assert_equal(2, &l:scrolloff)
2040 call assert_equal(3, &g:scrolloff)
2041 bw!
2042 bw!
2043 let &g:scrolloff = _gso
2044endfunc
2045
2046func GetGlobalLocalWindowOptions()
2047 new
2048 sil! r $VIMRUNTIME/doc/options.txt
2049 " Filter for global or local to window
2050 v/^'.*'.*\n.*global or local to window |global-local/d
2051 " get option value and type
2052 sil %s/^'\([^']*\)'.*'\s\+\(\w\+\)\s\+(default \%(\(".*"\|\d\+\|empty\)\).*/\1 \2 \3/g
2053 sil %s/empty/""/g
2054 " split the result
2055 let result=getline(1,'$')->map({_, val -> split(val, ' ')})
2056 bw!
2057 return result
2058endfunc
2059
2060func Test_set_option_window_global_local_all()
2061 new Xbuffer2
2062
2063 let optionlist = GetGlobalLocalWindowOptions()
2064 for [opt, type, default] in optionlist
2065 let _old = eval('&g:' .. opt)
2066 if type == 'string'
2067 if opt == 'fillchars'
2068 exe 'setl ' .. opt .. '=vert:+'
2069 exe 'setg ' .. opt .. '=vert:+,fold:+'
2070 elseif opt == 'listchars'
2071 exe 'setl ' .. opt .. '=tab:>>'
2072 exe 'setg ' .. opt .. '=tab:++'
2073 elseif opt == 'virtualedit'
2074 exe 'setl ' .. opt .. '=all'
2075 exe 'setg ' .. opt .. '=block'
2076 else
2077 exe 'setl ' .. opt .. '=Local'
2078 exe 'setg ' .. opt .. '=Global'
2079 endif
2080 elseif type == 'number'
2081 exe 'setl ' .. opt .. '=5'
2082 exe 'setg ' .. opt .. '=10'
2083 endif
2084 setl modified
2085 hide enew
2086 if type == 'string'
2087 call assert_equal('', eval('&l:' .. opt))
2088 if opt == 'fillchars'
2089 call assert_equal('vert:+,fold:+', eval('&g:' .. opt), 'option:' .. opt)
2090 elseif opt == 'listchars'
2091 call assert_equal('tab:++', eval('&g:' .. opt), 'option:' .. opt)
2092 elseif opt == 'virtualedit'
2093 call assert_equal('block', eval('&g:' .. opt), 'option:' .. opt)
2094 else
2095 call assert_equal('Global', eval('&g:' .. opt), 'option:' .. opt)
2096 endif
2097 elseif type == 'number'
2098 call assert_equal(-1, eval('&l:' .. opt), 'option:' .. opt)
2099 call assert_equal(10, eval('&g:' .. opt), 'option:' .. opt)
2100 endif
2101 bw!
2102 exe 'let &g:' .. opt .. '=' .. default
2103 endfor
2104 bw!
2105endfunc
2106
Christian Brabandt757593c2023-08-22 21:44:10 +02002107func Test_paste_depending_options()
2108 " setting the paste option, resets all dependent options
2109 " and will be reported correctly using :verbose set <option>?
2110 let lines =<< trim [CODE]
2111 " set paste test
2112 set autoindent
2113 set expandtab
2114 " disabled, because depends on compiled feature set
2115 " set hkmap
2116 " set revins
2117 " set varsofttabstop=8,32,8
2118 set ruler
2119 set showmatch
2120 set smarttab
2121 set softtabstop=4
2122 set textwidth=80
2123 set wrapmargin=10
2124
2125 source Xvimrc_paste2
2126
2127 redir > Xoutput_paste
2128 verbose set expandtab?
2129 verbose setg expandtab?
2130 verbose setl expandtab?
2131 redir END
2132
2133 qall!
2134 [CODE]
2135
2136 call writefile(lines, 'Xvimrc_paste', 'D')
2137 call writefile(['set paste'], 'Xvimrc_paste2', 'D')
2138 if !RunVim([], lines, '--clean')
2139 return
2140 endif
2141
2142 let result = readfile('Xoutput_paste')->filter('!empty(v:val)')
2143 call assert_equal('noexpandtab', result[0])
2144 call assert_match("^\tLast set from .*Xvimrc_paste2 line 1$", result[1])
2145 call assert_equal('noexpandtab', result[2])
2146 call assert_match("^\tLast set from .*Xvimrc_paste2 line 1$", result[3])
2147 call assert_equal('noexpandtab', result[4])
2148 call assert_match("^\tLast set from .*Xvimrc_paste2 line 1$", result[5])
2149
2150 call delete('Xoutput_paste')
2151endfunc
2152
2153func Test_binary_depending_options()
2154 " setting the paste option, resets all dependent options
2155 " and will be reported correctly using :verbose set <option>?
2156 let lines =<< trim [CODE]
2157 " set binary test
2158 set expandtab
2159
2160 source Xvimrc_bin2
2161
2162 redir > Xoutput_bin
2163 verbose set expandtab?
2164 verbose setg expandtab?
2165 verbose setl expandtab?
2166 redir END
2167
2168 qall!
2169 [CODE]
2170
2171 call writefile(lines, 'Xvimrc_bin', 'D')
2172 call writefile(['set binary'], 'Xvimrc_bin2', 'D')
2173 if !RunVim([], lines, '--clean')
2174 return
2175 endif
2176
2177 let result = readfile('Xoutput_bin')->filter('!empty(v:val)')
2178 call assert_equal('noexpandtab', result[0])
2179 call assert_match("^\tLast set from .*Xvimrc_bin2 line 1$", result[1])
2180 call assert_equal('noexpandtab', result[2])
2181 call assert_match("^\tLast set from .*Xvimrc_bin2 line 1$", result[3])
2182 call assert_equal('noexpandtab', result[4])
2183 call assert_match("^\tLast set from .*Xvimrc_bin2 line 1$", result[5])
2184
2185 call delete('Xoutput_bin')
2186endfunc
2187
Gregory Anders3695d0e2023-09-29 20:17:20 +02002188func Test_set_keyprotocol()
2189 CheckNotGui
2190
2191 let term = &term
2192 set term=ansi
2193 call assert_equal('', &t_TI)
2194
2195 " Setting 'keyprotocol' should affect terminal codes without needing to
2196 " reset 'term'
2197 set keyprotocol+=ansi:kitty
2198 call assert_equal("\<Esc>[=1;1u", &t_TI)
2199 let &term = term
2200endfunc
2201
Bram Moolenaar5d98dc22020-01-29 21:57:34 +01002202" vim: shiftwidth=2 sts=2 expandtab