Conversation
1. Fixed BaseServer.remove() Bug (BaseServer.js:149) Before: Used lookup result as key for deletion After: Correctly uses the key string returned by _documentKey() This fix ensures LiveHTMLDocuments are actually removed from the cache when closed, preventing memory leaks and stale references. 2. Fixed _markText() Function (HTMLInstrumentation.js:823-847) ✩ PRIMARY FIX Key change: Now detects when an editor has no marks and allows marking even when fullBuild = false The logic now: - Checks if the editor has any existing tagID marks - Allows marking if: DOM is a full build OR editor has no marks - Still refuses to re-mark if editor already has marks and DOM is stale (preserves safety) This solves the core issue where switching editor panes or reopening documents would leave the new editor without marks. 3. Added Defensive Fallback (HTMLInstrumentation.js:758-769) Added a safety net that: - Detects when markCache is empty but DOM has nodes - Automatically forces re-marking if this happens - Logs a warning so we know it triggered How This Fixes the Issue The error "couldn't find existing mark for tagID" occurred because: 1. Document edited -> cache has fullBuild = false 2. User switches panes -> new editor has NO marks 3. Old _markText() refused to mark the new editor 4. generateInstrumentedHTML() tried to use non-existent marks -> ERROR Now: - _markText() detects the editor has no marks and marks it anyway (even with fullBuild = false) - If marks are somehow still missing, the defensive fallback catches it - BaseServer properly cleans up old documents
|
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.



Before: Used lookup result as key for deletion
After: Correctly uses the key string returned by _documentKey()
This fix ensures LiveHTMLDocuments are actually removed from the cache when
closed, preventing memory leaks and stale references.
Key change: Now detects when an editor has no marks and allows marking even when fullBuild = false
The logic now:
This solves the core issue where switching editor panes or reopening documents would
leave the new editor without marks.
Added a safety net that:
How This Fixes the Issue
The error "couldn't find existing mark for tagID" occurred because:
Now: