Skip to content

Conversation

@wolfsilver
Copy link

Fixes #4853

Description

  • Editor change optimization:
    • Updated the onActiveEditorChanged logic in fileHistoryTrackerNode.ts to only trigger a change if the editor's document URI is different from the node's current URI, reducing redundant updates.

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

Copilot AI review requested due to automatic review settings January 7, 2026 04:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onActiveEditorChanged to prevent redundant updates when the same file remains active

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 157 to 158
// 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))) {
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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)) {

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During switching, the editor?.document?.uri may be temporarily unavailable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only refresh if the URI is different to avoid unnecessary reloads

1 participant