diff --git a/extensions/git/package.json b/extensions/git/package.json index 1122b41fc4c..117cc1b0761 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -2222,6 +2222,12 @@ "description": "%config.timeline.showAuthor%", "scope": "window" }, + "git.timeline.showUncommitted": { + "type": "boolean", + "default": false, + "description": "%config.timeline.showUncommitted%", + "scope": "window" + }, "git.showUnpublishedCommitsButton": { "type": "string", "enum": [ diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 6675bd12718..b19611f7dd9 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -188,6 +188,7 @@ "config.showCommitInput": "Controls whether to show the commit input in the Git source control panel.", "config.terminalAuthentication": "Controls whether to enable VS Code to be the authentication handler for git processes spawned in the integrated terminal. Note: terminals need to be restarted to pick up a change in this setting.", "config.timeline.showAuthor": "Controls whether to show the commit author in the Timeline view.", + "config.timeline.showUncommitted": "Controls whether to show uncommitted changes in the Timeline view.", "config.timeline.date": "Controls which date to use for items in the Timeline view.", "config.timeline.date.committed": "Use the committed date", "config.timeline.date.authored": "Use the authored date", diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index f2e665eaafc..8d65812a8d0 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -169,6 +169,8 @@ export class GitTimelineProvider implements TimelineProvider { const dateType = config.get<'committed' | 'authored'>('date'); const showAuthor = config.get('showAuthor'); + const showUncommitted = config.get('showUncommitted'); + const openComparison = localize('git.timeline.openComparison', "Open Comparison"); const items = commits.map((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(); } }