Skip to content

Commit

Permalink
Show proper shortcut for every action on edit inlay
Browse files Browse the repository at this point in the history
  • Loading branch information
pkukielka committed Jul 17, 2024
1 parent 94c0271 commit 2b13eee
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/main/kotlin/com/sourcegraph/cody/edit/EditCommandPrompt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 2b13eee

Please sign in to comment.