Skip to content

main highlighter does not highlight hashed directories with autocd and cdablevars set #930

Open
@zaidhaan

Description

@zaidhaan

Screenshot:
image

I was able to fix it with this

diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index f691051..505fe3c 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -196,6 +196,8 @@ _zsh_highlight_main__type() {
       REPLY=builtin
     elif (( $+commands[(e)$1] )); then
       REPLY=command
+    elif (( $+nameddirs[(e)$1] )) && [[ -x $nameddirs[$1] ]]; then
+      REPLY=hashed
     # None of the special hashes had a match, so fall back to 'type -w', for
     # forward compatibility with future versions of zsh that may add new command
     # types.

And get these results:
image

Though I'm not sure if that's the right approach, or whether that addresses it in the right place.

Additionally, cdablevars appears to also not be respected (not sure whether this should be moved to a new issue but these both seem related so I'll keep it here)
image

Even with my patch above, it only is able to partially addresses this, since it appears that after entering into that directory, only then does it update the hash table (and once the hash table is updated, it gets highlighted, as shown below)
image


  • zsh 5.9 (x86_64-pc-linux-gnu)
  • zsh-syntax-highlighting commit 1386f12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions