[Git] Fix annotation lookup for collapsed directories#1185
Open
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
Open
[Git] Fix annotation lookup for collapsed directories#1185rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
Conversation
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.
710499f to
478b335
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
treemacs--apply-annotations-deferredused the parent button's:keyto look up the git cache, but the cache is keyed by:path(via theroot/pathparameter):keyretains the original path while:pathis updated to the deep path bytreemacs--flatten-dirs, causing the lookup to misstreemacs-git-unmodified-faceregardless of their actual git statuspathparameter directly, which is already the correct cache keyReproducing
src/graph/wheresrccontains onlygraph)git adda new file under the collapsed path (so it has index-only statusA)treemacs-git-unmodified-faceinstead oftreemacs-git-added-face(ht-get (ht-get treemacs--git-cache "<parent-dir>") "<file-path>")returns the right face(treemacs-get-annotation "<file-path>")returnsnilAffects all git modes (simple, extended, deferred) equally since the timer runs unconditionally.