Skip to content

Commit ecf822f

Browse files
committed
Improves merge editor input handling
1 parent e6fd38c commit ecf822f

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/views/viewCommands.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,12 @@ export class ViewCommands implements Disposable {
15491549
const nodeUri = await this.container.git.getBestRevisionUri(node.repoPath, node.file.path, node.ref.ref);
15501550
if (nodeUri == null) return Promise.resolve();
15511551

1552+
const input1: MergeEditorInputs['input1'] = {
1553+
uri: nodeUri,
1554+
title: `Incoming`,
1555+
detail: ` ${node.ref.name}`,
1556+
};
1557+
15521558
const [mergeBaseResult, workingUriResult] = await Promise.allSettled([
15531559
repo.git.refs().getMergeBase(node.ref.ref, 'HEAD'),
15541560
this.container.git.getWorkingUri(node.repoPath, node.uri),
@@ -1560,6 +1566,20 @@ export class ViewCommands implements Disposable {
15601566
return Promise.resolve();
15611567
}
15621568

1569+
const input2: MergeEditorInputs['input2'] = {
1570+
uri: workingUri,
1571+
title: 'Current',
1572+
detail: ' Working Tree',
1573+
};
1574+
1575+
const headUri = await this.container.git.getBestRevisionUri(node.repoPath, node.file.path, 'HEAD');
1576+
if (headUri != null) {
1577+
const branch = await repo.git.branches().getBranch?.();
1578+
1579+
input2.uri = headUri;
1580+
input2.detail = ` ${branch?.name || 'HEAD'}`;
1581+
}
1582+
15631583
const mergeBase = getSettledValue(mergeBaseResult);
15641584
const baseUri =
15651585
mergeBase != null
@@ -1568,14 +1588,8 @@ export class ViewCommands implements Disposable {
15681588

15691589
const inputs: MergeEditorInputs = {
15701590
base: baseUri ?? nodeUri,
1571-
input1: {
1572-
uri: nodeUri,
1573-
title: node.ref.name,
1574-
},
1575-
input2: {
1576-
uri: workingUri,
1577-
title: 'Working Tree',
1578-
},
1591+
input1: input1,
1592+
input2: input2,
15791593
output: workingUri,
15801594
};
15811595

0 commit comments

Comments
 (0)