Only refresh if the URI is different to avoid unnecessary reloads#4854
Only refresh if the URI is different to avoid unnecessary reloads#4854wolfsilver wants to merge 2 commits intogitkraken:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes the file history tracker to avoid unnecessary reloads by only triggering changes when the active editor's document URI differs from the currently tracked URI.
Key Changes:
- Added a URI equality check in
onActiveEditorChangedto prevent redundant updates when the same file remains active
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Only trigger change if the editor's URI is different from the current one | ||
| if (!editor?.document?.uri || (editor?.document?.uri && areUrisEqual(editor.document.uri, this.uri))) { |
There was a problem hiding this comment.
This check may cause incorrect behavior when the editor has no document URI. The function should still call triggerChange() when editor exists but editor.document.uri is undefined or null, as this represents a state change from having a valid URI. The current logic returns early in this case, which might prevent necessary UI updates. Consider only checking the URI equality when both URIs are present.
| // Only trigger change if the editor's URI is different from the current one | |
| if (!editor?.document?.uri || (editor?.document?.uri && areUrisEqual(editor.document.uri, this.uri))) { | |
| // Only trigger change if the editor's URI is the same as the current one | |
| const editorUri = editor?.document?.uri; | |
| if (editorUri != null && this.uri != null && areUrisEqual(editorUri, this.uri)) { |
There was a problem hiding this comment.
During switching, the editor?.document?.uri may be temporarily unavailable.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
c2a0ab6 to
131fac3
Compare
Fixes #4853
Description
onActiveEditorChangedlogic infileHistoryTrackerNode.tsto only trigger a change if the editor's document URI is different from the node's current URI, reducing redundant updates.Checklist
Fixes $XXX -orCloses #XXX -prefix to auto-close the issue that your PR addresses