Merge pull request #272 from psprint/master
Optimization: -1 is extra computation of string length internally
This commit is contained in:
		
						commit
						e938825a85
					
				|  | @ -125,6 +125,7 @@ _zsh_highlight_main_highlighter() | ||||||
|   typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW |   typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW | ||||||
|   local -a options_to_set # used in callees |   local -a options_to_set # used in callees | ||||||
|   local buf="$PREBUFFER$BUFFER" |   local buf="$PREBUFFER$BUFFER" | ||||||
|  |   integer len="${#buf}" | ||||||
|   region_highlight=() |   region_highlight=() | ||||||
| 
 | 
 | ||||||
|   if (( path_dirs_was_set )); then |   if (( path_dirs_was_set )); then | ||||||
|  | @ -234,11 +235,13 @@ _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]' | ||||||
|       integer offset=${${buf[start_pos+1,-1]}[(i)$needle]} |       # 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]} | ||||||
|       (( start_pos += offset - 1 )) |       (( start_pos += offset - 1 )) | ||||||
|       (( end_pos = start_pos + $#arg )) |       (( end_pos = start_pos + $#arg )) | ||||||
|     else |     else | ||||||
|       ((start_pos+=${#buf[$start_pos+1,-1]}-${#${buf[$start_pos+1,-1]##([[:space:]]|\\[[:space:]])#}})) |       ((start_pos+=(len-start_pos)-${#${${buf: start_pos: len-start_pos}##([[:space:]]|\\[[:space:]])#}})) | ||||||
|       ((end_pos=$start_pos+${#arg})) |       ((end_pos=$start_pos+${#arg})) | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue