@@ -128,4 +128,95 @@ endfunc
128128
129129func Test_thesaurus ()
130130 call Check_dir_option (' thesaurus' )
131+ endfun
132+
133+ func Test_set_completion ()
134+ call feedkeys (" :set di\<C-A>\<C-B> \" \<CR> " , ' tx' )
135+ call assert_equal (' "set dictionary diff diffexpr diffopt digraph directory display' , @: )
136+
137+ " Expand boolan options. When doing :set no<Tab>
138+ " vim displays the options names without "no" but completion uses "no...".
139+ call feedkeys (" :set nodi\<C-A>\<C-B> \" \<CR> " , ' tx' )
140+ call assert_equal (' "set nodiff digraph' , @: )
141+
142+ call feedkeys (" :set invdi\<C-A>\<C-B> \" \<CR> " , ' tx' )
143+ call assert_equal (' "set invdiff digraph' , @: )
144+
145+ " Expand abbreviation of options.
146+ call feedkeys (" :set ts\<C-A>\<C-B> \" \<CR> " , ' tx' )
147+ call assert_equal (' "set tabstop thesaurus ttyscroll' , @: )
148+
149+ " Expand current value
150+ call feedkeys (" :set fileencodings=\<C-A>\<C-B> \" \<CR> " , ' tx' )
151+ call assert_equal (' "set fileencodings=ucs-bom,utf-8,default,latin1' , @: )
152+
153+ call feedkeys (" :set fileencodings:\<C-A>\<C-B> \" \<CR> " , ' tx' )
154+ call assert_equal (' "set fileencodings:ucs-bom,utf-8,default,latin1' , @: )
155+
156+ " Expand key codes.
157+ call feedkeys (" :set <H\<C-A>\<C-B> \" \<CR> " , ' tx' )
158+ call assert_equal (' "set <Help> <Home>' , @: )
159+
160+ " Expand terminal options.
161+ call feedkeys (" :set t_A\<C-A>\<C-B> \" \<CR> " , ' tx' )
162+ call assert_equal (' "set t_AB t_AF t_AL' , @: )
163+
164+ " Expand directories.
165+ call feedkeys (" :set cdpath=./\<C-A>\<C-B> \" \<CR> " , ' tx' )
166+ call assert_match (' ./samples/ ' , @: )
167+ call assert_notmatch (' ./small.vim ' , @: )
168+
169+ " Expand files and directories.
170+ call feedkeys (" :set tags=./\<C-A>\<C-B> \" \<CR> " , ' tx' )
171+ call assert_match (' ./samples/.* ./small.vim' , @: )
172+
173+ call feedkeys (" :set tags=./\\\\ dif\<C-A>\<C-B> \" \<CR> " , ' tx' )
174+ call assert_equal (' "set tags=./\\ diff diffexpr diffopt' , @: )
175+ endfunc
176+
177+ func Test_set_errors ()
178+ call assert_fails (' set scroll=-1' , ' E49:' )
179+ call assert_fails (' set backupcopy=' , ' E474:' )
180+ call assert_fails (' set regexpengine=3' , ' E474:' )
181+ call assert_fails (' set history=10001' , ' E474:' )
182+ call assert_fails (' set numberwidth=11' , ' E474:' )
183+ call assert_fails (' set colorcolumn=-a' )
184+ call assert_fails (' set colorcolumn=a' )
185+ call assert_fails (' set colorcolumn=1,' )
186+ call assert_fails (' set cmdheight=-1' , ' E487:' )
187+ call assert_fails (' set cmdwinheight=-1' , ' E487:' )
188+ if has (' conceal' )
189+ call assert_fails (' set conceallevel=-1' , ' E487:' )
190+ call assert_fails (' set conceallevel=4' , ' E474:' )
191+ endif
192+ call assert_fails (' set helpheight=-1' , ' E487:' )
193+ call assert_fails (' set history=-1' , ' E487:' )
194+ call assert_fails (' set report=-1' , ' E487:' )
195+ call assert_fails (' set shiftwidth=-1' , ' E487:' )
196+ call assert_fails (' set sidescroll=-1' , ' E487:' )
197+ call assert_fails (' set tabstop=-1' , ' E487:' )
198+ call assert_fails (' set textwidth=-1' , ' E487:' )
199+ call assert_fails (' set timeoutlen=-1' , ' E487:' )
200+ call assert_fails (' set updatecount=-1' , ' E487:' )
201+ call assert_fails (' set updatetime=-1' , ' E487:' )
202+ call assert_fails (' set winheight=-1' , ' E487:' )
203+ call assert_fails (' set tabstop!' , ' E488:' )
204+ call assert_fails (' set xxx' , ' E518:' )
205+ call assert_fails (' set beautify?' , ' E519:' )
206+ call assert_fails (' set undolevels=x' , ' E521:' )
207+ call assert_fails (' set tabstop=' , ' E521:' )
208+ call assert_fails (' set comments=-' , ' E524:' )
209+ call assert_fails (' set comments=a' , ' E525:' )
210+ call assert_fails (' set foldmarker=x' , ' E536:' )
211+ call assert_fails (' set commentstring=x' , ' E537:' )
212+ call assert_fails (' set complete=x' , ' E539:' )
213+ call assert_fails (' set statusline=%{' , ' E540:' )
214+ call assert_fails (' set statusline=' . repeat (" %p" , 81 ), ' E541:' )
215+ call assert_fails (' set statusline=%(' , ' E542:' )
216+ call assert_fails (' set guicursor=x' , ' E545:' )
217+ call assert_fails (' set backupext=~ patchmode=~' , ' E589:' )
218+ call assert_fails (' set winminheight=10 winheight=9' , ' E591:' )
219+ call assert_fails (' set winminwidth=10 winwidth=9' , ' E592:' )
220+ call assert_fails (" set showbreak=\x01 " , ' E595:' )
221+ call assert_fails (' set t_foo=' , ' E846:' )
131222endfunc
0 commit comments