Skip to content

Commit 79e8c2d

Browse files
committed
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 #204.
1 parent 4ec821b commit 79e8c2d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,17 @@ _zsh_highlight_main_highlighter()
178178
# (For array assignments, the command doesn't start until the ")" token.)
179179
new_expression=true; highlight_glob=true
180180
fi
181-
elif _zsh_highlight_main_highlighter_check_path; then
182-
style=$ZSH_HIGHLIGHT_STYLES[path]
183181
elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then
184182
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
185183
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
186184
style=$ZSH_HIGHLIGHT_STYLES[redirection]
187185
redirection=true
188186
else
189-
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
187+
if _zsh_highlight_main_highlighter_check_path; then
188+
style=$ZSH_HIGHLIGHT_STYLES[path]
189+
else
190+
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
191+
fi
190192
fi
191193
;;
192194
esac
@@ -212,16 +214,19 @@ _zsh_highlight_main_highlighter()
212214
;;
213215
'`'*) style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
214216
*[*?]*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
215-
*) if _zsh_highlight_main_highlighter_check_path; then
216-
style=$ZSH_HIGHLIGHT_STYLES[path]
217+
*) if false; then
217218
elif [[ $arg[0,1] = $histchars[0,1] ]]; then
218219
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
219220
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
220221
style=$ZSH_HIGHLIGHT_STYLES[commandseparator]
221222
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
222223
style=$ZSH_HIGHLIGHT_STYLES[redirection]
223224
else
224-
style=$ZSH_HIGHLIGHT_STYLES[default]
225+
if _zsh_highlight_main_highlighter_check_path; then
226+
style=$ZSH_HIGHLIGHT_STYLES[path]
227+
else
228+
style=$ZSH_HIGHLIGHT_STYLES[default]
229+
fi
225230
fi
226231
;;
227232
esac

0 commit comments

Comments
 (0)