From 2e46de450e7aebc846c768c29a5bfdfed20232b3 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Tue, 19 Apr 2022 15:07:44 +0100 Subject: [PATCH 01/13] gitignore test/vader.vim cloned by test/run script --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 926ccaa..1046619 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ doc/tags +test/vader.vim From a49ef6c5d28870d49f4f861c0219eab8ef07304f Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Tue, 19 Apr 2022 15:15:36 +0100 Subject: [PATCH 02/13] Add some vader tests for completion feature I want to improve file/path completion, so add some tests to cover existing behaviour (at least existing behaviour as I understand it). --- test/feature/completion.vader | 61 +++++++++++++++++++++++++++++ test/include/completion/foo/bar/baz | 0 2 files changed, 61 insertions(+) create mode 100644 test/feature/completion.vader create mode 100644 test/include/completion/foo/bar/baz diff --git a/test/feature/completion.vader b/test/feature/completion.vader new file mode 100644 index 0000000..ca510e2 --- /dev/null +++ b/test/feature/completion.vader @@ -0,0 +1,61 @@ +Before: + enew! + only! + cd include/completion + let w:testing = 1 + +After: + cd - + +Execute (command: flags, match all): + Assert len(grepper#complete('-', '', v:null)) > 3 + AssertEqual count(grepper#complete('-', '', v:null), '-cword '), 1 + AssertEqual count(grepper#complete('-', '', v:null), '-grepprg '), 1 + AssertEqual count(grepper#complete('-', '', v:null), '-tool '), 1 + +Execute (command: flags, match one): + AssertEqual grepper#complete('-noquickf', '', v:null), ['-noquickfix '] + +Execute (command: flags, match some): + Assert len(grepper#complete('-no', '', v:null)) > 2 + AssertEqual count(grepper#complete('-no', '', v:null), '-switch '), 0 + AssertEqual count(grepper#complete('-no', '', v:null), '-noswitch '), 1 + +Execute (command: flags, -dir options): + Assert len(grepper#complete('', 'Grepper -dir ', v:null)) > 2 + AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'cwd '), 1 + AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'repo '), 1 + +Execute (command: flags, -stop completion): + Assert grepper#complete('', 'Grepper -stop ', v:null)[0] =~# '\d\+' + +Execute (command: flags, -tool options): + Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 + AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 + +Execute (command: flags, -tool options): + Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 + AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 + +Execute (prompt: relative path, empty string): + AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/'] + +Execute (prompt: relative path, whitespace only): + AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/'] + +Execute (prompt: sub-path, ./ exact match): + AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/'] + +Execute (prompt: sub-path, ./ and word chars): + AssertEqual grepper#complete_files('x ./f', v:null, v:null), ['x ./foo/'] + +Execute (prompt: nested sub-path, e.g. ./foo/): + AssertEqual grepper#complete_files('x ./foo/', v:null, v:null), ['x ./foo/bar/'] + +Execute (prompt: absolute path, / exact match): + AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /bin/'), 1 + AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /var/'), 1 + +Execute (prompt: absolute path, / and word chars): + AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /bin/'), 1 + AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /var/'), 0 diff --git a/test/include/completion/foo/bar/baz b/test/include/completion/foo/bar/baz new file mode 100644 index 0000000..e69de29 From 56854d9048fb66bf9459bafa2722cff494d9e8dd Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Tue, 19 Apr 2022 15:19:48 +0100 Subject: [PATCH 03/13] Complete relative paths with leading word chars --- plugin/grepper.vim | 2 +- test/feature/completion.vader | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 3552d51..cb410ca 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -236,7 +236,7 @@ endfunction function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) " handle relative paths - if empty(path) || (path =~ '\s$') + if empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') return map(split(globpath('.'.s:slash, path.'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') " handle sub paths elseif path =~ '^.\/' diff --git a/test/feature/completion.vader b/test/feature/completion.vader index ca510e2..efefe39 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -43,6 +43,9 @@ Execute (prompt: relative path, empty string): Execute (prompt: relative path, whitespace only): AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/'] +Execute (prompt: relative path, leading word chars): + AssertEqual grepper#complete_files('x f', v:null, v:null), ['x ./foo/'] + Execute (prompt: sub-path, ./ exact match): AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/'] From c7857e08cf72f62bff4f7d0effb09db906598f93 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Tue, 19 Apr 2022 16:05:40 +0100 Subject: [PATCH 04/13] Complete relative paths more like vim's completion Relative path completion relies on the globpath() function, prepending a leading dot and slash when creating the path for globpath(), but this results in path completions with a leading dot and slash, unlike vim's built in file/path completion, so strip them back out before returning. --- plugin/grepper.vim | 5 ++++- test/feature/completion.vader | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index cb410ca..7931d64 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -237,7 +237,10 @@ function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) " handle relative paths if empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') - return map(split(globpath('.'.s:slash, path.'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') + return map( + \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), + \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' + \ ) " handle sub paths elseif path =~ '^.\/' return map(split(globpath('.'.s:slash, path[2:].'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') diff --git a/test/feature/completion.vader b/test/feature/completion.vader index efefe39..c85ad14 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -38,13 +38,13 @@ Execute (command: flags, -tool options): AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 Execute (prompt: relative path, empty string): - AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/'] + AssertEqual grepper#complete_files('x ', v:null, v:null), ['x foo/'] Execute (prompt: relative path, whitespace only): - AssertEqual grepper#complete_files('x ', v:null, v:null), ['x ./foo/'] + AssertEqual grepper#complete_files('x ', v:null, v:null), ['x foo/'] Execute (prompt: relative path, leading word chars): - AssertEqual grepper#complete_files('x f', v:null, v:null), ['x ./foo/'] + AssertEqual grepper#complete_files('x f', v:null, v:null), ['x foo/'] Execute (prompt: sub-path, ./ exact match): AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/'] From b6706ae803d6fb2bd7d3c30cb65ca594a56635b9 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Wed, 20 Apr 2022 10:15:53 +0100 Subject: [PATCH 05/13] Support tilde expansion when completing files - Expand tilde alone to $HOME (same as vim's built in path completion) - Support completion of paths relative to ~/ (taken from PR #152) This is getting quite messy now, but that's ok, we have some tests! Refactoring can come later, maybe when supporting hidden files/dirs. --- plugin/grepper.vim | 8 +++++++- test/feature/completion.vader | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 7931d64..1fc891a 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -235,8 +235,14 @@ endfunction " grepper#complete_files() {{{2 function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) + " tilde expansion to $HOME + if path ==# '~' + return [head . $HOME] + " handle paths in $HOME (~/foo) + elseif path[0:1] ==# '~/' + return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') " handle relative paths - if empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') + elseif empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') return map( \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' diff --git a/test/feature/completion.vader b/test/feature/completion.vader index c85ad14..34b70d3 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -37,6 +37,15 @@ Execute (command: flags, -tool options): Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 +Execute (prompt: path, tilde expansion): + AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME] + +Execute (prompt: path, relative to $HOME): + let home = $HOME + let $HOME = getcwd() + AssertEqual grepper#complete_files('x ~/f', v:null, v:null), ['x ~/foo/'] + let $HOME = home + Execute (prompt: relative path, empty string): AssertEqual grepper#complete_files('x ', v:null, v:null), ['x foo/'] From 1231216a09c3bf9d98a92e675fddc81843ff8482 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Wed, 20 Apr 2022 12:06:26 +0100 Subject: [PATCH 06/13] Allow completion of relative paths to hidden files --- plugin/grepper.vim | 2 +- test/feature/completion.vader | 9 +++++++++ test/include/completion/.foo | 0 test/include/completion/foo/bar/.baz | 0 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/include/completion/.foo create mode 100644 test/include/completion/foo/bar/.baz diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 1fc891a..4340300 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -242,7 +242,7 @@ function! grepper#complete_files(lead, _line, _pos) elseif path[0:1] ==# '~/' return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') " handle relative paths - elseif empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') + elseif empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') || (path =~ '^\.\w\+') return map( \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' diff --git a/test/feature/completion.vader b/test/feature/completion.vader index 34b70d3..e1d6cbc 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -55,6 +55,15 @@ Execute (prompt: relative path, whitespace only): Execute (prompt: relative path, leading word chars): AssertEqual grepper#complete_files('x f', v:null, v:null), ['x foo/'] +Execute (prompt: relative path, hidden files): + AssertEqual grepper#complete_files('x .f', '', v:null), ['x .foo'] + +Execute (prompt: relative path, nested hidden dirs): + AssertEqual grepper#complete_files('x foo/.b', '', v:null), ['x foo/.bar/'] + +Execute (prompt: relative path, nested hidden files): + AssertEqual grepper#complete_files('x foo/bar/.b', '', v:null), ['x foo/bar/.baz'] + Execute (prompt: sub-path, ./ exact match): AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/'] diff --git a/test/include/completion/.foo b/test/include/completion/.foo new file mode 100644 index 0000000..e69de29 diff --git a/test/include/completion/foo/bar/.baz b/test/include/completion/foo/bar/.baz new file mode 100644 index 0000000..e69de29 From b998ee683e79cabd837b8453aa942dfe80aa1ce1 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Wed, 20 Apr 2022 14:40:18 +0100 Subject: [PATCH 07/13] Minor refactoring of relative path completion This is the default case, it doesn't need an explicit condition --- plugin/grepper.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 4340300..bd0c590 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -241,18 +241,18 @@ function! grepper#complete_files(lead, _line, _pos) " handle paths in $HOME (~/foo) elseif path[0:1] ==# '~/' return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') - " handle relative paths - elseif empty(path) || (path =~ '\s$') || (path =~ '^\s*\w\+') || (path =~ '^\.\w\+') - return map( - \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), - \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' - \ ) " handle sub paths elseif path =~ '^.\/' return map(split(globpath('.'.s:slash, path[2:].'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') " handle absolute paths elseif path[0] == '/' return map(split(globpath(s:slash, path.'*'), '\n'), 'head . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') + " handle relative paths + else + return map( + \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), + \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' + \ ) endif endfunction From c0bb964a6a98c99fb7ea7246e829b36b30329c31 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Wed, 20 Apr 2022 14:41:42 +0100 Subject: [PATCH 08/13] Handle sub-paths as relative paths when completing Don't need to differentiate any more as we are stripping out the leading dot and slash from the resulting glob matches. Tests still pass :-) --- plugin/grepper.vim | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index bd0c590..b72b8c5 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -241,9 +241,6 @@ function! grepper#complete_files(lead, _line, _pos) " handle paths in $HOME (~/foo) elseif path[0:1] ==# '~/' return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') - " handle sub paths - elseif path =~ '^.\/' - return map(split(globpath('.'.s:slash, path[2:].'*'), '\n'), 'head . "." . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') " handle absolute paths elseif path[0] == '/' return map(split(globpath(s:slash, path.'*'), '\n'), 'head . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') From 7b7416ada9a89ebf055c5aeec722049bad59da56 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Fri, 6 May 2022 15:59:33 +0100 Subject: [PATCH 09/13] Remove file/path completion for Grepper command As far as I can tell, this does not make sense for the Grepper command. The command opens the prompt, from which path completion is performed. I suspect the right thing to do here is complete with all flags, but it seems sensible to leave that for another commit to make changes clear. --- plugin/grepper.vim | 2 +- test/feature/completion.vader | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index b72b8c5..199bbb7 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -228,7 +228,7 @@ function! grepper#complete(lead, line, _pos) abort return filter(map(sort(copy(g:grepper.tools)), 'v:val." "'), \ 'empty(a:lead) || v:val[:strlen(a:lead)-1] ==# a:lead') else - return grepper#complete_files(a:lead, 0, 0) + return [] endif endfunction diff --git a/test/feature/completion.vader b/test/feature/completion.vader index e1d6cbc..0295c9a 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -37,6 +37,9 @@ Execute (command: flags, -tool options): Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 +Execute (command: flags, default, no completion): + Assert len(grepper#complete('', '', v:null)) == 0 + Execute (prompt: path, tilde expansion): AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME] From c9c53439c7521036855a8e2c46478f74c7fdf292 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Mon, 9 May 2022 07:37:07 +0100 Subject: [PATCH 10/13] Add trailing slash when completing lonely tilde e.g. complete ~ with /home/foo/ rather than /home/foo, as vim does --- plugin/grepper.vim | 2 +- test/feature/completion.vader | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 199bbb7..81604b1 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -237,7 +237,7 @@ function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) " tilde expansion to $HOME if path ==# '~' - return [head . $HOME] + return [head . $HOME . '/'] " handle paths in $HOME (~/foo) elseif path[0:1] ==# '~/' return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') diff --git a/test/feature/completion.vader b/test/feature/completion.vader index 0295c9a..ab9d661 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -41,7 +41,7 @@ Execute (command: flags, default, no completion): Assert len(grepper#complete('', '', v:null)) == 0 Execute (prompt: path, tilde expansion): - AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME] + AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME.'/'] Execute (prompt: path, relative to $HOME): let home = $HOME From edd064a45c57cee3837e54077943a7da169ed0ac Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Fri, 13 May 2022 06:14:34 +0100 Subject: [PATCH 11/13] Use Vim built in function for file completions --- plugin/grepper.vim | 19 ++++--------------- test/feature/completion.vader | 3 +++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 81604b1..ba91ed1 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -235,22 +235,11 @@ endfunction " grepper#complete_files() {{{2 function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) - " tilde expansion to $HOME - if path ==# '~' - return [head . $HOME . '/'] - " handle paths in $HOME (~/foo) - elseif path[0:1] ==# '~/' - return map(split(globpath($HOME, path[2:].'*'), '\n'), 'head . "~" . v:val['.len($HOME).':] . (isdirectory(v:val) ? s:slash : "")') - " handle absolute paths - elseif path[0] == '/' - return map(split(globpath(s:slash, path.'*'), '\n'), 'head . v:val[1:] . (isdirectory(v:val) ? s:slash : "")') - " handle relative paths - else - return map( - \ map(split(globpath('.'.s:slash, path.'*'), '\n'), "substitute(v:val, '^\\s*.'.s:slash, '', '')"), - \ 'head . v:val . (isdirectory(v:val) ? s:slash : "")' - \ ) + if path[0:1] ==# '~/' + " undo tilde expansion, shorter completions + return map(getcompletion(path, 'file'), "head . substitute(v:val, $HOME, '~', '')") endif + return map(getcompletion(path, 'file'), 'head . v:val') endfunction " s:extract_path() {{{2 diff --git a/test/feature/completion.vader b/test/feature/completion.vader index ab9d661..c6be3fc 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -41,7 +41,10 @@ Execute (command: flags, default, no completion): Assert len(grepper#complete('', '', v:null)) == 0 Execute (prompt: path, tilde expansion): + let home = $HOME + let $HOME = getcwd() AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME.'/'] + let $HOME = home Execute (prompt: path, relative to $HOME): let home = $HOME From 674dc75cd57684ea2723cd381cbc1391efa1468a Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Fri, 13 May 2022 06:25:44 +0100 Subject: [PATCH 12/13] Further simplify file completion Remove custom handling of paths relative to ~/, unnecessary --- plugin/grepper.vim | 4 ---- test/feature/completion.vader | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index ba91ed1..8dec0a1 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -235,10 +235,6 @@ endfunction " grepper#complete_files() {{{2 function! grepper#complete_files(lead, _line, _pos) let [head, path] = s:extract_path(a:lead) - if path[0:1] ==# '~/' - " undo tilde expansion, shorter completions - return map(getcompletion(path, 'file'), "head . substitute(v:val, $HOME, '~', '')") - endif return map(getcompletion(path, 'file'), 'head . v:val') endfunction diff --git a/test/feature/completion.vader b/test/feature/completion.vader index c6be3fc..998c997 100644 --- a/test/feature/completion.vader +++ b/test/feature/completion.vader @@ -49,7 +49,7 @@ Execute (prompt: path, tilde expansion): Execute (prompt: path, relative to $HOME): let home = $HOME let $HOME = getcwd() - AssertEqual grepper#complete_files('x ~/f', v:null, v:null), ['x ~/foo/'] + AssertEqual grepper#complete_files('x ~/f', v:null, v:null), ['x '.$HOME.'/foo/'] let $HOME = home Execute (prompt: relative path, empty string): From e78901e83817f2c64fa6b4d0209fd2e4b7223c11 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Fri, 13 May 2022 06:26:50 +0100 Subject: [PATCH 13/13] Remove now unnecessary vader tests for completion File completion is now delegated to Vim's built in getcompletion() function, and the tests for grepper#complete arguably unnecessary. --- test/feature/completion.vader | 88 ---------------------------- test/include/completion/.foo | 0 test/include/completion/foo/bar/.baz | 0 test/include/completion/foo/bar/baz | 0 4 files changed, 88 deletions(-) delete mode 100644 test/feature/completion.vader delete mode 100644 test/include/completion/.foo delete mode 100644 test/include/completion/foo/bar/.baz delete mode 100644 test/include/completion/foo/bar/baz diff --git a/test/feature/completion.vader b/test/feature/completion.vader deleted file mode 100644 index 998c997..0000000 --- a/test/feature/completion.vader +++ /dev/null @@ -1,88 +0,0 @@ -Before: - enew! - only! - cd include/completion - let w:testing = 1 - -After: - cd - - -Execute (command: flags, match all): - Assert len(grepper#complete('-', '', v:null)) > 3 - AssertEqual count(grepper#complete('-', '', v:null), '-cword '), 1 - AssertEqual count(grepper#complete('-', '', v:null), '-grepprg '), 1 - AssertEqual count(grepper#complete('-', '', v:null), '-tool '), 1 - -Execute (command: flags, match one): - AssertEqual grepper#complete('-noquickf', '', v:null), ['-noquickfix '] - -Execute (command: flags, match some): - Assert len(grepper#complete('-no', '', v:null)) > 2 - AssertEqual count(grepper#complete('-no', '', v:null), '-switch '), 0 - AssertEqual count(grepper#complete('-no', '', v:null), '-noswitch '), 1 - -Execute (command: flags, -dir options): - Assert len(grepper#complete('', 'Grepper -dir ', v:null)) > 2 - AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'cwd '), 1 - AssertEqual count(grepper#complete('', 'Grepper -dir ', v:null), 'repo '), 1 - -Execute (command: flags, -stop completion): - Assert grepper#complete('', 'Grepper -stop ', v:null)[0] =~# '\d\+' - -Execute (command: flags, -tool options): - Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 - AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 - -Execute (command: flags, -tool options): - Assert len(grepper#complete('', 'Grepper -tool ', v:null)) > 1 - AssertEqual count(grepper#complete('', 'Grepper -tool ', v:null), 'grep '), 1 - -Execute (command: flags, default, no completion): - Assert len(grepper#complete('', '', v:null)) == 0 - -Execute (prompt: path, tilde expansion): - let home = $HOME - let $HOME = getcwd() - AssertEqual grepper#complete_files('x ~', v:null, v:null), ['x '.$HOME.'/'] - let $HOME = home - -Execute (prompt: path, relative to $HOME): - let home = $HOME - let $HOME = getcwd() - AssertEqual grepper#complete_files('x ~/f', v:null, v:null), ['x '.$HOME.'/foo/'] - let $HOME = home - -Execute (prompt: relative path, empty string): - AssertEqual grepper#complete_files('x ', v:null, v:null), ['x foo/'] - -Execute (prompt: relative path, whitespace only): - AssertEqual grepper#complete_files('x ', v:null, v:null), ['x foo/'] - -Execute (prompt: relative path, leading word chars): - AssertEqual grepper#complete_files('x f', v:null, v:null), ['x foo/'] - -Execute (prompt: relative path, hidden files): - AssertEqual grepper#complete_files('x .f', '', v:null), ['x .foo'] - -Execute (prompt: relative path, nested hidden dirs): - AssertEqual grepper#complete_files('x foo/.b', '', v:null), ['x foo/.bar/'] - -Execute (prompt: relative path, nested hidden files): - AssertEqual grepper#complete_files('x foo/bar/.b', '', v:null), ['x foo/bar/.baz'] - -Execute (prompt: sub-path, ./ exact match): - AssertEqual grepper#complete_files('x ./', v:null, v:null), ['x ./foo/'] - -Execute (prompt: sub-path, ./ and word chars): - AssertEqual grepper#complete_files('x ./f', v:null, v:null), ['x ./foo/'] - -Execute (prompt: nested sub-path, e.g. ./foo/): - AssertEqual grepper#complete_files('x ./foo/', v:null, v:null), ['x ./foo/bar/'] - -Execute (prompt: absolute path, / exact match): - AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /bin/'), 1 - AssertEqual count(grepper#complete_files('x /', v:null, v:null), 'x /var/'), 1 - -Execute (prompt: absolute path, / and word chars): - AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /bin/'), 1 - AssertEqual count(grepper#complete_files('x /b', v:null, v:null), 'x /var/'), 0 diff --git a/test/include/completion/.foo b/test/include/completion/.foo deleted file mode 100644 index e69de29..0000000 diff --git a/test/include/completion/foo/bar/.baz b/test/include/completion/foo/bar/.baz deleted file mode 100644 index e69de29..0000000 diff --git a/test/include/completion/foo/bar/baz b/test/include/completion/foo/bar/baz deleted file mode 100644 index e69de29..0000000