Bug fix: infinite loop when the current working directory doesn't exist#751
Bug fix: infinite loop when the current working directory doesn't exist#751romkatv wants to merge 1 commit intozsh-users:masterfrom
Conversation
To reproduce:
% mkdir /tmp/foo
% cd /tmp/foo
% rmdir /tmp/foo
% exec zsh -f
% source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Press 'a' and zle will hang.
|
Thanks. Triaged. Milestoned 0.9.0 because it's not a regression, though realistically I'd like to see it in 0.8.0 or, failing that, 0.8.1. No time to test or review right now, sorry. |
|
@romkatv thank you for the minimal reproducer. Thoughts on diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index e59c61c..24d0b75 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -1210,6 +1210,9 @@ _zsh_highlight_main_highlighter_check_path()
# Check if this is a blacklisted path
if [[ $expanded_path[1] == / ]]; then
tmp_path=$expanded_path
+ elif ! [[ -e . ]]; then
+ # If $PWD doesn't exist, relative paths are impossible
+ return 1
else
tmp_path=$PWD/$expanded_path
fiAm I missing an edge case? |
This is not blocking me in any way (I never delete my current directory), so take your time.
Your version of the patch has a race condition (so it can still go into an infinite loop) and doesn't colorize any files if the current directory doesn't exist (even though some files could still be colorized). That said, I've very little emotional investment in this PR one way or another, so if you decide to apply your patch I won't argue. |
To reproduce:
Press a and zle will hang.