Commit 584ccb71 authored by Frank Terbeck's avatar Frank Terbeck

jump-to-delim: Fix a couple of corner cases

The CURSOR-- adjustment in the backward case is correct, but only if the
function is in upto mode. In onto and across mode, it breaks stuff.
parent b810f82a
......@@ -25,9 +25,12 @@ function jumpToDelim () {
(( onto == 2 )) && (( CURSOR += ${#delim} ))
fi
else
# Move back a character: If we're already on an instance of the
# delimiter, we want to be able to move off of it to the next instance.
(( CURSOR-- ))
if (( onto == 0 )); then
# Move back a character: If we're already on an instance of the
# delimiter, we want to be able to move off of it to the next
# instance.
(( CURSOR-- ))
fi
if [[ $LBUFFER != *${delim}* ]]; then
(( CURSOR++ ))
return 1
......
......@@ -74,6 +74,12 @@ zpty_run 'bindkey -r "^xb"
zpty_run 'bindkey "^xb" jump-onto-prev-/
bindkey "^xf" jump-onto-next-/'
zle-test-define 'No delimiter in buffer (onto slash)'
zletest $'foo.bar.baz.zsh.scm\C-e\C-xb' | zle-results CURSOR=19
zle-test-define 'One delimiter directly to the left, going left (onto slash)'
zletest $'foo/\C-e\C-xb' | zle-results CURSOR=3
zle-test-define 'One level back onto slash'
zletest $'foo/bar/baz/zsh.scm\C-e\C-xb' | zle-results CURSOR=11
......@@ -99,6 +105,9 @@ zpty_run 'bindkey -r "^xb"
zpty_run 'bindkey "^xb" jump-across-prev-/
bindkey "^xf" jump-across-next-/'
zle-test-define 'One delimiter directly to the left, going left (across slash)'
zletest $'foo/\C-e\C-xb' | zle-results CURSOR=2
zle-test-define 'One level back across slash'
zletest $'foo/bar/baz/zsh.scm\C-e\C-xb' | zle-results CURSOR=10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment