Skip to content

Commit

Permalink
don't set totally local options, we need to inherit octalzeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
xPMo committed Mar 14, 2020
1 parent 38e8dad commit 0ad20fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions functions/.vi-increment
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env zsh
# take numeric prefix to command
zle -f vichange
emulate -L zsh
setopt extendedglob
setopt localoptions noksharrays extendedglob
# start|end: hex/other number start or end
# odec_(start|end): the start or end of the longest matching [[:digit:]] string
# base: the value determines what type of number is matched
Expand Down Expand Up @@ -44,7 +43,7 @@ else
end=$reply[4]
fi
case $base in
cbin0) # no cbases-0x[hex]-like option, have to manually strip prefix
cbin) # no cbases-0x[hex]-like option, have to manually strip prefix
ans=$(( [#2] BUFFER[start,end] + d ))
sans="${ans#'2#'}"
(( start += 2 ))
Expand All @@ -58,8 +57,9 @@ chex)
esac
if (( zero )); then
local -Z $((1 + end - start )) ans
if [[ $base != chex && $options[cbases] = on && $options[octalzeroes] = on ]]; then
if [[ -z $base && $options[cbases] = on && $options[octalzeroes] = on ]]; then
local -i 8 ans
[[ $ans[1] = 0 ]] || sans=0$ans
fi
fi
BUFFER="$BUFFER[1,start-1]${sans:=$ans}$BUFFER[end+1,$#BUFFER]"
Expand Down
2 changes: 1 addition & 1 deletion functions/.vi-increment::select-number
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ local k v line=$BUFFER[lstart,lend]
# Is this after the last bin/hex number?
if ((p[ostart] > p[end])); then
p[base]=''
((p[start] = p[ostart], p[end] = ${${line[p[start],-1]}[(i)[^[:digit:]_]]} - 1 ))
((p[start] = p[ostart], p[end] = p[start] + ${${line:$p[ostart]}[(i)[^[:digit:]_]]} - 1))
if [[ $line[p[start]] = 0 ]]; then
p[zero]=1
fi
Expand Down

0 comments on commit 0ad20fb

Please sign in to comment.