Skip to content

fix: re-evaluate active editor repository when SCM repositories change#308700

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/scm-active-repo-context-keys
Open

fix: re-evaluate active editor repository when SCM repositories change#308700
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/scm-active-repo-context-keys

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

Summary

  • Fixes ${activeRepositoryName} and ${activeRepositoryBranchName} window title variables appearing blank in multi-root workspaces
  • The _activeEditorRepositoryObs derived observable only tracked active editor changes but not SCM repository additions/removals. When a repository was registered after the editor was already open, the derived would cache undefined and never re-evaluate.
  • Added a repositoriesObs observable that tracks onDidAddRepository / onDidRemoveRepository events and reads it inside the derived to trigger re-evaluation when repositories change.

Fixes #304129

Test plan

  • Open a multi-root workspace with multiple Git repositories
  • Set window.title to ${rootNameShort} - ${activeRepositoryName} or ${rootNameShort} - ${activeRepositoryBranchName}
  • Verify the active repository name and branch name appear correctly in the window title
  • Open files from different repositories and verify the title updates accordingly
  • Restart VS Code and verify the variables resolve correctly on startup

The _activeEditorRepositoryObs derived observable only re-evaluated when
the active editor changed. It used scmService.getRepository() which is a
plain method call not tracked by the observable system. This meant that if
a repository was registered after the active editor was already open, the
derived would not re-evaluate and the active repository would remain
undefined.

This fix adds a repositoriesObs observable that tracks repository
additions/removals, and reads it inside the derived so that the active
editor's repository is re-evaluated when repositories change. This ensures
that window title variables like ${activeRepositoryName} and
${activeRepositoryBranchName} are correctly populated.

Fixes microsoft#304129
@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:

  • src/vs/workbench/contrib/scm/browser/scmViewService.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.

activeRepository* window title components seem broken

2 participants