Don't highlight syntax elements as paths.
Without this, redirections, history expansions, and command separators would be matched by path_approx. A test case is simply LBUFFER="<" RBUFFER="" (highlighted as redirection with this fix and as path_approx without it). Fixes zsh-users/zsh-syntax-highlighting#204.
This commit is contained in:
parent
4ec821b2b1
commit
79e8c2dd48
@ -178,16 +178,18 @@ _zsh_highlight_main_highlighter()
|
|||||||
# (For array assignments, the command doesn't start until the ")" token.)
|
# (For array assignments, the command doesn't start until the ")" token.)
|
||||||
new_expression=true; highlight_glob=true
|
new_expression=true; highlight_glob=true
|
||||||
fi
|
fi
|
||||||
elif _zsh_highlight_main_highlighter_check_path; then
|
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
|
||||||
elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then
|
elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
||||||
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
||||||
redirection=true
|
redirection=true
|
||||||
|
else
|
||||||
|
if _zsh_highlight_main_highlighter_check_path; then
|
||||||
|
style=$ZSH_HIGHLIGHT_STYLES[path]
|
||||||
else
|
else
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
|
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -212,17 +214,20 @@ _zsh_highlight_main_highlighter()
|
|||||||
;;
|
;;
|
||||||
'`'*) style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
|
'`'*) style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
|
||||||
*[*?]*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
|
*[*?]*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
|
||||||
*) if _zsh_highlight_main_highlighter_check_path; then
|
*) if false; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
|
||||||
elif [[ $arg[0,1] = $histchars[0,1] ]]; then
|
elif [[ $arg[0,1] = $histchars[0,1] ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
||||||
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[commandseparator]
|
style=$ZSH_HIGHLIGHT_STYLES[commandseparator]
|
||||||
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
||||||
|
else
|
||||||
|
if _zsh_highlight_main_highlighter_check_path; then
|
||||||
|
style=$ZSH_HIGHLIGHT_STYLES[path]
|
||||||
else
|
else
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[default]
|
style=$ZSH_HIGHLIGHT_STYLES[default]
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user