Browse Source

'main': Restore support for zsh-4.3.10 and older.

zsh older than workers/28418 (zsh revision 23bdfc7fd2)
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.
pull/283/head
Daniel Shahaf 8 years ago
parent
commit
bc7f8ea433
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      highlighters/main/main-highlighter.zsh

+ 2
- 4
highlighters/main/main-highlighter.zsh View File

@ -235,13 +235,11 @@ _zsh_highlight_main_highlighter()
# indistinguishable from 'echo foo echo bar' (one command with three # indistinguishable from 'echo foo echo bar' (one command with three
# words for arguments). # words for arguments).
local needle=$'[;\n]' 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 )) (( start_pos += offset - 1 ))
(( end_pos = start_pos + $#arg )) (( end_pos = start_pos + $#arg ))
else 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})) ((end_pos=$start_pos+${#arg}))
fi fi

Loading…
Cancel
Save