-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(shell): add Shift+Enter as newline shortcut alongside Ctrl-J and Alt-Enter #2302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1164,7 +1164,7 @@ def _build_toolbar_tips(clipboard_available: bool) -> list[str]: | |
| "ctrl-x: toggle mode", | ||
| "shift-tab: plan mode", | ||
| "ctrl-o: editor", | ||
| "ctrl-j: newline", | ||
| "shift-enter / ctrl-j: newline", | ||
| "/feedback: send feedback", | ||
| "/theme: switch dark/light", | ||
| ] | ||
|
|
@@ -1321,8 +1321,9 @@ async def _toggle() -> None: | |
|
|
||
| @_kb.add("escape", "enter", eager=True) | ||
| @_kb.add("c-j", eager=True) | ||
| @_kb.add("s-enter", eager=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎. |
||
| def _(event: KeyPressEvent) -> None: | ||
| """Insert a newline when Alt-Enter or Ctrl-J is pressed.""" | ||
| """Insert a newline when Alt-Enter, Ctrl-J, or Shift-Enter is pressed.""" | ||
| from kimi_cli.telemetry import track | ||
|
|
||
| track("shortcut_newline") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴
s-enteris not a valid prompt_toolkit key name, crashingCustomPromptSession.__init___kb.add("s-enter", eager=True)raisesValueError: Invalid key: s-enterat call time becauses-enterdoes not exist in prompt_toolkit'sALL_KEYS(verified on both 3.0.28 and the pinned 3.0.52). Because Python evaluates stacked decorators bottom-up, this error fires before thec-jandescape+enterdecorators above it are applied, so all three newline bindings fail to register and theCustomPromptSession.__init__crashes entirely. This means the interactive shell UI cannot start at all.Reproduction confirming the issue on prompt_toolkit 3.0.52
Shift+Enter is indistinguishable from Enter in most terminals because they both send
\r. Modern terminals supporting the Kitty keyboard protocol can distinguish them, but prompt_toolkit does not expose as-enterkey. A different approach is needed (e.g., handling via a VT100 escape sequence or the Kitty protocol directly).Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.