summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-05-12 01:40:44 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-05-12 01:40:44 +0900
commit26d2af5ee8b254b5a150728aac428762a6f6e92b (patch)
treeeb91cecfae56f5d375036e05c44f533e449cf8da
parent2b61dc6557b3ecdca7f8641b0c7c4d55e03d725b (diff)
[zsh-completion] Respect backslash-escaped spaces (#230)
-rw-r--r--shell/completion.zsh5
-rw-r--r--test/test_go.rb21
2 files changed, 22 insertions, 4 deletions
diff --git a/shell/completion.zsh b/shell/completion.zsh
index 299826c1..99cc112c 100644
--- a/shell/completion.zsh
+++ b/shell/completion.zsh
@@ -12,7 +12,7 @@
_fzf_path_completion() {
local base lbuf find_opts fzf_opts suffix tail fzf dir leftover matches nnm
- base=$1
+ base=${(Q)1}
lbuf=$2
find_opts=$3
fzf_opts=$4
@@ -102,7 +102,8 @@ fzf-completion() {
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
# http://zsh.sourceforge.net/FAQ/zshfaq03.html
- tokens=(${=LBUFFER})
+ # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
+ tokens=(${(z)LBUFFER})
if [ ${#tokens} -lt 1 ]; then
eval "zle ${fzf_default_completion:-expand-or-complete}"
return
diff --git a/test/test_go.rb b/test/test_go.rb
index b6b37dc6..b6be9e04 100644
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -582,7 +582,12 @@ end
module CompletionTest
def test_file_completion
- tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}; touch ~/fzf-home no~such~user', :Enter
+ FileUtils.mkdir_p '/tmp/fzf-test'
+ FileUtils.mkdir_p '/tmp/fzf test'
+ (1..100).each { |i| FileUtils.touch "/tmp/fzf-test/#{i}" }
+ ['no~such~user', '/tmp/fzf test/foobar', '~/fzf-home'].each do |f|
+ FileUtils.touch File.expand_path(f)
+ end
tmux.prepare
tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0
tmux.until(1) { |lines| lines.item_count > 0 }
@@ -614,8 +619,20 @@ module CompletionTest
tmux.send_keys 'C-L'
lines[-1].end_with?('no~such~user')
end
+
+ # /tmp/fzf\ test**<TAB>
+ tmux.send_keys 'C-u'
+ tmux.send_keys 'cat /tmp/fzf\ test/**', :Tab, pane: 0
+ tmux.until(1) { |lines| lines.item_count > 0 }
+ tmux.send_keys :Enter
+ tmux.until do |lines|
+ tmux.send_keys 'C-L'
+ lines[-1].end_with?('/tmp/fzf\ test/foobar')
+ end
ensure
- File.unlink 'no~such~user'
+ ['/tmp/fzf-test', '/tmp/fzf test', '~/fzf-home', 'no~such~user'].each do |f|
+ FileUtils.rm_rf File.expand_path(f)
+ end
end
def test_dir_completion