diff --git a/history-search-multi-word b/history-search-multi-word index 5d4cce2..68bd5e1 100644 --- a/history-search-multi-word +++ b/history-search-multi-word @@ -96,34 +96,33 @@ _hsmw_main() { # also preceeded by two spaces disp_list=( "${(@)disp_list/(#m)*/ ${MATCH[1,COLUMNS-8]}}" ) - local nl=$'\n' - local entry="${disp_list[on_page_idx]}" - entry[1]='>' - disp_list[on_page_idx]="$entry" - # - # Detect where "> .." entry starts + # Detect where "> .." entry starts, add the ">" mark # local txt_before="${(F)${(@)disp_list[1,on_page_idx-1]}}" + local for_syntax_text="${(F)disp_list}" + local entry="${disp_list[on_page_idx]}" + entry[1]='>' + disp_list[on_page_idx]="$entry" + local text="${(F)disp_list}" # # Colorify # local preamble=$'\n'"Searching for: $BUFFER"$'\n'"Element #$__hsmw_hcw_index of $max_index"$'\n' - local text="${(F)disp_list}" integer offset=${#preamble}+${#BUFFER} - POSTDISPLAY="$preamble$text" region_highlight=( ) -hsmw-highlight-init - -hsmw-highlight-process "$text" + -hsmw-highlight-process "$for_syntax_text" region_highlight=( "${region_highlight[@]//(#b)([[:digit:]]##)/$(( ${match[1]} + offset ))}" ) region_highlight+=( "$(( offset + ${#txt_before} )) $(( offset + ${#txt_before} + ${#entry} + 1 )) underline" ) if [ -n "$colsearch_pattern" ]; then + local nl=$'\n' # Following line is taken from Zaw (GH zsh-users/zaw) – license is named "Zaw", it is in LICENSE file region_highlight+=( "${(f)${(S)text//*(#bi)(${~colsearch_pattern})/$(( offset + mbegin[1] - 1 )) $(( offset + mend[1] )) ${__hsmw_hl_color}${nl}}%$nl*}" ) fi