Skip to content

Commit

Permalink
Fixes to default selected SCM code
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
  • Loading branch information
westbury committed Oct 30, 2019
1 parent 8814c20 commit a873de0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 7 additions & 2 deletions packages/git/src/browser/git-repository-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,15 @@ export class GitRepositoryProvider {
}

/**
* Sets or un-sets the repository.
* Sets the selected repository, but do nothing if the given repository is not a Git repository
* registered with the SCM service. We must be sure not to clear the selection if the selected
* repository is managed by an SCM other than Git.
*/
set selectedRepository(repository: Repository | undefined) {
this.scmService.selectedRepository = this.toScmRepository(repository);
const scmRepository = this.toScmRepository(repository);
if (scmRepository) {
this.scmService.selectedRepository = scmRepository;
}
}

get selectedScmRepository(): GitScmRepository | undefined {
Expand Down
5 changes: 1 addition & 4 deletions packages/scm/src/browser/scm-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ export class ScmService {
}
this.toDisposeOnSelected.dispose();
this._selectedRepository = repository;
if (!repository) {
this._selectedRepository = this._repositories.values().next().value;
}
this.updateContextKeys();
if (this._selectedRepository) {
this.toDisposeOnSelected.push(this._selectedRepository.onDidChange(() => this.updateContextKeys()));
Expand All @@ -91,7 +88,7 @@ export class ScmService {
dispose.bind(repository)();
this.onDidRemoveRepositoryEmitter.fire(repository);
if (this._selectedRepository === repository) {
this.selectedRepository = undefined;
this.selectedRepository = this._repositories.values().next().value;
}
};
this._repositories.set(key, repository);
Expand Down

0 comments on commit a873de0

Please sign in to comment.