From ef8ba84c3a76c768f49a0bdd2a620b2f53c2478a Mon Sep 17 00:00:00 2001 From: Aloxaf Date: Mon, 28 Feb 2022 11:19:23 +0800 Subject: [PATCH] fix: correct highlighting logic for hex color codes (e.g., `#fff` & `#ffffff`) (#18) - fixes an issue of incorrectly parsing certain strings as hex color codes --- fast-highlight | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast-highlight b/fast-highlight index 13a1f5a..5327eb2 100644 --- a/fast-highlight +++ b/fast-highlight @@ -1148,7 +1148,7 @@ typeset -ga ZLAST_COMMANDS fi fi fi - if [[ $__arg = (#b)*'#'(([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])|([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))* || $__arg = (#b)*'rgb('(([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)))* ]]; then + if [[ $__arg = (#b)*'#'(([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])|([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))(|[^[:alnum:]]*) || $__arg = (#b)*'rgb('(([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)))* ]]; then if [[ -n $match[2] ]]; then if [[ $match[2] = ?? || $match[3] = ?? || $match[4] = ?? ]]; then (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#${(l:2::0:)match[2]}${(l:2::0:)match[3]}${(l:2::0:)match[4]}")