Change:
this.scmViewService.onDidFocusRepository(this.focusRepository, this, this.disposables); this.focusRepository(this.scmViewService.focusedRepository); <del> editorService.onDidActiveEditorChange(this.tryFocusRepositoryBasedOnActiveEditor, this, this.disposables); </del> <ins> editorService.onDidActiveEditorChange(() => this.tryFocusRepositoryBasedOnActiveEditor(), this, this.disposables); </ins> this.renderActivityCount(); } <del> private tryFocusRepositoryBasedOnActiveEditor(): boolean { </del> <ins> private tryFocusRepositoryBasedOnActiveEditor(repositories: Iterable<ISCMRepository> = this.scmService.repositories): boolean { </ins> const resource = EditorResourceAccessor.getOriginalUri(this.editorService.activeEditor); if (!resource) {

Discussion:
Issue Type: <bBug</bI'm working with a multi-root workspace where each project has its own git repository. On startup VSCode restores my last session with all the open files and the tree-view updates correctly, selecting the file which has the focus in the editor. But the SCM status bar does not switch to the right repository, but shows the status of the repository from the first folder in the workspace. Steps to reproduce (or see the attached screencast): VSCode with a (multi-root)-workspace with two projects (projecta, projectb) the focus of files correcly selects the corresponding repository VSCode while the focus is on a file from the second project (projectb) VSCode restores the last session (open editor tabs, tree-view, etc.) correctly SCM status bar stays with the repository projecta, although the file in focus belongs to projectb Expected behaviour: I would expect that when restoring a session, the correct repository to the file that is in focus in the editor would be selected automatically. The problem here is only occurs when restoring the session. As soon as I actively change the focus in the editor, the associated repositories are correctly selected. https://user- VS Code version: Code 1.62.2 (, 2021-11-11T20:51:30.084Z) OS version: Linux x64 5.4.0-54-generic Restricted Mode: No <details<summarySystem Info</summary </details<details<summaryExtensions (9)</summaryExtensionVersion ------ gitlens11.6.1 vscode-docker1.18.0 python2021.11. vscode-pylance2021.11.1 remote-containers0.205.2 remote-ssh0.66.1 remote-ssh-edit0.66.1 hexeditor1.8.2 material-theme3.13.2 </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
I think this is just a refresh issue with the SCM status bar. When I open VSCode, the status bar assumes that I am working on the first repository in my workspace. However, all open editors only refer to files from another repository (the file tree is also expanded correctly).

Sometimes for example, the status bar shows a branch that I already deleted a few days ago, but since it assumes the wrong repository, it suggests publishing the "new" branch.
Any updates on this? I'm facing the same issue on Mac and find it quite annoying.
sorry for not getting back to you on this until now. I do have a repro for this, and I have couple of ideas on how to address this problem, though there is some complexity around the way repositories are discovered. I will try to have a fix for this later this week or next week.
<!-- AUTHORVERIFICATIONREQUEST --This bug has been fixed in the latest release of ! you can help us out by commenting if things are now working as expected. If things still don't seem right, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!