mirror of
https://github.com/Microsoft/vscode
synced 2024-09-12 21:24:38 +00:00
SCM - consistent fallback for count calculation (#214337)
This commit is contained in:
parent
ab9a1286f2
commit
af675232d0
|
@ -21,13 +21,10 @@ import { Iterable } from 'vs/base/common/iterator';
|
|||
import { ITitleService } from 'vs/workbench/services/title/browser/titleService';
|
||||
import { IEditorGroupContextKeyProvider, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { getRepositoryResourceCount } from 'vs/workbench/contrib/scm/browser/util';
|
||||
|
||||
function getCount(repository: ISCMRepository): number {
|
||||
if (typeof repository.provider.count === 'number') {
|
||||
return repository.provider.count;
|
||||
} else {
|
||||
return repository.provider.groups.reduce<number>((r, g) => r + g.resources.length, 0);
|
||||
}
|
||||
return repository.provider.count ?? getRepositoryResourceCount(repository.provider);
|
||||
}
|
||||
|
||||
export class SCMStatusController implements IWorkbenchContribution {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
|
|||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ActionRunner, IAction } from 'vs/base/common/actions';
|
||||
import { connectPrimaryMenu, isSCMRepository, StatusBarAction } from './util';
|
||||
import { connectPrimaryMenu, getRepositoryResourceCount, isSCMRepository, StatusBarAction } from './util';
|
||||
import { ITreeNode } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
|
||||
import { FuzzyScore } from 'vs/base/common/filters';
|
||||
|
@ -117,7 +117,7 @@ export class RepositoryRenderer implements ICompressibleTreeRenderer<ISCMReposit
|
|||
}));
|
||||
|
||||
templateData.elementDisposables.add(autorun(reader => {
|
||||
const count = repository.provider.countObs.read(reader) ?? 0;
|
||||
const count = repository.provider.countObs.read(reader) ?? getRepositoryResourceCount(repository.provider);
|
||||
templateData.countContainer.setAttribute('data-count', String(count));
|
||||
templateData.count.setCount(count);
|
||||
}));
|
||||
|
|
|
@ -173,3 +173,7 @@ export function getActionViewItemProvider(instaService: IInstantiationService):
|
|||
export function getProviderKey(provider: ISCMProvider): string {
|
||||
return `${provider.contextValue}:${provider.label}${provider.rootUri ? `:${provider.rootUri.toString()}` : ''}`;
|
||||
}
|
||||
|
||||
export function getRepositoryResourceCount(provider: ISCMProvider): number {
|
||||
return provider.groups.reduce<number>((r, g) => r + g.resources.length, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue