diff options
Diffstat (limited to 'src/vs/workbench/contrib/scm/browser/activity.ts')
-rw-r--r-- | src/vs/workbench/contrib/scm/browser/activity.ts | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/vs/workbench/contrib/scm/browser/activity.ts b/src/vs/workbench/contrib/scm/browser/activity.ts index 399e48dcce8..38a53b72c60 100644 --- a/src/vs/workbench/contrib/scm/browser/activity.ts +++ b/src/vs/workbench/contrib/scm/browser/activity.ts @@ -18,6 +18,7 @@ import { EditorResourceAccessor } from 'vs/workbench/common/editor'; import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'; import { stripIcons } from 'vs/base/common/iconLabels'; import { Schemas } from 'vs/base/common/network'; +import { Iterable } from 'vs/base/common/iterator'; function getCount(repository: ISCMRepository): number { if (typeof repository.provider.count === 'number') { @@ -116,7 +117,7 @@ export class SCMStatusController implements IWorkbenchContribution { return; } - this.focusRepository(this.scmService.repositories[0]); + this.focusRepository(Iterable.first(this.scmService.repositories)); } private focusRepository(repository: ISCMRepository | undefined): void { @@ -148,7 +149,8 @@ export class SCMStatusController implements IWorkbenchContribution { : repository.provider.label; const disposables = new DisposableStore(); - for (const command of commands) { + for (let index = 0; index < commands.length; index++) { + const command = commands[index]; const tooltip = `${label}${command.tooltip ? ` - ${command.tooltip}` : ''}`; let ariaLabel = stripIcons(command.title).trim(); @@ -160,7 +162,7 @@ export class SCMStatusController implements IWorkbenchContribution { ariaLabel: `${ariaLabel}${command.tooltip ? ` - ${command.tooltip}` : ''}`, tooltip, command: command.id ? command : undefined - }, 'status.scm', MainThreadStatusBarAlignment.LEFT, 10000)); + }, `status.scm.${index}`, MainThreadStatusBarAlignment.LEFT, 10000)); } this.statusBarDisposable = disposables; @@ -172,7 +174,7 @@ export class SCMStatusController implements IWorkbenchContribution { let count = 0; if (countBadgeType === 'all') { - count = this.scmService.repositories.reduce((r, repository) => r + getCount(repository), 0); + count = Iterable.reduce(this.scmService.repositories, (r, repository) => r + getCount(repository), 0); } else if (countBadgeType === 'focused' && this.focusedRepository) { count = getCount(this.focusedRepository); } @@ -198,7 +200,7 @@ export class SCMStatusController implements IWorkbenchContribution { export class SCMActiveResourceContextKeyController implements IWorkbenchContribution { private activeResourceHasChangesContextKey: IContextKey<boolean>; - private activeResourceRepositoryContextKey: IContextKey<ISCMRepository | undefined>; + private activeResourceRepositoryContextKey: IContextKey<string | undefined>; private disposables = new DisposableStore(); private repositoryDisposables = new Set<IDisposable>(); @@ -239,11 +241,12 @@ export class SCMActiveResourceContextKeyController implements IWorkbenchContribu const activeResource = EditorResourceAccessor.getOriginalUri(this.editorService.activeEditor); if (activeResource?.scheme === Schemas.file || activeResource?.scheme === Schemas.vscodeRemote) { - const activeResourceRepository = this.scmService.repositories - .find(r => r.provider.rootUri && - this.uriIdentityService.extUri.isEqualOrParent(activeResource, r.provider.rootUri)); + const activeResourceRepository = Iterable.find( + this.scmService.repositories, + r => Boolean(r.provider.rootUri && this.uriIdentityService.extUri.isEqualOrParent(activeResource, r.provider.rootUri)) + ); - this.activeResourceRepositoryContextKey.set(activeResourceRepository); + this.activeResourceRepositoryContextKey.set(activeResourceRepository?.id); for (const resourceGroup of activeResourceRepository?.provider.groups.elements ?? []) { if (resourceGroup.elements |