From 1f9abf61f68fced2e86e8b5b504d617718531471 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 1 Dec 2020 11:20:22 +0800 Subject: [PATCH] highlight: fix unhighlighted tilde expansions "~+" --- lib/core-syntax.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh index ef17475b..6b24446a 100644 --- a/lib/core-syntax.sh +++ b/lib/core-syntax.sh @@ -2397,8 +2397,8 @@ function ble/syntax:bash/check-tilde-expansion { if ((tilde_enabled)); then local chars="${_ble_syntax_bash_chars[CTX_ARGI]}/:" ble/syntax:bash/cclass/update/reorder chars - local delimiters="$_ble_syntax_bash_IFS;|&()<>" - local rex='^(~[^'$chars']*)([^'$delimiters'/:]?)'; [[ $tail =~ $rex ]] + local delimiters="$_ble_syntax_bash_IFS;|&)<>" + local rex='^(~\+|~[^'$chars']*)([^'$delimiters'/:]?)'; [[ $tail =~ $rex ]] local str=${BASH_REMATCH[1]} local path attr=$ctx @@ -2413,6 +2413,12 @@ function ble/syntax:bash/check-tilde-expansion { ble/util/assert 'ble/util/unlocal tail; [[ $tail == ":~"* ]]' ble/syntax/parse/nest-pop fi + else + # ~+ で始まってかつ有効なチルダ展開ではない時 ~ まで後退 (#D1424) + if [[ $str == '~+' ]]; then + ble/syntax/parse/set-lookahead 3 + str='~' + fi fi ((_ble_syntax_attr[i]=attr,i+=${#str})) else