Ver a proveniência

'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 há 8 anos
ascendente
cometimento
bc7f8ea433
1 ficheiros alterados com 2 adições e 4 eliminações
  1. +2
    -4
      highlighters/main/main-highlighter.zsh

+ 2
- 4
highlighters/main/main-highlighter.zsh Ver ficheiro

@ -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

Carregando…
Cancelar
Guardar