aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir
diff options
context:
space:
mode:
Diffstat (limited to 'test/old/testdir')
-rw-r--r--test/old/testdir/test_cmdline.vim66
-rw-r--r--test/old/testdir/test_options.vim52
2 files changed, 110 insertions, 8 deletions
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index 54f5dd500b..90748a6076 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -1176,13 +1176,71 @@ func Test_cmdline_complete_various()
mapclear
delcom MyCmd
+ " Prepare for path completion
+ call mkdir('Xa b c', 'D')
+ defer delete('Xcomma,foobar.txt')
+ call writefile([], 'Xcomma,foobar.txt')
+
" completion for :set path= with multiple backslashes
- call feedkeys(":set path=a\\\\\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
- call assert_equal('"set path=a\\\ b', @:)
+ call feedkeys(':set path=Xa\\\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set path=Xa\\\ b\\\ c/', @:)
+ set path&
" completion for :set dir= with a backslash
- call feedkeys(":set dir=a\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
- call assert_equal('"set dir=a\ b', @:)
+ call feedkeys(':set dir=Xa\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set dir=Xa\ b\ c/', @:)
+ set dir&
+
+ " completion for :set tags= / set dictionary= with escaped commas
+ if has('win32')
+ " In Windows backslashes are rounded up, so both '\,' and '\\,' escape to
+ " '\,'
+ call feedkeys(':set dictionary=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set dictionary=Xcomma\,foobar.txt', @:)
+
+ call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set tags=Xcomma\,foobar.txt', @:)
+
+ call feedkeys(':set tags=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set tags=Xcomma\\\,foo', @:) " Didn't find a match
+
+ " completion for :set dictionary= with escaped commas (same behavior, but
+ " different internal code path from 'set tags=' for escaping the output)
+ call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set tags=Xcomma\,foobar.txt', @:)
+ else
+ " In other platforms, backslashes are rounded down (since '\,' itself will
+ " be escaped into ','). As a result '\\,' and '\\\,' escape to '\,'.
+ call feedkeys(':set tags=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set tags=Xcomma\,foo', @:) " Didn't find a match
+
+ call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set tags=Xcomma\\,foobar.txt', @:)
+
+ call feedkeys(':set dictionary=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:)
+
+ " completion for :set dictionary= with escaped commas (same behavior, but
+ " different internal code path from 'set tags=' for escaping the output)
+ call feedkeys(':set dictionary=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:)
+ endif
+ set tags&
+ set dictionary&
+
+ " completion for :set makeprg= with no escaped commas
+ call feedkeys(':set makeprg=Xcomma,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set makeprg=Xcomma,foobar.txt', @:)
+
+ if !has('win32')
+ " Cannot create file with backslash in file name in Windows, so only test
+ " this elsewhere.
+ defer delete('Xcomma\,fooslash.txt')
+ call writefile([], 'Xcomma\,fooslash.txt')
+ call feedkeys(':set makeprg=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set makeprg=Xcomma\\,fooslash.txt', @:)
+ endif
+ set makeprg&
" completion for the :py3 commands
call feedkeys(":py3\<C-A>\<C-B>\"\<CR>", 'xt')
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index 76b7cc920b..cc3f21b86b 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -316,16 +316,60 @@ func Test_set_completion()
" Expand directories.
call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('./samples/ ', @:)
- call assert_notmatch('./small.vim ', @:)
+ call assert_match(' ./samples/ ', @:)
+ call assert_notmatch(' ./summarize.vim ', @:)
+ set cdpath&
" Expand files and directories.
call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('./samples/ ./sautest/ ./screendump.vim ./script_util.vim ./setup.vim ./shared.vim', @:)
+ call assert_match(' ./samples/.* ./summarize.vim', @:)
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
- set tags&
+
+ " Expand files with spaces/commas in them. Make sure we delimit correctly.
+ "
+ " 'tags' allow for for spaces/commas to both act as delimiters, with actual
+ " spaces requiring double escape, and commas need a single escape.
+ " 'dictionary' is a normal comma-separated option where only commas act as
+ " delimiters, and both space/comma need one single escape.
+ " 'makeprg' is a non-comma-separated option. Commas don't need escape.
+ defer delete('Xfoo Xspace.txt')
+ defer delete('Xsp_dummy')
+ defer delete('Xbar,Xcomma.txt')
+ defer delete('Xcom_dummy')
+ call writefile([], 'Xfoo Xspace.txt')
+ call writefile([], 'Xsp_dummy')
+ call writefile([], 'Xbar,Xcomma.txt')
+ call writefile([], 'Xcom_dummy')
+
+ call feedkeys(':set tags=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set tags=./Xfoo\ Xsp_dummy', @:)
+ call feedkeys(':set tags=./Xfoo\\\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set tags=./Xfoo\\\ Xspace.txt', @:)
+ call feedkeys(':set dictionary=./Xfoo\ Xsp' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set dictionary=./Xfoo\ Xspace.txt', @:)
+
+ call feedkeys(':set dictionary=./Xbar,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set dictionary=./Xbar,Xcom_dummy', @:)
+ if has('win32')
+ " In Windows, '\,' is literal, see `:help filename-backslash`, so this
+ " means we treat it as one file name.
+ call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set dictionary=Xbar\,Xcomma.txt', @:)
+ else
+ " In other platforms, '\,' simply escape to ',', and indicate a delimiter
+ " to split into a separate file name. You need '\\,' to escape the comma
+ " as part of the file name.
+ call feedkeys(':set dictionary=Xbar\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set dictionary=Xbar\,Xcom_dummy', @:)
+
+ call feedkeys(':set dictionary=Xbar\\,Xcom' .. "\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set dictionary=Xbar\\,Xcomma.txt', @:)
+ endif
+ call feedkeys(":set makeprg=./Xbar,Xcom\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set makeprg=./Xbar,Xcomma.txt', @:)
+ set tags& dictionary& makeprg&
" Expanding the option names
call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')