This commit is contained in:
inb4after 2021-11-26 11:27:08 -08:00 committed by GitHub
commit 3162b135b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 22 deletions

View file

@ -4,7 +4,7 @@
"displayName": "%displayName%",
"description": "%description%",
"icon": "media/icon.png",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
@ -44,9 +44,15 @@
},
{
"category": "%command.category%",
"title": "%command.accept.all-both%",
"original": "Accept All Both",
"command": "merge-conflict.accept.all-both"
"title": "%command.accept.all-current-then-incoming%",
"original": "Accept All Current Then Incoming",
"command": "merge-conflict.accept.all-current-then-incoming"
},
{
"category": "%command.category%",
"title": "%command.accept.all-incoming-then-current%",
"original": "Accept All Incoming Then Current",
"command": "merge-conflict.accept.all-incoming-then-current"
},
{
"category": "%command.category%",
@ -68,9 +74,15 @@
},
{
"category": "%command.category%",
"title": "%command.accept.both%",
"original": "Accept Both",
"command": "merge-conflict.accept.both"
"title": "%command.accept.current-then-incoming%",
"original": "Accept Current Then Incoming",
"command": "merge-conflict.accept.current-then-incoming"
},
{
"category": "%command.category%",
"title": "%command.accept.incoming-then-current%",
"original": "Accept Incoming Then Current",
"command": "merge-conflict.accept.incoming-then-current"
},
{
"category": "%command.category%",

View file

@ -4,11 +4,13 @@
"command.category": "Merge Conflict",
"command.accept.all-current": "Accept All Current",
"command.accept.all-incoming": "Accept All Incoming",
"command.accept.all-both": "Accept All Both",
"command.accept.all-current-then-incoming": "Accept All Current Then Incoming",
"command.accept.all-incoming-then-current": "Accept All Incoming Then Current",
"command.accept.current": "Accept Current",
"command.accept.incoming": "Accept Incoming",
"command.accept.selection": "Accept Selection",
"command.accept.both": "Accept Both",
"command.accept.current-then-incoming": "Accept Current Then Incoming",
"command.accept.incoming-then-current": "Accept Incoming Then Current",
"command.next": "Next Conflict",
"command.previous": "Previous Conflict",
"command.compare": "Compare Current Conflict",

View file

@ -75,9 +75,15 @@ export default class MergeConflictCodeLensProvider implements vscode.CodeLensPro
arguments: ['known-conflict', conflict]
};
let acceptBothCommand: vscode.Command = {
command: 'merge-conflict.accept.both',
title: localize('acceptBothChanges', 'Accept Both Changes'),
let acceptCurrentThenIncomingCommand: vscode.Command = {
command: 'merge-conflict.accept.current-then-incoming',
title: localize('acceptCurrentThenIncomingChanges', 'Accept Current Then Incoming Changes'),
arguments: ['known-conflict', conflict]
};
let acceptIncomingThenCurrentCommand: vscode.Command = {
command: 'merge-conflict.accept.incoming-then-current',
title: localize('acceptIncomingThenCurrentChanges', 'Accept Incoming Then Current Changes'),
arguments: ['known-conflict', conflict]
};
@ -90,8 +96,9 @@ export default class MergeConflictCodeLensProvider implements vscode.CodeLensPro
items.push(
new vscode.CodeLens(conflict.range, acceptCurrentCommand),
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 1 })), acceptIncomingCommand),
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 2 })), acceptBothCommand),
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 3 })), diffCommand)
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 2 })), acceptCurrentThenIncomingCommand),
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 3 })), acceptIncomingThenCurrentCommand),
new vscode.CodeLens(conflict.range.with(conflict.range.start.with({ character: conflict.range.start.character + 4 })), diffCommand)
);
});

View file

@ -32,10 +32,12 @@ export default class CommandHandler implements vscode.Disposable {
this.registerTextEditorCommand('merge-conflict.accept.current', this.acceptCurrent),
this.registerTextEditorCommand('merge-conflict.accept.incoming', this.acceptIncoming),
this.registerTextEditorCommand('merge-conflict.accept.selection', this.acceptSelection),
this.registerTextEditorCommand('merge-conflict.accept.both', this.acceptBoth),
this.registerTextEditorCommand('merge-conflict.accept.current-then-incoming', this.acceptCurrentThenIncoming),
this.registerTextEditorCommand('merge-conflict.accept.incoming-then-current', this.acceptIncomingThenCurrent),
this.registerTextEditorCommand('merge-conflict.accept.all-current', this.acceptAllCurrent, this.acceptAllCurrentResources),
this.registerTextEditorCommand('merge-conflict.accept.all-incoming', this.acceptAllIncoming, this.acceptAllIncomingResources),
this.registerTextEditorCommand('merge-conflict.accept.all-both', this.acceptAllBoth),
this.registerTextEditorCommand('merge-conflict.accept.all-current-then-incoming', this.acceptAllCurrentThenIncoming),
this.registerTextEditorCommand('merge-conflict.accept.all-incoming-then-current', this.acceptAllIncomingThenCurrent),
this.registerTextEditorCommand('merge-conflict.next', this.navigateNext),
this.registerTextEditorCommand('merge-conflict.previous', this.navigatePrevious),
this.registerTextEditorCommand('merge-conflict.compare', this.compare)
@ -60,8 +62,12 @@ export default class CommandHandler implements vscode.Disposable {
return this.accept(interfaces.CommitType.Incoming, editor, ...args);
}
acceptBoth(editor: vscode.TextEditor, ...args: any[]): Promise<void> {
return this.accept(interfaces.CommitType.Both, editor, ...args);
acceptCurrentThenIncoming(editor: vscode.TextEditor, ...args: any[]): Promise<void> {
return this.accept(interfaces.CommitType.CurrentThenIncoming, editor, ...args);
}
acceptIncomingThenCurrent(editor: vscode.TextEditor, ...args: any[]): Promise<void> {
return this.accept(interfaces.CommitType.IncomingThenCurrent, editor, ...args);
}
acceptAllCurrent(editor: vscode.TextEditor): Promise<void> {
@ -80,8 +86,12 @@ export default class CommandHandler implements vscode.Disposable {
return this.acceptAllResources(interfaces.CommitType.Incoming, resources);
}
acceptAllBoth(editor: vscode.TextEditor): Promise<void> {
return this.acceptAll(interfaces.CommitType.Both, editor);
acceptAllCurrentThenIncoming(editor: vscode.TextEditor): Promise<void> {
return this.acceptAll(interfaces.CommitType.CurrentThenIncoming, editor);
}
acceptAllIncomingThenCurrent(editor: vscode.TextEditor): Promise<void> {
return this.acceptAll(interfaces.CommitType.IncomingThenCurrent, editor);
}
async compare(editor: vscode.TextEditor, conflict: interfaces.IDocumentMergeConflict | null) {

View file

@ -52,7 +52,7 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict
let content = document.getText(this.incoming.content);
this.replaceRangeWithContent(content, edit);
}
else if (type === interfaces.CommitType.Both) {
else if (type === interfaces.CommitType.CurrentThenIncoming) {
// Replace [ Conflict Range ] with [ Current Content ] + \n + [ Incoming Content ]
const currentContent = document.getText(this.current.content);
@ -60,6 +60,14 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict
edit.replace(this.range, currentContent.concat(incomingContent));
}
else if (type === interfaces.CommitType.IncomingThenCurrent) {
// Replace [ Conflict Range ] with [ Incoming Content ] + \n + [ Current Content ]
const currentContent = document.getText(this.current.content);
const incomingContent = document.getText(this.incoming.content);
edit.replace(this.range, incomingContent.concat(currentContent));
}
}
private replaceRangeWithContent(content: string, edit: { replace(range: vscode.Range, newText: string): void; }) {

View file

@ -14,7 +14,8 @@ export interface IMergeRegion {
export const enum CommitType {
Current,
Incoming,
Both
CurrentThenIncoming,
IncomingThenCurrent
}
export interface IExtensionConfiguration {