From b911af200c4ed4085a76d3e0a12458ccba2d3b3f Mon Sep 17 00:00:00 2001 From: zhaoyunfeng Date: Thu, 28 Jun 2018 13:58:09 +0800 Subject: [PATCH] [zsh-completion] Fix prefix extraction when triggers start with ';' --- shell/completion.zsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell/completion.zsh b/shell/completion.zsh index ed1f279..509f581 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -158,6 +158,12 @@ fzf-completion() { trigger=${FZF_COMPLETION_TRIGGER-'**'} [ -z "$trigger" -a ${LBUFFER[-1]} = ' ' ] && tokens+=("") + # When the trigger starts with ';', it becomes a separate token + if [[ ${LBUFFER} = *"${tokens[-2]}${tokens[-1]}" ]]; then + tokens[-2]="${tokens[-2]}${tokens[-1]}" + tokens=(${tokens[0,-2]}) + fi + tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} # Kill completion (do not require trigger sequence) if [ $cmd = kill -a ${LBUFFER[-1]} = ' ' ]; then