Skip to content

Commit 3954cc7

Browse files
committed
scm: remember worktree visibility across restarts
When a repository is discovered after the initial loading phase has ended (e.g. git worktrees detected by git.detectWorktrees), the SCM view service was ignoring the persisted visibility state and making the repository visible by default. This forced users to re-hide any worktrees they had previously deselected on every restart. This change keeps consulting the persisted state for repositories added after loading finished: if the repository was explicitly hidden in the previous session, it stays hidden when it is re-discovered. Fixes microsoft#271554
1 parent 1da74cc commit 3954cc7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vs/workbench/contrib/scm/browser/scmViewService.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,17 @@ export class SCMViewService implements ISCMViewService {
405405
this.didSelectRepository = true;
406406
}
407407
}
408+
} else if (this.previousState && this.didFinishLoadingRepositories.get()) {
409+
// Even after the initial loading phase has ended, repositories
410+
// that are discovered later (e.g. git worktrees) should respect
411+
// the previously persisted hidden state so that the user does
412+
// not have to hide them again on every restart.
413+
const index = this.previousState.all.indexOf(getProviderStorageKey(repository.provider));
414+
if (index !== -1 && this.previousState.visible.indexOf(index) === -1) {
415+
this.insertRepositoryView(this._repositories, repositoryView);
416+
this._onDidChangeRepositories.fire({ added: Iterable.empty(), removed: Iterable.empty() });
417+
return;
418+
}
408419
}
409420

410421
if (this.selectionModeConfig.get() === ISCMRepositorySelectionMode.Multiple || !this._repositories.find(r => r.selectionIndex !== -1)) {

0 commit comments

Comments
 (0)