blob: 23e0de4377350ab437df2aa92d0bf9f019b7b044 [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&
Bram Moolenaar1e115362019-01-09 23:01:02 +010049endfunc
Bram Moolenaar187a4f22017-02-23 17:07:14 +010050
Bram Moolenaar1e115362019-01-09 23:01:02 +010051func Test_wildchar()
Bram Moolenaara12e4032017-02-25 21:37:57 +010052 " Empty 'wildchar' used to access invalid memory.
53 call assert_fails('set wildchar=', 'E521:')
54 call assert_fails('set wildchar=abc', 'E521:')
55 set wildchar=<Esc>
56 let a=execute('set wildchar?')
57 call assert_equal("\n wildchar=<Esc>", a)
58 set wildchar=27
59 let a=execute('set wildchar?')
60 call assert_equal("\n wildchar=<Esc>", a)
61 set wildchar&
Bram Moolenaar1e115362019-01-09 23:01:02 +010062endfunc
Bram Moolenaara12e4032017-02-25 21:37:57 +010063
Bram Moolenaar2e61e2d2020-05-22 14:10:36 +020064func Test_wildoptions()
65 set wildoptions=
66 set wildoptions+=tagfile
67 set wildoptions+=tagfile
68 call assert_equal('tagfile', &wildoptions)
69endfunc
70
Bram Moolenaar6b915c02020-01-18 15:53:19 +010071func Test_options_command()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +020072 let caught = 'ok'
73 try
74 options
75 catch
76 let caught = v:throwpoint . "\n" . v:exception
77 endtry
78 call assert_equal('ok', caught)
79
Bram Moolenaare0b59492019-05-21 20:54:45 +020080 " Check if the option-window is opened horizontally.
81 wincmd j
82 call assert_notequal('option-window', bufname(''))
83 wincmd k
84 call assert_equal('option-window', bufname(''))
85 " close option-window
86 close
87
88 " Open the option-window vertically.
89 vert options
90 " Check if the option-window is opened vertically.
91 wincmd l
92 call assert_notequal('option-window', bufname(''))
93 wincmd h
94 call assert_equal('option-window', bufname(''))
95 " close option-window
96 close
97
Bram Moolenaar7a1637f2020-04-13 21:16:21 +020098 " Open the option-window at the top.
99 set splitbelow
100 topleft options
101 call assert_equal(1, winnr())
102 close
103
104 " Open the option-window at the bottom.
105 set nosplitbelow
106 botright options
107 call assert_equal(winnr('$'), winnr())
108 close
109 set splitbelow&
110
Bram Moolenaare0b59492019-05-21 20:54:45 +0200111 " Open the option-window in a new tab.
112 tab options
113 " Check if the option-window is opened in a tab.
114 normal gT
115 call assert_notequal('option-window', bufname(''))
116 normal gt
117 call assert_equal('option-window', bufname(''))
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200118 " close option-window
119 close
Bram Moolenaar004a6782020-04-11 17:09:31 +0200120
121 " Open the options window browse
122 if has('browse')
123 browse set
124 call assert_equal('option-window', bufname(''))
125 close
126 endif
Bram Moolenaar1e115362019-01-09 23:01:02 +0100127endfunc
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200128
Bram Moolenaar1e115362019-01-09 23:01:02 +0100129func Test_path_keep_commas()
Bram Moolenaarc8ce6152016-08-07 13:48:20 +0200130 " Test that changing 'path' keeps two commas.
131 set path=foo,,bar
132 set path-=bar
133 set path+=bar
134 call assert_equal('foo,,bar', &path)
135
136 set path&
Bram Moolenaar1e115362019-01-09 23:01:02 +0100137endfunc
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200138
139func Test_signcolumn()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200140 CheckFeature signs
141 call assert_equal("auto", &signcolumn)
142 set signcolumn=yes
143 set signcolumn=no
144 call assert_fails('set signcolumn=nope')
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200145endfunc
146
Bram Moolenaard0b51382016-11-04 15:23:45 +0100147func Test_filetype_valid()
148 set ft=valid_name
149 call assert_equal("valid_name", &filetype)
150 set ft=valid-name
151 call assert_equal("valid-name", &filetype)
152
153 call assert_fails(":set ft=wrong;name", "E474:")
154 call assert_fails(":set ft=wrong\\\\name", "E474:")
155 call assert_fails(":set ft=wrong\\|name", "E474:")
156 call assert_fails(":set ft=wrong/name", "E474:")
157 call assert_fails(":set ft=wrong\\\nname", "E474:")
158 call assert_equal("valid-name", &filetype)
159
160 exe "set ft=trunc\x00name"
161 call assert_equal("trunc", &filetype)
162endfunc
163
164func Test_syntax_valid()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200165 CheckFeature syntax
Bram Moolenaard0b51382016-11-04 15:23:45 +0100166 set syn=valid_name
167 call assert_equal("valid_name", &syntax)
168 set syn=valid-name
169 call assert_equal("valid-name", &syntax)
170
171 call assert_fails(":set syn=wrong;name", "E474:")
172 call assert_fails(":set syn=wrong\\\\name", "E474:")
173 call assert_fails(":set syn=wrong\\|name", "E474:")
174 call assert_fails(":set syn=wrong/name", "E474:")
175 call assert_fails(":set syn=wrong\\\nname", "E474:")
176 call assert_equal("valid-name", &syntax)
177
178 exe "set syn=trunc\x00name"
179 call assert_equal("trunc", &syntax)
180endfunc
181
182func Test_keymap_valid()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200183 CheckFeature keymap
Bram Moolenaard0b51382016-11-04 15:23:45 +0100184 call assert_fails(":set kmp=valid_name", "E544:")
185 call assert_fails(":set kmp=valid_name", "valid_name")
186 call assert_fails(":set kmp=valid-name", "E544:")
187 call assert_fails(":set kmp=valid-name", "valid-name")
188
189 call assert_fails(":set kmp=wrong;name", "E474:")
190 call assert_fails(":set kmp=wrong\\\\name", "E474:")
191 call assert_fails(":set kmp=wrong\\|name", "E474:")
192 call assert_fails(":set kmp=wrong/name", "E474:")
193 call assert_fails(":set kmp=wrong\\\nname", "E474:")
194
195 call assert_fails(":set kmp=trunc\x00name", "E544:")
196 call assert_fails(":set kmp=trunc\x00name", "trunc")
197endfunc
Bram Moolenaar7554da42016-11-25 22:04:13 +0100198
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100199func Check_dir_option(name)
Bram Moolenaar7554da42016-11-25 22:04:13 +0100200 " Check that it's possible to set the option.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100201 exe 'set ' . a:name . '=/usr/share/dict/words'
202 call assert_equal('/usr/share/dict/words', eval('&' . a:name))
203 exe 'set ' . a:name . '=/usr/share/dict/words,/and/there'
204 call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name))
205 exe 'set ' . a:name . '=/usr/share/dict\ words'
206 call assert_equal('/usr/share/dict words', eval('&' . a:name))
Bram Moolenaar7554da42016-11-25 22:04:13 +0100207
208 " Check rejecting weird characters.
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100209 call assert_fails("set " . a:name . "=/not&there", "E474:")
210 call assert_fails("set " . a:name . "=/not>there", "E474:")
211 call assert_fails("set " . a:name . "=/not.*there", "E474:")
212endfunc
213
Bram Moolenaar60629d62017-02-23 18:08:56 +0100214func Test_cinkeys()
215 " This used to cause invalid memory access
216 set cindent cinkeys=0
217 norm a
218 set cindent& cinkeys&
219endfunc
220
Bram Moolenaarf422bcc2016-11-26 17:45:53 +0100221func Test_dictionary()
222 call Check_dir_option('dictionary')
223endfunc
224
225func Test_thesaurus()
226 call Check_dir_option('thesaurus')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100227endfun
228
Bram Moolenaar226c5342017-02-17 14:53:15 +0100229func Test_complete()
230 " Trailing single backslash used to cause invalid memory access.
231 set complete=s\
232 new
233 call feedkeys("i\<C-N>\<Esc>", 'xt')
234 bwipe!
Bram Moolenaaree4e0c12020-04-06 21:35:05 +0200235 call assert_fails('set complete=ix', 'E535:')
Bram Moolenaar226c5342017-02-17 14:53:15 +0100236 set complete&
237endfun
238
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100239func Test_set_completion()
240 call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
241 call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
242
Bram Moolenaar297610b2019-12-27 17:20:55 +0100243 call feedkeys(":setlocal di\<C-A>\<C-B>\"\<CR>", 'tx')
244 call assert_equal('"setlocal dictionary diff diffexpr diffopt digraph directory display', @:)
245
246 call feedkeys(":setglobal di\<C-A>\<C-B>\"\<CR>", 'tx')
247 call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:)
248
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100249 " Expand boolan options. When doing :set no<Tab>
250 " vim displays the options names without "no" but completion uses "no...".
251 call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
252 call assert_equal('"set nodiff digraph', @:)
253
254 call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
255 call assert_equal('"set invdiff digraph', @:)
256
257 " Expand abbreviation of options.
258 call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
259 call assert_equal('"set tabstop thesaurus ttyscroll', @:)
260
261 " Expand current value
262 call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
263 call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
264
265 call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
266 call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
267
268 " Expand key codes.
269 call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
270 call assert_equal('"set <Help> <Home>', @:)
271
272 " Expand terminal options.
273 call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaare023e882020-05-31 16:42:30 +0200274 call assert_equal('"set t_AB t_AF t_AU t_AL', @:)
Bram Moolenaar0ff5ded2020-05-07 18:43:44 +0200275 call assert_fails('call feedkeys(":set <t_afoo>=\<C-A>\<CR>", "xt")', 'E474:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100276
277 " Expand directories.
278 call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
279 call assert_match(' ./samples/ ', @:)
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200280 call assert_notmatch(' ./summarize.vim ', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100281
282 " Expand files and directories.
283 call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200284 call assert_match(' ./samples/.* ./summarize.vim', @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100285
286 call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
287 call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
Bram Moolenaar0331faf2019-06-15 18:40:37 +0200288 set tags&
Bram Moolenaar1363a302020-04-12 13:50:26 +0200289
290 " Expanding the option names
291 call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')
292 call assert_equal('"set all', @:)
293
294 " Expanding a second set of option names
295 call feedkeys(":set wrapscan \<Tab>\<C-B>\"\<CR>", 'xt')
296 call assert_equal('"set wrapscan all', @:)
297
298 " Expanding a special keycode
299 call feedkeys(":set <Home>\<Tab>\<C-B>\"\<CR>", 'xt')
300 call assert_equal('"set <Home>', @:)
301
302 " Expanding an invalid special keycode
303 call feedkeys(":set <abcd>\<Tab>\<C-B>\"\<CR>", 'xt')
304 call assert_equal("\"set <abcd>\<Tab>", @:)
305
306 " Expanding a terminal keycode
307 call feedkeys(":set t_AB\<Tab>\<C-B>\"\<CR>", 'xt')
308 call assert_equal("\"set t_AB", @:)
309
310 " Expanding an invalid option name
311 call feedkeys(":set abcde=\<Tab>\<C-B>\"\<CR>", 'xt')
312 call assert_equal("\"set abcde=\<Tab>", @:)
313
314 " Expanding after a = for a boolean option
315 call feedkeys(":set wrapscan=\<Tab>\<C-B>\"\<CR>", 'xt')
316 call assert_equal("\"set wrapscan=\<Tab>", @:)
317
318 " Expanding a numeric option
319 call feedkeys(":set tabstop+=\<Tab>\<C-B>\"\<CR>", 'xt')
320 call assert_equal("\"set tabstop+=" .. &tabstop, @:)
321
322 " Expanding a non-boolean option
323 call feedkeys(":set invtabstop=\<Tab>\<C-B>\"\<CR>", 'xt')
324 call assert_equal("\"set invtabstop=", @:)
325
326 " Expand options for 'spellsuggest'
327 call feedkeys(":set spellsuggest=best,file:xyz\<Tab>\<C-B>\"\<CR>", 'xt')
328 call assert_equal("\"set spellsuggest=best,file:xyz", @:)
329
330 " Expand value for 'key'
331 set key=abcd
332 call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
333 call assert_equal('"set key=*****', @:)
334 set key=
Bram Moolenaard5e8c922021-02-02 21:10:01 +0100335
336 " Expand values for 'filetype'
337 call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
338 call assert_equal('"set filetype=sshdconfig', @:)
339 call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
340 call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100341endfunc
342
343func Test_set_errors()
344 call assert_fails('set scroll=-1', 'E49:')
345 call assert_fails('set backupcopy=', 'E474:')
346 call assert_fails('set regexpengine=3', 'E474:')
347 call assert_fails('set history=10001', 'E474:')
Bram Moolenaarf8a07122019-07-01 22:06:07 +0200348 call assert_fails('set numberwidth=21', 'E474:')
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100349 call assert_fails('set colorcolumn=-a', 'E474:')
350 call assert_fails('set colorcolumn=a', 'E474:')
351 call assert_fails('set colorcolumn=1,', 'E474:')
352 call assert_fails('set colorcolumn=1;', 'E474:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100353 call assert_fails('set cmdheight=-1', 'E487:')
354 call assert_fails('set cmdwinheight=-1', 'E487:')
355 if has('conceal')
356 call assert_fails('set conceallevel=-1', 'E487:')
357 call assert_fails('set conceallevel=4', 'E474:')
358 endif
359 call assert_fails('set helpheight=-1', 'E487:')
360 call assert_fails('set history=-1', 'E487:')
361 call assert_fails('set report=-1', 'E487:')
362 call assert_fails('set shiftwidth=-1', 'E487:')
363 call assert_fails('set sidescroll=-1', 'E487:')
364 call assert_fails('set tabstop=-1', 'E487:')
365 call assert_fails('set textwidth=-1', 'E487:')
366 call assert_fails('set timeoutlen=-1', 'E487:')
367 call assert_fails('set updatecount=-1', 'E487:')
368 call assert_fails('set updatetime=-1', 'E487:')
369 call assert_fails('set winheight=-1', 'E487:')
370 call assert_fails('set tabstop!', 'E488:')
371 call assert_fails('set xxx', 'E518:')
372 call assert_fails('set beautify?', 'E519:')
373 call assert_fails('set undolevels=x', 'E521:')
374 call assert_fails('set tabstop=', 'E521:')
375 call assert_fails('set comments=-', 'E524:')
376 call assert_fails('set comments=a', 'E525:')
377 call assert_fails('set foldmarker=x', 'E536:')
378 call assert_fails('set commentstring=x', 'E537:')
379 call assert_fails('set complete=x', 'E539:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100380 call assert_fails('set rulerformat=%-', 'E539:')
381 call assert_fails('set rulerformat=%(', 'E542:')
382 call assert_fails('set rulerformat=%15(%%', 'E542:')
383 call assert_fails('set statusline=%$', 'E539:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100384 call assert_fails('set statusline=%{', 'E540:')
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100385 call assert_fails('set statusline=%(', 'E542:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100386 call assert_fails('set statusline=%)', 'E542:')
387
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100388 if has('cursorshape')
389 " This invalid value for 'guicursor' used to cause Vim to crash.
390 call assert_fails('set guicursor=i-ci,r-cr:h', 'E545:')
391 call assert_fails('set guicursor=i-ci', 'E545:')
392 call assert_fails('set guicursor=x', 'E545:')
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100393 call assert_fails('set guicursor=x:', 'E546:')
Bram Moolenaar24922ec2017-02-23 17:59:22 +0100394 call assert_fails('set guicursor=r-cr:horx', 'E548:')
395 call assert_fails('set guicursor=r-cr:hor0', 'E549:')
396 endif
Bram Moolenaar9b9be002020-03-22 14:41:22 +0100397 if has('mouseshape')
398 call assert_fails('se mouseshape=i-r:x', 'E547:')
399 endif
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100400 call assert_fails('set backupext=~ patchmode=~', 'E589:')
401 call assert_fails('set winminheight=10 winheight=9', 'E591:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200402 set winminheight& winheight&
403 set winheight=10 winminheight=10
404 call assert_fails('set winheight=9', 'E591:')
405 set winminheight& winheight&
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100406 call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200407 set winminwidth& winwidth&
408 call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
409 set winwidth& winminwidth&
Bram Moolenaar698f8b22017-02-04 15:53:32 +0100410 call assert_fails("set showbreak=\x01", 'E595:')
411 call assert_fails('set t_foo=', 'E846:')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200412 call assert_fails('set tabstop??', 'E488:')
413 call assert_fails('set wrapscan!!', 'E488:')
414 call assert_fails('set tabstop&&', 'E488:')
415 call assert_fails('set wrapscan<<', 'E488:')
416 call assert_fails('set wrapscan=1', 'E474:')
417 call assert_fails('set autoindent@', 'E488:')
418 call assert_fails('set wildchar=<abc>', 'E474:')
419 call assert_fails('set cmdheight=1a', 'E521:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200420 call assert_fails('set invcmdheight', 'E474:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100421 if has('python') || has('python3')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200422 call assert_fails('set pyxversion=6', 'E474:')
423 endif
Bram Moolenaar1363a302020-04-12 13:50:26 +0200424 call assert_fails("let &tabstop='ab'", 'E521:')
Bram Moolenaar531be472020-09-23 22:38:05 +0200425 call assert_fails('set spellcapcheck=%\\(', 'E54:')
Bram Moolenaar85773bf2021-01-17 13:48:03 +0100426 call assert_fails('set sessionoptions=curdir,sesdir', 'E474:')
427 call assert_fails('set foldmarker={{{,', 'E474:')
428 call assert_fails('set sessionoptions=sesdir,curdir', 'E474:')
429 call assert_fails('set listchars=trail:· ambiwidth=double', 'E834:')
430 set listchars&
431 call assert_fails('set fillchars=stl:· ambiwidth=double', 'E835:')
432 set fillchars&
433 call assert_fails('set fileencoding=latin1,utf-8', 'E474:')
434 set nomodifiable
435 call assert_fails('set fileencoding=latin1', 'E21:')
436 set modifiable&
Bram Moolenaar7554da42016-11-25 22:04:13 +0100437endfunc
Bram Moolenaar67391142017-02-19 21:07:04 +0100438
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200439func CheckWasSet(name)
440 let verb_cm = execute('verbose set ' .. a:name .. '?')
441 call assert_match('Last set from.*test_options.vim', verb_cm)
442endfunc
443func CheckWasNotSet(name)
444 let verb_cm = execute('verbose set ' .. a:name .. '?')
445 call assert_notmatch('Last set from', verb_cm)
446endfunc
447
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200448" Must be executed before other tests that set 'term'.
449func Test_000_term_option_verbose()
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200450 CheckNotGui
451
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200452 call CheckWasNotSet('t_cm')
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200453
454 let term_save = &term
455 set term=ansi
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200456 call CheckWasSet('t_cm')
Bram Moolenaar35bc7d62018-10-02 14:45:10 +0200457 let &term = term_save
458endfunc
459
Bram Moolenaarcfb38142019-10-19 20:18:47 +0200460func Test_copy_context()
461 setlocal list
462 call CheckWasSet('list')
463 split
464 call CheckWasSet('list')
465 quit
466 setlocal nolist
467
468 set ai
469 call CheckWasSet('ai')
470 set filetype=perl
471 call CheckWasSet('filetype')
472 set fo=tcroq
473 call CheckWasSet('fo')
474
475 split Xsomebuf
476 call CheckWasSet('ai')
477 call CheckWasNotSet('filetype')
478 call CheckWasSet('fo')
479endfunc
480
Bram Moolenaar67391142017-02-19 21:07:04 +0100481func Test_set_ttytype()
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200482 CheckUnix
483 CheckNotGui
Bram Moolenaarf803a762017-04-09 22:54:13 +0200484
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200485 " Setting 'ttytype' used to cause a double-free when exiting vim and
486 " when vim is compiled with -DEXITFREE.
487 set ttytype=ansi
488 call assert_equal('ansi', &ttytype)
489 call assert_equal(&ttytype, &term)
490 set ttytype=xterm
491 call assert_equal('xterm', &ttytype)
492 call assert_equal(&ttytype, &term)
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200493 try
494 set ttytype=
495 call assert_report('set ttytype= did not fail')
Bram Moolenaar5daa9112021-02-01 18:39:47 +0100496 catch /E529/
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200497 endtry
Bram Moolenaarf803a762017-04-09 22:54:13 +0200498
Bram Moolenaar8c5a2782019-08-07 23:07:07 +0200499 " Some systems accept any terminal name and return dumb settings,
500 " check for failure of finding the entry and for missing 'cm' entry.
501 try
502 set ttytype=xxx
503 call assert_report('set ttytype=xxx did not fail')
504 catch /E522\|E437/
505 endtry
506
507 set ttytype&
508 call assert_equal(&ttytype, &term)
Bram Moolenaaree4e0c12020-04-06 21:35:05 +0200509
510 if has('gui') && !has('gui_running')
511 call assert_fails('set term=gui', 'E531:')
512 endif
Bram Moolenaar67391142017-02-19 21:07:04 +0100513endfunc
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100514
515func Test_set_all()
516 set tw=75
517 set iskeyword=a-z,A-Z
518 set nosplitbelow
519 let out = execute('set all')
520 call assert_match('textwidth=75', out)
521 call assert_match('iskeyword=a-z,A-Z', out)
522 call assert_match('nosplitbelow', out)
523 set tw& iskeyword& splitbelow&
524endfunc
525
Bram Moolenaar6b915c02020-01-18 15:53:19 +0100526func Test_set_one_column()
527 let out_mult = execute('set all')->split("\n")
528 let out_one = execute('set! all')->split("\n")
Bram Moolenaarab505b12020-03-23 19:28:44 +0100529 call assert_true(len(out_mult) < len(out_one))
Bram Moolenaar6b915c02020-01-18 15:53:19 +0100530endfunc
531
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100532func Test_set_values()
Bram Moolenaarbdd2c292020-06-22 21:34:30 +0200533 " opt_test.vim is generated from ../optiondefs.h using gen_opt_test.vim
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100534 if filereadable('opt_test.vim')
535 source opt_test.vim
Bram Moolenaare8512d72017-03-07 22:33:32 +0100536 else
537 throw 'Skipped: opt_test.vim does not exist'
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100538 endif
539endfunc
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200540
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100541func Test_renderoptions()
542 " Only do this for Windows Vista and later, fails on Windows XP and earlier.
543 " Doesn't hurt to do this on a non-Windows system.
544 if windowsversion() !~ '^[345]\.'
545 set renderoptions=type:directx
546 set rop=type:directx
547 endif
548endfunc
549
Bram Moolenaara701b3b2017-04-20 22:57:27 +0200550func ResetIndentexpr()
551 set indentexpr=
552endfunc
553
554func Test_set_indentexpr()
555 " this was causing usage of freed memory
556 set indentexpr=ResetIndentexpr()
557 new
558 call feedkeys("i\<c-f>", 'x')
559 call assert_equal('', &indentexpr)
560 bwipe!
561endfunc
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200562
563func Test_backupskip()
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100564 " Option 'backupskip' may contain several comma-separated path
565 " specifications if one or more of the environment variables TMPDIR, TMP,
566 " or TEMP is defined. To simplify testing, convert the string value into a
567 " list.
568 let bsklist = split(&bsk, ',')
569
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200570 if has("mac")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100571 let found = (index(bsklist, '/private/tmp/*') >= 0)
572 call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200573 elseif has("unix")
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100574 let found = (index(bsklist, '/tmp/*') >= 0)
575 call assert_true(found, '/tmp not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200576 endif
577
Bram Moolenaar98ad1e12019-01-30 21:51:27 +0100578 " If our test platform is Windows, the path(s) in option bsk will use
579 " backslash for the path separator and the components could be in short
580 " (8.3) format. As such, we need to replace the backslashes with forward
581 " slashes and convert the path components to long format. The expand()
582 " function will do this but it cannot handle comma-separated paths. This is
583 " why bsk was converted from a string into a list of strings above.
584 "
585 " One final complication is that the wildcard "/*" is at the end of each
586 " path and so expand() might return a list of matching files. To prevent
587 " this, we need to remove the wildcard before calling expand() and then
588 " append it afterwards.
589 if has('win32')
590 let item_nbr = 0
591 while item_nbr < len(bsklist)
592 let path_spec = bsklist[item_nbr]
593 let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
594 let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
595 let bsklist[item_nbr] = path_spec . '/*'
596 let item_nbr += 1
597 endwhile
598 endif
599
600 " Option bsk will also include these environment variables if defined.
601 " If they're defined, verify they appear in the option value.
602 for var in ['$TMPDIR', '$TMP', '$TEMP']
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200603 if exists(var)
604 let varvalue = substitute(expand(var), '\\', '/', 'g')
Bram Moolenaarcbbd0f62019-01-30 22:36:18 +0100605 let varvalue = substitute(varvalue, '/$', '', '')
606 let varvalue .= '/*'
607 let found = (index(bsklist, varvalue) >= 0)
608 call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk)
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200609 endif
610 endfor
Bram Moolenaar06e2c812019-06-12 19:05:48 +0200611
Bram Moolenaarb00ef052020-09-12 14:53:53 +0200612 " Duplicates from environment variables should be filtered out (option has
613 " P_NODUP). Run this in a separate instance and write v:errors in a file,
614 " so that we see what happens on startup.
615 let after =<< trim [CODE]
616 let bsklist = split(&backupskip, ',')
617 call assert_equal(uniq(copy(bsklist)), bsklist)
618 call writefile(['errors:'] + v:errors, 'Xtestout')
619 qall
620 [CODE]
621 call writefile(after, 'Xafter')
622 let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
623
624 let saveenv = {}
625 for var in ['TMPDIR', 'TMP', 'TEMP']
626 let saveenv[var] = getenv(var)
627 call setenv(var, '/duplicate/path')
628 endfor
629
630 exe 'silent !' . cmd
631 call assert_equal(['errors:'], readfile('Xtestout'))
632
633 " restore environment variables
634 for var in ['TMPDIR', 'TMP', 'TEMP']
635 call setenv(var, saveenv[var])
636 endfor
637
638 call delete('Xtestout')
639 call delete('Xafter')
640
Bram Moolenaar06e2c812019-06-12 19:05:48 +0200641 " Duplicates should be filtered out (option has P_NODUP)
642 let backupskip = &backupskip
643 set backupskip=
644 set backupskip+=/test/dir
645 set backupskip+=/other/dir
646 set backupskip+=/test/dir
647 call assert_equal('/test/dir,/other/dir', &backupskip)
648 let &backupskip = backupskip
Bram Moolenaarb8e22a02018-04-12 21:37:34 +0200649endfunc
Bram Moolenaar25782a72018-05-13 18:05:33 +0200650
651func Test_copy_winopt()
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200652 set hidden
Bram Moolenaar25782a72018-05-13 18:05:33 +0200653
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200654 " Test copy option from current buffer in window
655 split
656 enew
657 setlocal numberwidth=5
658 wincmd w
659 call assert_equal(4,&numberwidth)
660 bnext
661 call assert_equal(5,&numberwidth)
662 bw!
663 call assert_equal(4,&numberwidth)
Bram Moolenaar25782a72018-05-13 18:05:33 +0200664
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200665 " Test copy value from window that used to be display the buffer
666 split
667 enew
668 setlocal numberwidth=6
669 bnext
670 wincmd w
671 call assert_equal(4,&numberwidth)
672 bnext
673 call assert_equal(6,&numberwidth)
674 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200675
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200676 " Test that if buffer is current, don't use the stale cached value
677 " from the last time the buffer was displayed.
678 split
679 enew
680 setlocal numberwidth=7
681 bnext
682 bnext
683 setlocal numberwidth=8
684 wincmd w
685 call assert_equal(4,&numberwidth)
686 bnext
687 call assert_equal(8,&numberwidth)
688 bw!
Bram Moolenaar25782a72018-05-13 18:05:33 +0200689
Bram Moolenaar7cb33a12018-08-23 22:20:35 +0200690 " Test value is not copied if window already has seen the buffer
691 enew
692 split
693 setlocal numberwidth=9
694 bnext
695 setlocal numberwidth=10
696 wincmd w
697 call assert_equal(4,&numberwidth)
698 bnext
699 call assert_equal(4,&numberwidth)
700 bw!
701
702 set hidden&
Bram Moolenaar25782a72018-05-13 18:05:33 +0200703endfunc
Bram Moolenaarfc089602018-06-24 16:53:35 +0200704
705func Test_shortmess_F()
706 new
707 call assert_match('\[No Name\]', execute('file'))
708 set shortmess+=F
709 call assert_match('\[No Name\]', execute('file'))
710 call assert_match('^\s*$', execute('file foo'))
711 call assert_match('foo', execute('file'))
712 set shortmess-=F
713 call assert_match('bar', execute('file bar'))
714 call assert_match('bar', execute('file'))
715 set shortmess&
716 bwipe
717endfunc
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200718
719func Test_shortmess_F2()
720 e file1
721 e file2
722 call assert_match('file1', execute('bn', ''))
723 call assert_match('file2', execute('bn', ''))
724 set shortmess+=F
725 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200726 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200727 call assert_true(empty(execute('bn', '')))
Bram Moolenaarce90e362019-09-08 18:58:44 +0200728 call assert_false('need_fileinfo'->test_getvalue())
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200729 set hidden
730 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200731 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200732 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200733 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200734 set nohidden
735 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200736 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200737 call assert_true(empty(execute('bn', '')))
Bram Moolenaareda65222019-05-16 20:29:44 +0200738 call assert_false(test_getvalue('need_fileinfo'))
Bram Moolenaar2f0f8712018-08-21 18:50:18 +0200739 set shortmess&
740 call assert_match('file1', execute('bn', ''))
741 call assert_match('file2', execute('bn', ''))
742 bwipe
743 bwipe
744endfunc
Bram Moolenaar375e3392019-01-31 18:26:10 +0100745
746func Test_local_scrolloff()
747 set so=5
748 set siso=7
749 split
750 call assert_equal(5, &so)
751 setlocal so=3
752 call assert_equal(3, &so)
753 wincmd w
754 call assert_equal(5, &so)
755 wincmd w
756 setlocal so<
757 call assert_equal(5, &so)
758 setlocal so=0
759 call assert_equal(0, &so)
760 setlocal so=-1
761 call assert_equal(5, &so)
762
763 call assert_equal(7, &siso)
764 setlocal siso=3
765 call assert_equal(3, &siso)
766 wincmd w
767 call assert_equal(7, &siso)
768 wincmd w
769 setlocal siso<
770 call assert_equal(7, &siso)
771 setlocal siso=0
772 call assert_equal(0, &siso)
773 setlocal siso=-1
774 call assert_equal(7, &siso)
775
776 close
777 set so&
778 set siso&
779endfunc
Bram Moolenaar449ac472019-04-03 21:42:35 +0200780
781func Test_writedelay()
Bram Moolenaar5feabe02020-01-30 18:24:53 +0100782 CheckFunction reltimefloat
783
Bram Moolenaar449ac472019-04-03 21:42:35 +0200784 new
785 call setline(1, 'empty')
786 redraw
787 set writedelay=10
788 let start = reltime()
789 call setline(1, repeat('x', 70))
790 redraw
791 let elapsed = reltimefloat(reltime(start))
792 set writedelay=0
793 " With 'writedelay' set should take at least 30 * 10 msec
794 call assert_inrange(30 * 0.01, 999.0, elapsed)
795
796 bwipe!
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200797endfunc
798
799func Test_visualbell()
Bram Moolenaar7a666272019-04-03 22:52:34 +0200800 set belloff=
Bram Moolenaarb4e6a2d2019-04-03 21:53:33 +0200801 set visualbell
802 call assert_beeps('normal 0h')
803 set novisualbell
Bram Moolenaar7a666272019-04-03 22:52:34 +0200804 set belloff=all
Bram Moolenaar449ac472019-04-03 21:42:35 +0200805endfunc
Bram Moolenaar5d98dc22020-01-29 21:57:34 +0100806
807" Test for the 'write' option
808func Test_write()
809 new
810 call setline(1, ['L1'])
811 set nowrite
812 call assert_fails('write Xfile', 'E142:')
813 set write
814 close!
815endfunc
816
817" Test for 'buftype' option
818func Test_buftype()
819 new
820 call setline(1, ['L1'])
821 set buftype=nowrite
822 call assert_fails('write', 'E382:')
Bram Moolenaara3a9c8e2020-03-19 12:38:34 +0100823
824 for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
825 exe 'set buftype=' .. val
826 call writefile(['something'], 'XBuftype')
827 call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
828 endfor
829
830 call delete('XBuftype')
831 bwipe!
Bram Moolenaar5d98dc22020-01-29 21:57:34 +0100832endfunc
833
Bram Moolenaar4d23c522020-04-09 18:42:11 +0200834" Test for the 'shell' option
835func Test_shell()
836 CheckUnix
837 let save_shell = &shell
838 set shell=
Bram Moolenaar4b2ce122020-11-21 21:41:41 +0100839 let caught_e91 = 0
840 try
841 shell
842 catch /E91:/
843 let caught_e91 = 1
844 endtry
845 call assert_equal(1, caught_e91)
Bram Moolenaar4d23c522020-04-09 18:42:11 +0200846 let &shell = save_shell
847endfunc
848
Bram Moolenaarea3db912020-02-02 15:32:13 +0100849" Test for the 'shellquote' option
850func Test_shellquote()
851 CheckUnix
852 set shellquote=#
853 set verbose=20
854 redir => v
855 silent! !echo Hello
856 redir END
857 set verbose&
858 set shellquote&
859 call assert_match(': "#echo Hello#"', v)
860endfunc
861
Bram Moolenaar578fe942020-02-27 21:32:51 +0100862" Test for the 'rightleftcmd' option
863func Test_rightleftcmd()
864 CheckFeature rightleft
865 set rightleft
866 set rightleftcmd
867
868 let g:l = []
869 func AddPos()
870 call add(g:l, screencol())
871 return ''
872 endfunc
873 cmap <expr> <F2> AddPos()
874
875 call feedkeys("/\<F2>abc\<Left>\<F2>\<Right>\<Right>\<F2>" ..
876 \ "\<Left>\<F2>\<Esc>", 'xt')
877 call assert_equal([&co - 1, &co - 4, &co - 2, &co - 3], g:l)
878
879 cunmap <F2>
880 unlet g:l
881 set rightleftcmd&
882 set rightleft&
883endfunc
884
Bram Moolenaarcde0ff32020-04-04 14:00:39 +0200885" Test for the "debug" option
886func Test_debug_option()
887 set debug=beep
888 exe "normal \<C-c>"
889 call assert_equal('Beep!', Screenline(&lines))
890 set debug&
891endfunc
892
Bram Moolenaar004a6782020-04-11 17:09:31 +0200893" Test for the default CDPATH option
894func Test_opt_default_cdpath()
895 CheckFeature file_in_path
896 let after =<< trim [CODE]
897 call assert_equal(',/path/to/dir1,/path/to/dir2', &cdpath)
898 call writefile(v:errors, 'Xtestout')
899 qall
900 [CODE]
901 if has('unix')
902 let $CDPATH='/path/to/dir1:/path/to/dir2'
903 else
904 let $CDPATH='/path/to/dir1;/path/to/dir2'
905 endif
906 if RunVim([], after, '')
907 call assert_equal([], readfile('Xtestout'))
908 call delete('Xtestout')
909 endif
910endfunc
911
912" Test for setting keycodes using set
913func Test_opt_set_keycode()
914 call assert_fails('set <t_k1=l', 'E474:')
915 call assert_fails('set <Home=l', 'E474:')
916 set <t_k9>=abcd
917 call assert_equal('abcd', &t_k9)
918 set <t_k9>&
919 set <F9>=xyz
920 call assert_equal('xyz', &t_k9)
921 set <t_k9>&
922endfunc
923
924" Test for changing options in a sandbox
925func Test_opt_sandbox()
926 for opt in ['backupdir', 'cdpath', 'exrc']
927 call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
Bram Moolenaar1363a302020-04-12 13:50:26 +0200928 call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200929 endfor
Bram Moolenaar1363a302020-04-12 13:50:26 +0200930 call assert_fails('sandbox let &modelineexpr = 1', 'E48:')
Bram Moolenaar004a6782020-04-11 17:09:31 +0200931endfunc
932
933" Test for setting an option with local value to global value
934func Test_opt_local_to_global()
935 setglobal equalprg=gprg
936 setlocal equalprg=lprg
937 call assert_equal('gprg', &g:equalprg)
938 call assert_equal('lprg', &l:equalprg)
939 call assert_equal('lprg', &equalprg)
940 set equalprg<
941 call assert_equal('', &l:equalprg)
942 call assert_equal('gprg', &equalprg)
943 setglobal equalprg=gnewprg
944 setlocal equalprg=lnewprg
945 setlocal equalprg<
946 call assert_equal('gnewprg', &l:equalprg)
947 call assert_equal('gnewprg', &equalprg)
948 set equalprg&
949endfunc
950
951" Test for incrementing, decrementing and multiplying a number option value
952func Test_opt_num_op()
953 set shiftwidth=4
954 set sw+=2
955 call assert_equal(6, &sw)
956 set sw-=2
957 call assert_equal(4, &sw)
958 set sw^=2
959 call assert_equal(8, &sw)
960 set shiftwidth&
961endfunc
962
Bram Moolenaar65d032c2020-04-24 20:57:01 +0200963" Test for setting option values using v:false and v:true
964func Test_opt_boolean()
965 set number&
966 set number
967 call assert_equal(1, &nu)
968 set nonu
969 call assert_equal(0, &nu)
970 let &nu = v:true
971 call assert_equal(1, &nu)
972 let &nu = v:false
973 call assert_equal(0, &nu)
974 set number&
975endfunc
976
Bram Moolenaarbdd2c292020-06-22 21:34:30 +0200977" Test for the 'window' option
978func Test_window_opt()
979 " Needs only one open widow
980 %bw!
981 call setline(1, range(1, 8))
982 set window=5
983 exe "normal \<C-F>"
984 call assert_equal(4, line('w0'))
985 exe "normal \<C-F>"
986 call assert_equal(7, line('w0'))
987 exe "normal \<C-F>"
988 call assert_equal(8, line('w0'))
989 exe "normal \<C-B>"
990 call assert_equal(5, line('w0'))
991 exe "normal \<C-B>"
992 call assert_equal(2, line('w0'))
993 exe "normal \<C-B>"
994 call assert_equal(1, line('w0'))
995 set window=1
996 exe "normal gg\<C-F>"
997 call assert_equal(2, line('w0'))
998 exe "normal \<C-F>"
999 call assert_equal(3, line('w0'))
1000 exe "normal \<C-B>"
1001 call assert_equal(2, line('w0'))
1002 exe "normal \<C-B>"
1003 call assert_equal(1, line('w0'))
1004 enew!
1005 set window&
1006endfunc
1007
Bram Moolenaar5d3c9f82020-06-26 20:41:39 +02001008" Test for the 'winminheight' option
1009func Test_opt_winminheight()
1010 only!
1011 let &winheight = &lines + 4
1012 call assert_fails('let &winminheight = &lines + 2', 'E36:')
1013 call assert_true(&winminheight <= &lines)
1014 set winminheight&
1015 set winheight&
1016endfunc
1017
1018" Test for the 'winminwidth' option
1019func Test_opt_winminwidth()
1020 only!
1021 let &winwidth = &columns + 4
1022 call assert_fails('let &winminwidth = &columns + 2', 'E36:')
1023 call assert_true(&winminwidth <= &columns)
1024 set winminwidth&
1025 set winwidth&
1026endfunc
1027
Bram Moolenaar994b89d2020-08-07 19:12:41 +02001028" Test for setting option value containing spaces with isfname+=32
1029func Test_isfname_with_options()
1030 set isfname+=32
1031 setlocal keywordprg=:term\ help.exe
1032 call assert_equal(':term help.exe', &keywordprg)
1033 set isfname&
1034 setlocal keywordprg&
1035endfunc
1036
Bram Moolenaar74667062020-12-28 15:41:41 +01001037" Test that resetting laststatus does change scroll option
1038func Test_opt_reset_scroll()
1039 CheckRunVimInTerminal
1040 let vimrc =<< trim [CODE]
1041 set scroll=2
1042 set laststatus=2
1043 [CODE]
1044 call writefile(vimrc, 'Xscroll')
1045 let buf = RunVimInTerminal('-S Xscroll', {'rows': 16, 'cols': 45})
1046 call term_sendkeys(buf, ":verbose set scroll?\n")
1047 call WaitForAssert({-> assert_match('Last set.*window size', term_getline(buf, 15))})
1048 call assert_match('^\s*scroll=7$', term_getline(buf, 14))
1049 call StopVimInTerminal(buf)
1050
1051 " clean up
1052 call delete('Xscroll')
1053endfunc
1054
Bram Moolenaar5d98dc22020-01-29 21:57:34 +01001055" vim: shiftwidth=2 sts=2 expandtab