From bc7f8ea433adf3efd71a3e950e9a8dec846a1171 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 23 Mar 2016 01:32:44 +0000 Subject: [PATCH] 'main': Restore support for zsh-4.3.10 and older. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zsh older than workers/28418 (zsh revision 23bdfc7fd2a012d5205ed22d18eb39e41c8fbc95) doesn't support the «${name:offset:length}» syntax. Therefore, use the older «$name[start,end]» syntax instead. Followup to 3cb58fd7d7b9e42067ffcf24892114dc2c9b26e4, "Optimization: -1 is extra computation of string length internally". Fixes zsh-users/zsh-syntax-highlighting#279. --- highlighters/main/main-highlighter.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index a6465a6..2f43255 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -235,13 +235,11 @@ _zsh_highlight_main_highlighter() # indistinguishable from 'echo foo echo bar' (one command with three # words for arguments). local needle=$'[;\n]' - # Len-start_pos drops one character, but it should do it, as start_pos - # starts from next, not from "start_pos", character - integer offset=${${buf: start_pos: len-start_pos}[(i)$needle]} + integer offset=${${buf[start_pos+1,len]}[(i)$needle]} (( start_pos += offset - 1 )) (( end_pos = start_pos + $#arg )) else - ((start_pos+=(len-start_pos)-${#${${buf: start_pos: len-start_pos}##([[:space:]]|\\[[:space:]])#}})) + ((start_pos+=(len-start_pos)-${#${${buf[start_pos+1,len]}##([[:space:]]|\\[[:space:]])#}})) ((end_pos=$start_pos+${#arg})) fi