ignore untracked in git change count badge
This commit is contained in:
parent
1fad0d5893
commit
4d07969cf9
2 changed files with 21 additions and 4 deletions
|
@ -26,6 +26,7 @@ import output = require('vs/workbench/parts/output/common/output');
|
|||
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
|
||||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import confregistry = require('vs/platform/configuration/common/configurationRegistry');
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import quickopen = require('vs/workbench/browser/quickopen');
|
||||
import editorcontrib = require('vs/workbench/parts/git/browser/gitEditorContributions');
|
||||
import {IActivityService, ProgressBadge, NumberBadge} from 'vs/workbench/services/activity/common/activityService';
|
||||
|
@ -52,6 +53,7 @@ export class StatusUpdater implements ext.IWorkbenchContribution
|
|||
private eventService: IEventService;
|
||||
private activityService:IActivityService;
|
||||
private messageService:IMessageService;
|
||||
private configurationService:IConfigurationService;
|
||||
private progressBadgeDelayer: async.Delayer<void>;
|
||||
private toDispose: lifecycle.IDisposable[];
|
||||
|
||||
|
@ -59,12 +61,14 @@ export class StatusUpdater implements ext.IWorkbenchContribution
|
|||
@IGitService gitService: IGitService,
|
||||
@IEventService eventService: IEventService,
|
||||
@IActivityService activityService: IActivityService,
|
||||
@IMessageService messageService: IMessageService
|
||||
@IMessageService messageService: IMessageService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
this.gitService = gitService;
|
||||
this.eventService = eventService;
|
||||
this.activityService = activityService;
|
||||
this.messageService = messageService;
|
||||
this.configurationService = configurationService;
|
||||
|
||||
this.progressBadgeDelayer = new async.Delayer<void>(200);
|
||||
|
||||
|
@ -86,9 +90,21 @@ export class StatusUpdater implements ext.IWorkbenchContribution
|
|||
}
|
||||
|
||||
private showChangesBadge(): void {
|
||||
var count = this.gitService.getModel().getStatus().getGroups().map((g1: git.IStatusGroup) => {
|
||||
return g1.all().length;
|
||||
}).reduce((a, b) => a + b, 0);
|
||||
const config = this.configurationService.getConfiguration<git.IGitConfiguration>('git');
|
||||
|
||||
// only use the filter version of the map callback if filtering by file status is really necessary
|
||||
var mapper = (g1: git.IStatusGroup) => {
|
||||
return g1.all().filter((f1: git.IFileStatus) => {
|
||||
return f1.getStatus() !== git.Status.UNTRACKED;
|
||||
}).length;
|
||||
};
|
||||
|
||||
// no need to filter by file status if we count both tracked and untracked files
|
||||
if (config.countUntracked) {
|
||||
mapper = (g1: git.IStatusGroup) => g1.all().length;
|
||||
}
|
||||
|
||||
var count = this.gitService.getModel().getStatus().getGroups().map(mapper).reduce((a, b) => a + b, 0);
|
||||
|
||||
var badge = new NumberBadge(count, (num)=>{ return nls.localize('gitPendingChangesBadge', '{0} pending changes', num); });
|
||||
|
||||
|
|
|
@ -235,6 +235,7 @@ export interface IGitConfiguration {
|
|||
enableLongCommitWarning: boolean;
|
||||
allowLargeRepositories: boolean;
|
||||
confirmSync: boolean;
|
||||
countUntracked: boolean;
|
||||
}
|
||||
|
||||
// Service interfaces
|
||||
|
|
Loading…
Reference in a new issue