Skip to content

git: clear blame information when switching to editor with no diff info#309179

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/git-blame-clear-on-non-git-editor
Open

git: clear blame information when switching to editor with no diff info#309179
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/git-blame-clear-on-non-git-editor

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

When switching from a git-tracked file to a file with no SCM diff information (e.g. a file outside any repository, a virtual document, or an untitled file), _updateTextEditorBlameInformation returned early because textEditor.diffInformation was undefined. The two conditions were ORed together in a single guard:

if (!textEditor.diffInformation || textEditor !== window.activeTextEditor) {
    return;
}

This meant the "no diff info" path returned without clearing textEditorBlameInformation, leaving the previous file's blame decoration and status-bar item visible in the new editor.

Fix: Separate the two guards so each has the correct side-effect:

  1. Race-condition guard (textEditor !== window.activeTextEditor) — return silently; don't touch state, since we're processing a stale event.
  2. No diff info (!textEditor.diffInformation) — set textEditorBlameInformation = undefined before returning, so decorations and the status-bar are cleared.

Files changed

  • extensions/git/src/blame.ts — _updateTextEditorBlameInformation()

When switching from a git-tracked file to a file with no SCM
diff information (e.g. a file outside any repository, or a
virtual/read-only document), _updateTextEditorBlameInformation
returned early because `textEditor.diffInformation` was undefined.
This left the previous file's blame decoration and status-bar item
visible for the new editor.

Separate the two early-exit conditions so that the race-condition
guard (textEditor !== activeTextEditor) still returns silently, while
the missing-diff-info case explicitly clears textEditorBlameInformation
before returning.
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/blame.ts

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.

2 participants