Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] select-bracketed: set nocprecedences to force native precedence ordering
- X-seq: zsh-workers 43779
- From: Joey Pabalinas <joeypabalinas@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] select-bracketed: set nocprecedences to force native precedence ordering
- Date: Tue, 6 Nov 2018 13:34:10 -1000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=UayTHOmg+eECT3c6aWx34mszBBtw/GbRNtJbMViqaR8=; b=VpiNDCg9ksv0PgaIj2Kg/JDhaozXmOc+vJXZSbIlo0zAiuJjHmeu2dtO7Q+Beyg3mW uxJ8tMQRkbb+zV5XoSFLaiaUYa8ZBetzJ4DvWl0eIHYn31TlxGLfuuXFVPkflY/rrJIO DDoNeDPcPbmN1J+PVDnSUz9icCvNpp3lBZIlo1Ti/eNYDwgwoucecjcIazc/LOXerm39 8aNQV0xMOKdLtEbFlaal9tSYeo3CzvBTyvrzb/HnGf10tIOmWt6PlWvT55/b3L4WM8/h wHFEcMNd5VCVA517Ypyd35rMDyb5RHZ5EOA8jumJ8WkJBWaEFr4RDAJ91f8v/cTI5XLX 7zcw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
With cprecedences set, expressions like `1 + (idx-1) & ~1` are evaluated as
`(1 + (idx-1)) & ~1` instead of the intended `1 + ((idx-1) & ~1)`. Set the
nocprecedences option and add clarifying parenthesis to the ambiguous
expressions.
Signed-off-by: Joey Pabalinas <joeypabalinas@xxxxxxxxx>
---
Functions/Zle/select-bracketed | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Functions/Zle/select-bracketed b/Functions/Zle/select-bracketed
index d467bb8047466faa32..add5b70f0c9fd72215 100644
--- a/Functions/Zle/select-bracketed
+++ b/Functions/Zle/select-bracketed
@@ -10,17 +10,17 @@
# for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
# bindkey -M $m $c select-bracketed
# done
# done
-setopt localoptions noksharrays
+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 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) ))
--
Cheers,
Joey Pabalinas
Messages sorted by:
Reverse Date,
Date,
Thread,
Author