Skip to content

Commit

Permalink
'main': Restore support for zsh-4.3.10 and older.
Browse files Browse the repository at this point in the history
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 3cb58fd, "Optimization: -1 is
extra computation of string length internally".

Fixes zsh-users/zsh-syntax-highlighting#279.
  • Loading branch information
danielshahaf committed Mar 23, 2016
1 parent cb02451 commit bc7f8ea
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit bc7f8ea

Please sign in to comment.