From 5c7957161072c7cc5a0a26314e14e9d9817ed476 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Wed, 31 Mar 2021 10:46:11 +0200 Subject: [PATCH] Add next/prev conflicts (#97613) --- extensions/merge-conflict/package.json | 8 ++++---- extensions/merge-conflict/src/commandHandler.ts | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/extensions/merge-conflict/package.json b/extensions/merge-conflict/package.json index 87f44958322..11340c09376 100644 --- a/extensions/merge-conflict/package.json +++ b/extensions/merge-conflict/package.json @@ -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" } ] diff --git a/extensions/merge-conflict/src/commandHandler.ts b/extensions/merge-conflict/src/commandHandler.ts index ca45b9a16f8..c6c9eaa82ca 100644 --- a/extensions/merge-conflict/src/commandHandler.ts +++ b/extensions/merge-conflict/src/commandHandler.ts @@ -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,