-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix(tui): fix Shift+Enter newline on Windows #8040
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
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #3965: Differentiate Shift+Enter from Enter for prompt submission This PR appears to address the same issue - differentiating between |
|
@kommander possibly something opentuis houdl handle? |
|
Interesting workaround. @Hona you think that makes sense? Could bring that in opentui. |
|
I reached out on discord to kmdr, this is an API I've used in high render throughput C# console apps. |
|
Oh interesting @kommander, I was having these same issues and was about to and get Claude or GLM to come up with a fix. I was having these issues even with the following set in my keybinds; "keybinds": {
"input_newline": "shift+return",
// more binds
}This was GLM's take on this issue where AnalysisI've traced through the keybinding system and identified the root cause: Problem Location
Root CauseThe function adds hardcoded keybindings before user-configured bindings: return [
{ name: "return", action: "submit" }, // Line 68
{ name: "return", meta: true, action: "newline" }, // Line 69
...TEXTAREA_ACTIONS.flatMap((action) => mapTextareaKeybindings(keybinds, action)),
]The hardcoded Current Defaults(from
These defaults are already in the config schema but are being ignored because of the hardcoded bindings. Minimal Fix PlanFile: Changes Required:
Result:
Behavior After Fix
|
can you show some proof of this working? cause the fix i provided does showcase the fix applied and the behaviour working as intended? |
Currently, in the process of trying to see what I have to do to actually test it. 03:34 UTC: Had a bunch of issues with typecheck, then finally was able to get it working in dev, but my implementation didn't fix it. Happy to try help though should need but not I am not technical Discord: Edit: consolidated messages. Note: wasn't trying to do a this way is better too btw. |
|
@kommander should i close this pr and open a more general fix pr on opentui? |
What does this PR do?
Video
Fixes #8038
Summary
Fixes Windows prompt behavior where
Shift+Enterwas treated likeEnter(submitting) instead of inserting a newline, restoring the intended “newline vs submit” UX.Details
Shift+Entercan be delivered as an unmodifiedreturnkey event, so it matches the textarea’sreturn → submitbinding (same path as plainEnter).packages/opencode/src/cli/cmd/tui/context/keybind.tsx:user32.dllviabun:ffiand callGetAsyncKeyState(VK_SHIFT)(VK_SHIFT = 0x10).evt.name === "return"evt.shift/ctrl/meta/super/hyperall falseGetAsyncKeyStateindicates Shift is currently down (state & 0x8000)evt.shift = truebefore matching keybinds.returnevents with no other modifiers and only onprocess.platform === "win32", so the change is intentionally limited to the broken case.How did you verify your code works?
Shift+Enter, submit withEnter).bun run typecheck(repo typecheck via the pre-push hook /turbo typecheck).