fix: always call initSyntax on mount to prevent lost highlighting#64
Open
voglster wants to merge 1 commit intoMrWangJustToDo:mainfrom
Open
fix: always call initSyntax on mount to prevent lost highlighting#64voglster wants to merge 1 commit intoMrWangJustToDo:mainfrom
voglster wants to merge 1 commit intoMrWangJustToDo:mainfrom
Conversation
Syntax highlighting is lost when DiffView is unmounted and remounted with the same file content. The global File cache causes initRaw() → #syncSyntax() to copy highlighter metadata from cached File objects into a fresh DiffFile, making the syntax effect's guard condition evaluate to false and skip initSyntax() entirely. initSyntax() is already idempotent — when syntax is initialized with a matching highlighter, it efficiently re-syncs syntax line references without recomputing. Remove the guard condition and always call initSyntax() when highlighting is enabled. Fixes MrWangJustToDo#63
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
DiffViewis unmounted and remounted with the same file contentinitSyntax()is already idempotent, so calling it unconditionally is safe and efficientRoot Cause
The global
Filecache in@git-diff-view/corecausesinitRaw()→#syncSyntax()to copy highlighter metadata (highlighterName,highlighterType) from cachedFileobjects into a freshDiffFile. The syntax effect then sees matching metadata and skipsinitSyntax()entirely, leaving syntax lines asnull.Fixes #63