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%",
|
||||
"original": "Next Conflict",
|
||||
"command": "merge-conflict.next",
|
||||
"icon": "$(codicon/arrow-down)"
|
||||
"icon": "$(arrow-down)"
|
||||
},
|
||||
{
|
||||
"category": "%command.category%",
|
||||
"title": "%command.previous%",
|
||||
"original": "Previous Conflict",
|
||||
"command": "merge-conflict.previous",
|
||||
"icon": "$(codicon/arrow-up)"
|
||||
"icon": "$(arrow-up)"
|
||||
},
|
||||
{
|
||||
"category": "%command.category%",
|
||||
|
@ -103,12 +103,12 @@
|
|||
"editor/title": [
|
||||
{
|
||||
"command": "merge-conflict.previous",
|
||||
"group": "navigation",
|
||||
"group": "navigation@1",
|
||||
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
||||
},
|
||||
{
|
||||
"command": "merge-conflict.next",
|
||||
"group": "navigation",
|
||||
"group": "navigation@2",
|
||||
"when": "mergeConflictsCount && mergeConflictsCount != 0"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -339,18 +339,21 @@ export default class CommandHandler implements vscode.Disposable {
|
|||
|
||||
let predicate: (_conflict: any) => boolean;
|
||||
let fallback: () => interfaces.IDocumentMergeConflict;
|
||||
let scanOrder: interfaces.IDocumentMergeConflict[];
|
||||
|
||||
if (direction === NavigationDirection.Forwards) {
|
||||
predicate = (conflict) => selection.isBefore(conflict.range.start);
|
||||
fallback = () => conflicts![0];
|
||||
scanOrder = conflicts;
|
||||
} else if (direction === NavigationDirection.Backwards) {
|
||||
predicate = (conflict) => selection.isAfter(conflict.range.start);
|
||||
fallback = () => conflicts![conflicts!.length - 1];
|
||||
scanOrder = conflicts.slice().reverse();
|
||||
} else {
|
||||
throw new Error(`Unsupported direction ${direction}`);
|
||||
}
|
||||
|
||||
for (const conflict of conflicts) {
|
||||
for (const conflict of scanOrder) {
|
||||
if (predicate(conflict) && !conflict.range.contains(selection)) {
|
||||
return {
|
||||
canNavigate: true,
|
||||
|
|
Loading…
Reference in a new issue