mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 05:28:19 -05:00
Adds index (staged changes) to timeline
This commit is contained in:
@@ -2334,6 +2334,10 @@ export class CommandCenter {
|
||||
|
||||
@command('git.openDiff', { repository: false })
|
||||
async openDiff(uri: Uri, hash: string) {
|
||||
if (hash === '~') {
|
||||
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `HEAD`));
|
||||
}
|
||||
|
||||
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `${hash}^`));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ export class GitTimelineProvider implements TimelineProvider {
|
||||
|
||||
console.log(`GitTimelineProvider.provideTimeline: commits=${commits.length}`);
|
||||
|
||||
return commits.map<TimelineItem>(c => {
|
||||
const items = commits.map<TimelineItem>(c => {
|
||||
let message = c.message;
|
||||
|
||||
const index = message.indexOf('\n');
|
||||
@@ -82,6 +82,26 @@ export class GitTimelineProvider implements TimelineProvider {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
|
||||
if (index) {
|
||||
items.push({
|
||||
id: '~',
|
||||
// TODO: Fix the date
|
||||
date: Date.now(),
|
||||
iconPath: new ThemeIcon('git-commit'),
|
||||
label: 'Staged Changes',
|
||||
description: '',
|
||||
detail: '',
|
||||
command: {
|
||||
title: 'Open Diff',
|
||||
command: 'git.openDiff',
|
||||
arguments: [uri, '~']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@debounce(500)
|
||||
|
||||
Reference in New Issue
Block a user