Skip to content

Commit bae47d3

Browse files
author
SqlRush
committed
Normalize namespaced keybinding actions
1 parent eb5b50b commit bae47d3

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ M7 progress now includes:
361361
- `internal/tui`: keybinding config now accepts page/navigation/editing aliases such as `pgup`, `pg-up`, `prior`, `pageUpKey`, `pgdn`, `pg-down`, `next`, `pageDownKey`, `homeKey`, `endKey`, `deleteForward`, `forwardDelete`, and `deleteBackward`.
362362
- `internal/tui`: keybinding config and named-key script input now accept DOM/fixture control-key aliases such as `enterKey`, `returnKey`, `numpadEnter`, `escapeKey`, `escKey`, `tabKey`, `shiftEnterKey`, `shiftNumpadEnter`, `shiftTabKey`, and `backtabKey`.
363363
- `internal/tui`: keybinding config and named-key script input now accept DOM-style arrow key aliases such as `arrowLeft`, `arrowRight`, `arrowUp`, `arrowDown`, and modifier-arrow variants.
364-
- `internal/tui`: keybinding action parsing now accepts broader editor/global-style aliases such as `cursorLeft`, `previousWord`, `nextWord`, `lineStart`, `lineEnd`, `moveToBeginningOfLine`, `moveToEndOfLine`, `deletePreviousChar`, `deleteNextChar`, `backwardDelete`, `forwardDelete`, `deleteToStartOfLine`, `deleteToEndOfLine`, `killLine`, `pasteKillRing`, `clearScreen`, `openExternalEditor`, `toggleTasks`, `cancelAgents`, `focusPrev`, `acceptSelection`, and `search`.
364+
- `internal/tui`: keybinding action parsing now accepts broader editor/global-style aliases and namespaced `editor.action.*`/`workbench.action.*`/`terminal.action.*`/`chat.action.*` aliases such as `cursorLeft`, `previousWord`, `nextWord`, `lineStart`, `lineEnd`, `moveToBeginningOfLine`, `moveToEndOfLine`, `deletePreviousChar`, `deleteNextChar`, `backwardDelete`, `forwardDelete`, `deleteToStartOfLine`, `deleteToEndOfLine`, `killLine`, `pasteKillRing`, `clearScreen`, `openExternalEditor`, `toggleTasks`, `cancelAgents`, `focusPrev`, `acceptSelection`, and `search`.
365365
- `internal/tui`: keybinding config and named-key script input now accept short modifier aliases such as `c-left`, `cA`, `m-b`, `a-right`, `optF`, `s-tab`, and `sEnter`.
366366
- `internal/tui`: keybinding config and named-key script input now accept Shift-Tab terminfo aliases such as `backtab`, `back-tab`, and `btab`, mapping them to the existing focus-previous key surface.
367367
- `internal/tui`: scripted interaction `keys` entries now accept printable text chunks and whitespace-separated named key sequences such as `ctrl-x ctrl-k`.

internal/tui/keybinding_config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ func compactShiftKeySuffix(suffix string) bool {
433433

434434
func ParseActionName(raw string) (Action, error) {
435435
name := normalizeActionName(raw)
436+
name = stripActionNamespace(name)
436437
switch name {
437438
case "", "none", "noop", "no_op", "null", "unbind", "unbound":
438439
return ActionNone, nil
@@ -522,6 +523,21 @@ func ParseActionName(raw string) (Action, error) {
522523
return action, nil
523524
}
524525

526+
func stripActionNamespace(name string) string {
527+
for _, prefix := range []string{
528+
"editor_action_",
529+
"workbench_action_",
530+
"terminal_action_",
531+
"chat_action_",
532+
"claude_action_",
533+
} {
534+
if suffix, ok := strings.CutPrefix(name, prefix); ok && suffix != "" {
535+
return suffix
536+
}
537+
}
538+
return name
539+
}
540+
525541
func normalizeActionName(raw string) string {
526542
var b strings.Builder
527543
lastSeparator := false

internal/tui/tui_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,12 @@ func TestKeymapFromSpecsOverridesAndRemovesBindings(t *testing.T) {
14941494
{name: "cancelAgents", want: ActionKillAgents},
14951495
{name: "deleteWordBackward", want: ActionDeleteWordBack},
14961496
{name: "deleteWordForward", want: ActionDeleteWordFwd},
1497+
{name: "editor.action.deleteWordLeft", want: ActionDeleteWordBack},
1498+
{name: "editor.action.deleteWordRight", want: ActionDeleteWordFwd},
1499+
{name: "editor.action.moveToBeginningOfLine", want: ActionMoveStart},
1500+
{name: "workbench.action.clearScreen", want: ActionRedraw},
1501+
{name: "terminal.action.focusPrevious", want: ActionFocusPrevious},
1502+
{name: "chat.action.submitPrompt", want: ActionSubmitPrompt},
14971503
{name: "pasteKillRing", want: ActionYank},
14981504
{name: "yankPrevious", want: ActionYankPop},
14991505
{name: "cursorLeft", want: ActionMoveLeft},

0 commit comments

Comments
 (0)