From 1e204d36c1fab9884f65618ccca019d8cd5f9386 Mon Sep 17 00:00:00 2001 From: kj-sh604 Date: Wed, 16 Jul 2025 22:10:52 -0400 Subject: refactor: update `zsh-fast-syntax-highlighting` plugin --- .../fast-string-highlight | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to '.config/shell/zsh-fast-syntax-highlighting/fast-string-highlight') diff --git a/.config/shell/zsh-fast-syntax-highlighting/fast-string-highlight b/.config/shell/zsh-fast-syntax-highlighting/fast-string-highlight index dd8eb4f..cc8d860 100644 --- a/.config/shell/zsh-fast-syntax-highlighting/fast-string-highlight +++ b/.config/shell/zsh-fast-syntax-highlighting/fast-string-highlight @@ -15,18 +15,18 @@ function -fast-highlight-string-process { pair_map=( "(" ")" "{" "}" "[" "]" ) - while [[ $_mybuf = (#b)[^"{}()[]\\\"'"]#((["({[]})\"'"])|[\\](*))(*) ]]; do - [[ -n ${match[3]} ]] && { - __idx+=${mbegin[1]} + while [[ $_mybuf = (#b)([^"{}()[]\\\"'"]#)((["({[]})\"'"])|[\\](*))(*) ]]; do + if [[ -n ${match[4]} ]] { + __idx+=${mbegin[2]} - [[ $__quoting = \' ]] && _mybuf=${match[3]} || { _mybuf=${match[3]:1}; (( ++ __idx )); } - } || { - __idx+=${mbegin[1]} + [[ $__quoting = \' ]] && _mybuf=${match[4]} || { _mybuf=${match[4]:1}; (( ++ __idx )); } + } else { + __idx+=${mbegin[2]} [[ -z $__quoting && -z ${_FAST_COMPLEX_BRACKETS[(r)$((__idx-${#PREBUFFER}-1))]} ]] && { - if [[ ${match[1]} = ["({["] ]]; then + if [[ ${match[2]} = ["({["] ]]; then pos_to_level[$__idx]=$(( ++__level )) level_to_pos[$__level]=$__idx - elif [[ ${match[1]} = ["]})"] ]]; then + elif [[ ${match[2]} = ["]})"] ]]; then if (( __level > 0 )); then __pair_idx=${level_to_pos[$__level]} pos_to_level[$__idx]=$(( __level -- )) @@ -40,10 +40,21 @@ function -fast-highlight-string-process { fi } - [[ ${match[1]} = \" && $__quoting != \' ]] && { [[ $__quoting = '"' ]] && __quoting="" || __quoting='"'; } - [[ ${match[1]} = \' && $__quoting != \" ]] && { [[ $__quoting = "'" ]] && __quoting="" || __quoting="'"; } - - _mybuf=${match[4]} + if [[ ${match[2]} = \" && $__quoting != \' ]] { + [[ $__quoting = '"' ]] && __quoting="" || __quoting='"'; + } + if [[ ${match[2]} = \' && $__quoting != \" ]] { + if [[ $__quoting = ("'"|"$'") ]] { + __quoting="" + } else { + if [[ $match[1] = *\$ ]] { + __quoting="\$'"; + } else { + __quoting="'"; + } + } + } + _mybuf=${match[5]} } done -- cgit v1.2.3