zsh-workers
 help / color / mirror / code / Atom feed
add5b70f0c9fd72215546122a1dc9cf224f71b27 blob 1718 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
# Text object for matching characters between matching pairs of brackets
#
# So for example, given (( i+1 )), the vi command ci( will change
# all the text between matching colons.
#
# The following is an example of how to enable this:
#     autoload -U select-bracketed
#     zle -N select-bracketed
#     for m in visual viopp; do
#	for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
#	  bindkey -M $m $c select-bracketed
#	done
#     done

setopt localoptions nocprecedences noksharrays

local style=${${1:-$KEYS}[1]} matching="(){}[]<>bbBB"
local -i find=${NUMERIC:-1} idx=${matching[(I)[${${1:-$KEYS}[2]}]]}%9
(( idx )) || return 1 # no corresponding closing bracket
local lmatch=${matching[1 + ((idx-1) & ~1)]}
local rmatch=${matching[1 + ((idx-1) | 1)]}
local -i start=CURSOR+1 end=CURSOR+1 rfind=find

[[ $BUFFER[start] = "$rmatch" ]] && (( start--, end-- ))
if (( REGION_ACTIVE  && MARK != CURSOR)); then
  (( MARK < CURSOR && (start=end=MARK+1) ))
  local -i origstart=start-1
  [[ $style = i ]] && (( origstart-- ))
fi

while (( find )); do
  for (( ; find && start; --start )); do
    case $BUFFER[start] in
      "$lmatch") (( find-- )) ;;
      "$rmatch") (( find++ )) ;;
    esac
  done

  (( find )) && return 1 # opening bracket not found

  while (( rfind && end++ < $#BUFFER )); do
    case $BUFFER[end] in
      "$lmatch") (( rfind++ )) ;;
      "$rmatch") (( rfind-- )) ;;
    esac
  done

  (( rfind )) && return 1 # closing bracket not found

  (( REGION_ACTIVE && MARK != CURSOR && start >= origstart &&
    ( find=rfind=${NUMERIC:-1} ) ))
done

[[ $style = i ]] && (( start++, end-- ))
(( REGION_ACTIVE = !!REGION_ACTIVE ))
[[ $KEYMAP = vicmd ]] && (( REGION_ACTIVE && end-- ))
MARK=$start
CURSOR=$end
debug log:

solving add5b70f0c9fd72215 ...
found add5b70f0c9fd72215 in https://inbox.vuxu.org/zsh-workers/389ebb53e6d5b8cfe9985af3d41574679e5ce4b8.1541547033.git.joeypabalinas@gmail.com/
found d467bb8047466faa32 in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 d467bb8047466faa323f12790bc086c317643755	Functions/Zle/select-bracketed

applying [1/1] https://inbox.vuxu.org/zsh-workers/389ebb53e6d5b8cfe9985af3d41574679e5ce4b8.1541547033.git.joeypabalinas@gmail.com/
diff --git a/Functions/Zle/select-bracketed b/Functions/Zle/select-bracketed
index d467bb8047466faa32..add5b70f0c9fd72215 100644

Checking patch Functions/Zle/select-bracketed...
Applied patch Functions/Zle/select-bracketed cleanly.

index at:
100644 add5b70f0c9fd72215546122a1dc9cf224f71b27	Functions/Zle/select-bracketed

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).