IDEA-387204 bookmarks: sync line numbers after document reload#3461
Open
fvoidhe wants to merge 1 commit intoJetBrains:masterfrom
Open
IDEA-387204 bookmarks: sync line numbers after document reload#3461fvoidhe wants to merge 1 commit intoJetBrains:masterfrom
fvoidhe wants to merge 1 commit intoJetBrains:masterfrom
Conversation
When a file is reloaded from disk, `beforeFileContentReload` adds the document to `reloadingDocs`, causing `afterDocumentChange` to skip all intermediate notifications during the reload — which is intentional (IJPL-62074). However, once `fileContentReloaded` fires and the document is removed from the set, `afterDocumentChange` was never called to reconcile the final state. During reload the platform updates RangeMarkers to reflect new line positions, so the editor gutter shows bookmark icons at the correct (shifted) lines. But `LineBookmarkImpl.line` was never updated, leaving the stored line number stale. This caused the Bookmarks tool window to display the old line number while the gutter marker appeared at the new one. Fix: call `afterDocumentChange(document)` at the end of `fileContentReloaded`, after removing the document from `reloadingDocs`, so the guard no longer blocks it and bookmark line numbers are resynced with the post-reload RangeMarker positions.
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.
When a file is reloaded from disk,
beforeFileContentReloadadds the document toreloadingDocs, causingafterDocumentChangeto skip all intermediate notifications during the reload — which is intentional (IJPL-62074). However, oncefileContentReloadedfires and the document is removed from the set,afterDocumentChangewas never called to reconcile the final state.During reload the platform updates RangeMarkers to reflect new line positions, so the editor gutter shows bookmark icons at the correct (shifted) lines. But
LineBookmarkImpl.linewas never updated, leaving the stored line number stale. This caused the Bookmarks tool window to display the old line number while the gutter marker appeared at the new one.Fix: call
afterDocumentChange(document)at the end offileContentReloaded, after removing the document fromreloadingDocs, so the guard no longer blocks it and bookmark line numbers are resynced with the post-reload RangeMarker positions.Note
Low Risk
Low risk: a small change to bookmark synchronization that runs only after
fileContentReloaded, with minimal surface area outside the bookmarks subsystem.Overview
Fixes stale line numbers for line bookmarks after a document is reloaded from disk.
LineBookmarkProvidernow callsafterDocumentChange(document)at the end ofFileDocumentManagerListener.fileContentReloaded, ensuring storedLineBookmarkImpl.linevalues are reconciled with the post-reloadRangeMarkerpositions (so the Bookmarks tool window matches gutter markers).Written by Cursor Bugbot for commit 05d2f5b. This will update automatically on new commits. Configure here.