mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Closes #116361 - adds select/compare ability
This commit is contained in:
parent
3c31b0deba
commit
31aa03fcc8
|
@ -495,6 +495,16 @@
|
|||
"title": "%command.timelineCopyCommitMessage%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.selectForCompare",
|
||||
"title": "%command.timelineSelectForCompare%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.compareWithSelected",
|
||||
"title": "%command.timelineCompareWithSelected%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.rebaseAbort",
|
||||
"title": "%command.rebaseAbort%",
|
||||
|
@ -874,6 +884,18 @@
|
|||
{
|
||||
"command": "git.timeline.copyCommitMessage",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.selectForCompare",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.compareWithSelected",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.compareSelected",
|
||||
"when": "false"
|
||||
}
|
||||
],
|
||||
"scm/title": [
|
||||
|
@ -1349,17 +1371,27 @@
|
|||
{
|
||||
"command": "git.timeline.openDiff",
|
||||
"group": "1_actions",
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file\\b/"
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file\\b/ && !listMultiSelection"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.compareWithSelected",
|
||||
"group": "3_compare@1",
|
||||
"when": "config.git.enabled && !git.missing && git.timeline.selectedForCompare && timelineItem =~ /git:file\\b/ && !listMultiSelection"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.selectForCompare",
|
||||
"group": "3_compare@2",
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file\\b/ && !listMultiSelection"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.copyCommitId",
|
||||
"group": "5_copy@1",
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file:commit\\b/"
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file:commit\\b/ && !listMultiSelection"
|
||||
},
|
||||
{
|
||||
"command": "git.timeline.copyCommitMessage",
|
||||
"group": "5_copy@2",
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file:commit\\b/"
|
||||
"when": "config.git.enabled && !git.missing && timelineItem =~ /git:file:commit\\b/ && !listMultiSelection"
|
||||
}
|
||||
],
|
||||
"git.commit": [
|
||||
|
|
|
@ -90,6 +90,8 @@
|
|||
"command.timelineOpenDiff": "Open Changes",
|
||||
"command.timelineCopyCommitId": "Copy Commit ID",
|
||||
"command.timelineCopyCommitMessage": "Copy Commit Message",
|
||||
"command.timelineSelectForCompare": "Select for Compare",
|
||||
"command.timelineCompareWithSelected": "Compare with Selected",
|
||||
"config.enabled": "Whether git is enabled.",
|
||||
"config.path": "Path and filename of the git executable, e.g. `C:\\Program Files\\Git\\bin\\git.exe` (Windows). This can also be an array of string values containing multiple paths to look up.",
|
||||
"config.autoRepositoryDetection": "Configures when repositories should be automatically detected.",
|
||||
|
|
|
@ -2669,6 +2669,52 @@ export class CommandCenter {
|
|||
env.clipboard.writeText(item.message);
|
||||
}
|
||||
|
||||
private _selectedForCompare: { uri: Uri, item: GitTimelineItem } | undefined;
|
||||
|
||||
@command('git.timeline.selectForCompare', { repository: false })
|
||||
async timelineSelectForCompare(item: TimelineItem, uri: Uri | undefined, _source: string) {
|
||||
if (!GitTimelineItem.is(item) || !uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._selectedForCompare = { uri, item };
|
||||
await commands.executeCommand('setContext', 'git.timeline.selectedForCompare', true);
|
||||
}
|
||||
|
||||
@command('git.timeline.compareWithSelected', { repository: false })
|
||||
async timelineCompareWithSelected(item: TimelineItem, uri: Uri | undefined, _source: string) {
|
||||
if (!GitTimelineItem.is(item) || !uri || !this._selectedForCompare || uri.toString() !== this._selectedForCompare.uri.toString()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { item: selected } = this._selectedForCompare;
|
||||
|
||||
const basename = path.basename(uri.fsPath);
|
||||
let leftTitle;
|
||||
if ((selected.previousRef === 'HEAD' || selected.previousRef === '~') && selected.ref === '') {
|
||||
leftTitle = localize('git.title.workingTree', '{0} (Working Tree)', basename);
|
||||
}
|
||||
else if (selected.previousRef === 'HEAD' && selected.ref === '~') {
|
||||
leftTitle = localize('git.title.index', '{0} (Index)', basename);
|
||||
} else {
|
||||
leftTitle = localize('git.title.ref', '{0} ({1})', basename, selected.shortRef);
|
||||
}
|
||||
|
||||
let rightTitle;
|
||||
if ((item.previousRef === 'HEAD' || item.previousRef === '~') && item.ref === '') {
|
||||
rightTitle = localize('git.title.workingTree', '{0} (Working Tree)', basename);
|
||||
}
|
||||
else if (item.previousRef === 'HEAD' && item.ref === '~') {
|
||||
rightTitle = localize('git.title.index', '{0} (Index)', basename);
|
||||
} else {
|
||||
rightTitle = localize('git.title.ref', '{0} ({1})', basename, item.shortRef);
|
||||
}
|
||||
|
||||
|
||||
const title = localize('git.title.diff', '{0} ⟷ {1}', leftTitle, rightTitle);
|
||||
await commands.executeCommand('vscode.diff', selected.ref === '' ? uri : toGitUri(uri, selected.ref), item.ref === '' ? uri : toGitUri(uri, item.ref), title);
|
||||
}
|
||||
|
||||
@command('git.rebaseAbort', { repository: true })
|
||||
async rebaseAbort(repository: Repository): Promise<void> {
|
||||
if (repository.rebaseCommit) {
|
||||
|
|
|
@ -908,7 +908,6 @@ export class TimelinePane extends ViewPane {
|
|||
item = selection[0];
|
||||
}
|
||||
|
||||
// const item = e.element;
|
||||
if (item === null) {
|
||||
return;
|
||||
}
|
||||
|
@ -923,8 +922,6 @@ export class TimelinePane extends ViewPane {
|
|||
}
|
||||
|
||||
this.commandService.executeCommand(item.command.id, ...args);
|
||||
|
||||
// this.commandService.executeCommand(item.command.id, ...(item.command.arguments || []));
|
||||
}
|
||||
}
|
||||
else if (isLoadMoreCommand(item)) {
|
||||
|
|
Loading…
Reference in a new issue