From 7078904f6a076e8fca94d1bd4cefe014466489d6 Mon Sep 17 00:00:00 2001 From: Mark Woods Date: Tue, 19 Apr 2022 15:19:48 +0100 Subject: [PATCH] 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..923f1b7 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('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/']