Skip to content

fix(keymap): rebind file picker from ctrl+p to P - #300

Merged
umputun merged 1 commit into
masterfrom
rebind-file-picker-key
Jul 31, 2026
Merged

umputun merged 1 commit into
masterfrom
rebind-file-picker-key

Conversation

@umputun

@umputun umputun commented Jul 31, 2026

Copy link
Copy Markdown
Owner

the file picker from #285 was bound to ctrl+p, which host terminals claim before it reaches the TUI. Agterm binds it to session_palette by default, so inside agterm the picker could not be opened at all and read as a missing feature rather than a shadowed key. Moved the default to P.

one line of production code in app/keymap/keymap.go, the rest is tests and docs.

the trade-off with a printable key

filePickerOverlay.handleKey runs appendPrintableRunes before the action checks, and that consumes every unmodified printable rune regardless of what it resolves to. So P inside an open picker extends the filter instead of closing it, and the ActionJumpFile close branch is unreachable for the default binding.

that ordering has to stay. Reversing it would break filtering for whichever bare printable keys are bound to jump_file, up or down, P/j/k by default plus any bare printable key a user maps to those actions. Esc closes the picker, and toggle-close still works through any non-printable binding (map alt+f jump_file, map f1 jump_file, a ctrl chord).

tests

TestModel_JumpFileToggleClosesPicker no longer describes the default behavior, so it was replaced by two tests rather than dropped. TestModel_JumpFileKeyFiltersInsideOpenPicker pins that P filters and Enter selects the narrowed match, TestModel_JumpFileModifiedChordTogglesClosesPicker pins that alt+f still toggles closed. Added TestActionJumpFile_NotBoundToCtrlP so the default cannot drift back onto a chord host terminals take, and TestModel_SearchPrompt_SwallowsJumpFileKey so a capital P typed into the search prompt stays text.

known limitation, not introduced here

bubbletea batches consecutive printable runes from one terminal read into a single KeyRunes message (key.go:696), and Key.String() returns the concatenation. Typing P plus filter text fast enough to land in one read resolves to no action and drops the keystroke. This already affects every printable binding in the app (j, k, a, v, C, w, t); ctrl+p was immune only because control sequences parse separately. Fixing it means splitting multi-rune messages in the dispatcher, which is a separate change with its own tests.

users who have unmap ctrl+p in their keybindings will pick up P as a new default. unmap P suppresses it.

Related to #284

host terminals claim ctrl+p before it reaches the TUI — agterm binds it to
session_palette by default — so the file picker was unreachable there and read
as a missing feature rather than a conflict.

P is printable, and the picker's handleKey runs appendPrintableRunes before the
action checks, so P inside an open picker extends the filter instead of closing
it. That ordering has to stay: reversing it would break filtering for whichever
bare printable keys are bound to jump_file, up or down — P/j/k by default, and
any bare printable key a user maps to those actions. Toggle-close remains
available through any non-printable binding (map alt+f jump_file, map f1
jump_file, a ctrl chord).
Copilot AI review requested due to automatic review settings July 31, 2026 06:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@umputun
umputun merged commit 79c9a99 into master Jul 31, 2026
5 checks passed
@umputun
umputun deleted the rebind-file-picker-key branch July 31, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants