Skip to content

[Git] Fix annotation lookup for collapsed directories#1185

Open
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
rain-64:collapsed-directories-lookup
Open

[Git] Fix annotation lookup for collapsed directories#1185
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
rain-64:collapsed-directories-lookup

Conversation

@rain-64
Copy link
Copy Markdown

@rain-64 rain-64 commented Apr 9, 2026

Summary

  • treemacs--apply-annotations-deferred used the parent button's :key to look up the git cache, but the cache is keyed by :path (via the root/path parameter)
  • For collapsed/flattened directories, :key retains the original path while :path is updated to the deep path by treemacs--flatten-dirs, causing the lookup to miss
  • All child nodes are left with treemacs-git-unmodified-face regardless of their actual git status
  • Fix: use the path parameter directly, which is already the correct cache key

Reproducing

  1. Have a directory structure where treemacs collapses directories (e.g., src/graph/ where src contains only graph)
  2. git add a new file under the collapsed path (so it has index-only status A)
  3. Expand the collapsed directory in treemacs — the file shows as treemacs-git-unmodified-face instead of treemacs-git-added-face
  4. Verify the cache is correct: (ht-get (ht-get treemacs--git-cache "<parent-dir>") "<file-path>") returns the right face
  5. Verify annotations are never created: (treemacs-get-annotation "<file-path>") returns nil

Affects all git modes (simple, extended, deferred) equally since the timer runs unconditionally.

When directories are collapsed/flattened, `treemacs--flatten-dirs'
updates the button's `:path' but not its `:key'.
`treemacs--apply-annotations-deferred' used `:key' to look up the git
cache, which is keyed by `:path' (via the `root'/`path' parameter).
This caused the lookup to miss for collapsed directories, leaving all
child nodes with `treemacs-git-unmodified-face'.

Use the `path' parameter directly, which is already the correct cache
key — consistent with how the cache is populated in both
`treemacs--create-branch' and the deferred-mode branch of this same
function.
@rain-64 rain-64 force-pushed the collapsed-directories-lookup branch from 710499f to 478b335 Compare April 10, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant