From 59fbdda64c21dd9e911329f31fbbedc69123865b Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 26 Oct 2015 08:26:35 +0000 Subject: [PATCH] main: Refresh highlighting upon accept-* widgets (accept-line et al). Use this to remove [path_prefix] highlighting during accept-* widgets. This causes ": file.tx" to remove the underline from "file.tx", like ": file.tx" already does. (Assume 'file.txt' exists.) --- highlighters/main/main-highlighter.zsh | 7 +++++-- highlighters/main/test-data/path_prefix2.zsh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 42d19cc..166ae57 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -59,7 +59,9 @@ # Whether the highlighter should be called or not. _zsh_highlight_main_highlighter_predicate() { - _zsh_highlight_buffer_modified + # accept-* may trigger removal of path_prefix highlighting + [[ $WIDGET == accept-* ]] || + _zsh_highlight_buffer_modified } # Helper to deal with tokens crossing line boundaries. @@ -280,7 +282,8 @@ _zsh_highlight_main_highlighter_check_path() [[ ! -e ${expanded_path:h} ]] && return 1 # If this word ends the buffer, check if it's the prefix of a valid path. - if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]]; then + if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]] && + [[ $WIDGET != accept-* ]]; then local -a tmp tmp=( ${expanded_path}*(N) ) (( $#tmp > 0 )) && style_override=path_prefix && return 0 diff --git a/highlighters/main/test-data/path_prefix2.zsh b/highlighters/main/test-data/path_prefix2.zsh index 13d8c9e..a1974eb 100644 --- a/highlighters/main/test-data/path_prefix2.zsh +++ b/highlighters/main/test-data/path_prefix2.zsh @@ -35,5 +35,5 @@ BUFFER='ls /bin/s' WIDGET=accept-line expected_region_highlight=( - "4 9 $ZSH_HIGHLIGHT_STYLES[default] 'implemented by next commit'" # /bin/s + "4 9 $ZSH_HIGHLIGHT_STYLES[default]" # /bin/s )