timeline - add setting to bring back "Uncommitted Changes" (#147372)

This commit is contained in:
Benjamin Pasero
2022-04-13 17:10:28 +02:00
committed by GitHub
parent 2aa78c8cfb
commit 44b6695d4e
3 changed files with 34 additions and 1 deletions

View File

@@ -169,6 +169,8 @@ export class GitTimelineProvider implements TimelineProvider {
const dateType = config.get<'committed' | 'authored'>('date');
const showAuthor = config.get<boolean>('showAuthor');
const showUncommitted = config.get<boolean>('showUncommitted');
const openComparison = localize('git.timeline.openComparison', "Open Comparison");
const items = commits.map<GitTimelineItem>((c, i) => {
@@ -220,6 +222,30 @@ export class GitTimelineProvider implements TimelineProvider {
items.splice(0, 0, item);
}
if (showUncommitted) {
const working = repo.workingTreeGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
if (working) {
const date = new Date();
const item = new GitTimelineItem('', index ? '~' : 'HEAD', localize('git.timeline.uncommitedChanges', 'Uncommitted Changes'), date.getTime(), 'working', 'git:file:working');
// TODO@eamodio: Replace with a better icon -- reflecting its status maybe?
item.iconPath = new ThemeIcon('git-commit');
item.description = '';
item.setItemDetails(you, undefined, dateFormatter.format(date), Resource.getStatusText(working.type));
const cmd = this.commands.resolveTimelineOpenDiffCommand(item, uri);
if (cmd) {
item.command = {
title: openComparison,
command: cmd.command,
arguments: cmd.arguments,
};
}
items.splice(0, 0, item);
}
}
}
return {
@@ -235,7 +261,7 @@ export class GitTimelineProvider implements TimelineProvider {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (e.affectsConfiguration('git.timeline.date') || e.affectsConfiguration('git.timeline.showAuthor')) {
if (e.affectsConfiguration('git.timeline.date') || e.affectsConfiguration('git.timeline.showAuthor') || e.affectsConfiguration('git.timeline.showUncommitted')) {
this.fireChanged();
}
}