Merge branch 'git-untracked-files' of https://github.com/FabianLauer/vscode into FabianLauer-git-untracked-files

This commit is contained in:
Joao Moreno 2016-08-12 16:02:11 +02:00
commit a4b3d1456b
2 changed files with 26 additions and 4 deletions

View file

@ -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); });
@ -547,6 +563,11 @@ export function registerContributions(): void {
type: 'boolean',
description: nls.localize('confirmSync', "Confirm before synchronizing git repositories."),
default: false
},
'git.countUntracked': {
type: 'boolean',
description: nls.localize('countUntracked', "Count untracked files in the changes badge."),
default: true
}
}
});

View file

@ -240,6 +240,7 @@ export interface IGitConfiguration {
enableLongCommitWarning: boolean;
allowLargeRepositories: boolean;
confirmSync: boolean;
countUntracked: boolean;
}
// Service interfaces