summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-10-30 16:59:04 +0000
committerPeter Stephenson <pws@zsh.org>2015-10-30 16:59:41 +0000
commit1eef57b3d15af235430ad2b5e2940ded375e69d2 (patch)
tree09266b2ddafc28e8646cbb9fe3e1346dc6299943 /Functions
parent26614ad0e05d99e974742276b710a4afff79e8b2 (diff)
downloadzsh-1eef57b3d15af235430ad2b5e2940ded375e69d2.tar.gz
zsh-1eef57b3d15af235430ad2b5e2940ded375e69d2.tar.xz
zsh-1eef57b3d15af235430ad2b5e2940ded375e69d2.zip
37027: allow subword context to discriminate between words
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Zle/match-word-context9
1 files changed, 7 insertions, 2 deletions
diff --git a/Functions/Zle/match-word-context b/Functions/Zle/match-word-context
index 7f1154498..8793483f4 100644
--- a/Functions/Zle/match-word-context
+++ b/Functions/Zle/match-word-context
@@ -7,7 +7,7 @@ setopt extendedglob
 
 local -a worcon bufwords
 local pat tag lastword word backword forword
-integer iword
+integer iword between
 
 zstyle -a $curcontext word-context worcon || return 0
 
@@ -25,13 +25,18 @@ if [[ $lastword = ${bufwords[iword]} ]]; then
   # If the word immediately left of the cursor is complete,
   # we're not on it for forward operations.
   forword=${bufwords[iword+1]}
+  # If, furthermore, we're on whitespace, then we're between words.
+  # It can't be significant whitespace because the previous word is complete.
+  [[ $RBUFFER[1] = [[:space:]] ]] && between=1
 else
   # We're on a word.
   forword=${bufwords[iword]}
 fi
 backword=${bufwords[iword]}
 
-if [[ $curcontext = *back* ]]; then
+if [[ between -ne 0 && $curcontext = *between* ]]; then
+  word=' '
+elif [[ $curcontext = *back* ]]; then
   word=$backword
 else
   word=$forword