Add next/prev conflicts (#97613)
This commit is contained in:
parent
96d0dc4154
commit
5c79571610
2 changed files with 8 additions and 5 deletions
|
@ -71,14 +71,14 @@
|
||||||
"title": "%command.next%",
|
"title": "%command.next%",
|
||||||
"original": "Next Conflict",
|
"original": "Next Conflict",
|
||||||
"command": "merge-conflict.next",
|
"command": "merge-conflict.next",
|
||||||
"icon": "$(codicon/arrow-down)"
|
"icon": "$(arrow-down)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "%command.category%",
|
"category": "%command.category%",
|
||||||
"title": "%command.previous%",
|
"title": "%command.previous%",
|
||||||
"original": "Previous Conflict",
|
"original": "Previous Conflict",
|
||||||
"command": "merge-conflict.previous",
|
"command": "merge-conflict.previous",
|
||||||
"icon": "$(codicon/arrow-up)"
|
"icon": "$(arrow-up)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "%command.category%",
|
"category": "%command.category%",
|
||||||
|
@ -103,12 +103,12 @@
|
||||||
"editor/title": [
|
"editor/title": [
|
||||||
{
|
{
|
||||||
"command": "merge-conflict.previous",
|
"command": "merge-conflict.previous",
|
||||||
"group": "navigation",
|
"group": "navigation@1",
|
||||||
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "merge-conflict.next",
|
"command": "merge-conflict.next",
|
||||||
"group": "navigation",
|
"group": "navigation@2",
|
||||||
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -339,18 +339,21 @@ export default class CommandHandler implements vscode.Disposable {
|
||||||
|
|
||||||
let predicate: (_conflict: any) => boolean;
|
let predicate: (_conflict: any) => boolean;
|
||||||
let fallback: () => interfaces.IDocumentMergeConflict;
|
let fallback: () => interfaces.IDocumentMergeConflict;
|
||||||
|
let scanOrder: interfaces.IDocumentMergeConflict[];
|
||||||
|
|
||||||
if (direction === NavigationDirection.Forwards) {
|
if (direction === NavigationDirection.Forwards) {
|
||||||
predicate = (conflict) => selection.isBefore(conflict.range.start);
|
predicate = (conflict) => selection.isBefore(conflict.range.start);
|
||||||
fallback = () => conflicts![0];
|
fallback = () => conflicts![0];
|
||||||
|
scanOrder = conflicts;
|
||||||
} else if (direction === NavigationDirection.Backwards) {
|
} else if (direction === NavigationDirection.Backwards) {
|
||||||
predicate = (conflict) => selection.isAfter(conflict.range.start);
|
predicate = (conflict) => selection.isAfter(conflict.range.start);
|
||||||
fallback = () => conflicts![conflicts!.length - 1];
|
fallback = () => conflicts![conflicts!.length - 1];
|
||||||
|
scanOrder = conflicts.slice().reverse();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported direction ${direction}`);
|
throw new Error(`Unsupported direction ${direction}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const conflict of conflicts) {
|
for (const conflict of scanOrder) {
|
||||||
if (predicate(conflict) && !conflict.range.contains(selection)) {
|
if (predicate(conflict) && !conflict.range.contains(selection)) {
|
||||||
return {
|
return {
|
||||||
canNavigate: true,
|
canNavigate: true,
|
||||||
|
|
Loading…
Reference in a new issue