Skip to content

feat(tui): add input.line_discard to choose what ctrl+u deletes - #56246

Open
Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:line-discard
Open

Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:line-discard

Conversation

@Nowaker

@Nowaker Nowaker commented Oct 16, 2026

Copy link
Copy Markdown

Note: I'm aware v1 is now the maintenance branch and new features go to v2 only. This PR is here for others to use, and I'll submit the v2 version once I've migrated my whole plugin system to it.

Issue for this PR

Closes #56242

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ctrl+u (input_delete_to_line_start) deletes from the cursor back to the start of its line, as bash does. zsh users expect it to delete the whole line wherever the cursor is.

  • input.line_discard in tui.json: "bash" (default, today's behavior) or "zsh".
  • "Line" is the cursor's logical line in both modes, never the rest of a multi-line prompt.
  • "zsh" moves the cursor to the end of the line and runs opentui's deleteToLineStart, so both modes keep its edge behavior: a press at the start of a line, or on an empty one, joins it to the line above. input_undo restores the text.
  • registerOpencodeKeymap replaces the textarea's input.delete.to.line.start command and adds a binding layer for a focused single-line <input>, which otherwise handles ctrl+u itself. That covers the prompt, question and permission replies, dialog prompts, the export options editor, select-dialog filters and the run footer, which gets the setting through RunTuiConfig.

How did you verify your code works?

  • bun typecheck in packages/tui and packages/opencode.
  • test/keymap.test.tsx sends a real \x15 through the keymap: hello world with the cursor after hello becomes world (unset and "bash") and empty ("zsh"), in a textarea and in an <input>; in first / hello world / last only the middle line changes; undo brings each back.
  • My fork's build, in a real TUI in tmux with isolated XDG dirs: hello world with the cursor after hello in the prompt and in the command palette filter gives world ("bash" and unset) and an empty field ("zsh"); in a three-line prompt only the middle line changes, and ctrl+z brings it back.

Screenshots / recordings

Behavior-only change, no visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR is AI generated, but under direct supervision and on request of @Nowaker.

ctrl+u (input_delete_to_line_start) deletes from the cursor back to
the start of its line, as bash and readline's unix-line-discard do.
zsh users expect it to delete the whole line wherever the cursor is
(kill-whole-line). input.line_discard in tui.json chooses: 'bash'
(default, unchanged behaviour) or 'zsh'.

"Line" is the cursor's logical line in both modes, never the rest of
a multi-line prompt. 'zsh' moves the cursor to the line's end and
runs opentui's deleteToLineStart, so both modes keep its edge
behaviour (a press at the start of a line, or on an empty one, joins
it to the line above) and input_undo restores the text.

The setting applies to every text field: registerOpencodeKeymap
replaces the managed textarea's input.delete.to.line.start command
(packages/tui/src/keymap.tsx) and adds a binding layer for focused
single-line <input> fields, which otherwise handle ctrl+u natively.
That covers the prompt, permission and question replies, dialog
prompts, the export options editor, select-dialog filters and the
run-mode footer, which receives the setting through RunTuiConfig.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

This branch has not been deployed

No deployments
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.

1 participant