From 2b13eee9b732f7c818be710f75092d849e1067e8 Mon Sep 17 00:00:00 2001 From: Piotr Kukielka Date: Wed, 17 Jul 2024 11:45:48 +0200 Subject: [PATCH] Show proper shortcut for every action on edit inlay --- .../cody/edit/EditCommandPrompt.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/sourcegraph/cody/edit/EditCommandPrompt.kt b/src/main/kotlin/com/sourcegraph/cody/edit/EditCommandPrompt.kt index 9f6d3bfe16..d1e624d8c9 100644 --- a/src/main/kotlin/com/sourcegraph/cody/edit/EditCommandPrompt.kt +++ b/src/main/kotlin/com/sourcegraph/cody/edit/EditCommandPrompt.kt @@ -614,21 +614,19 @@ class EditCommandPrompt( /** Returns a compact symbol representation of the action's keyboard shortcut, if any. */ @JvmStatic fun getShortcutDisplayString(actionId: String): String? { + fun getFirstShortcut(id: String): String? { + return KeymapManager.getInstance().activeKeymap.getShortcuts(id).firstOrNull()?.let { + KeymapUtil.getShortcutText(it) + } + } + return when (actionId) { "cody.editCodeAction", - "cody.inlineEditRetryAction" -> { - KeymapUtil.getShortcutText( - KeymapManager.getInstance().activeKeymap.getShortcuts("cody.editCodeAction")[0]) - } + "cody.inlineEditRetryAction" -> getFirstShortcut("cody.editCodeAction") "cody.inlineEditCancelAction", "cody.inlineEditUndoAction", - "cody.inlineEditDismissAction" -> { - KeymapUtil.getShortcutText( - KeymapManager.getInstance() - .activeKeymap - .getShortcuts("cody.editCancelOrUndoAction")[0]) - } - else -> null + "cody.inlineEditDismissAction" -> getFirstShortcut("cody.editCancelOrUndoAction") + else -> getFirstShortcut(actionId) } } }