Textarea: Ctrl/Cmd+Enter inserts a newline before emitting PressEnter { secondary: true }
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with enter in crates/base/src/input/base/state.rs and trace how action.secondary and is_code_editor() are handled. Check the input tests for multiline Enter behavior, then add coverage for Ctrl/Cmd+Enter in a regular textarea and a code editor. Done means the regular textarea keeps its text unchanged while emitting the secondary PressEnter event, and the code editor retains its existing behavior.
Written by the indexing model from the issue text.
Description
Description
In a multi-line field, a secondary Enter (Ctrl+Enter, Cmd+Enter on macOS) inserts a newline at the caret and then emits InputEvent::PressEnter { secondary: true }. enter in crates/base/src/input/base/state.rs decides from submit_on_enter and Shift only:
let insert_newline = self.is_multi_line() && (!self.submit_on_enter || action.shift);
Ctrl/Cmd+Enter is the usual submit gesture of a chat or comment field. When the application submits and clears the field, the extra line goes unseen. When it does not submit (the message cannot be sent yet, so the text is kept), a stray empty line is left in the text, before the caret.
Environment
- GPUI: gpui-pre 0.3.11
- GPUI Component: 0.9.0 (gpui-base 0.9.0); the same logic on main (checked at 7cace79d)
- Platform: Ubuntu 24.04.5; the code path is platform independent
Steps to Reproduce
- A
Textarea(InputState::new(window, cx).multi_line(true)), subscribe toInputEvent::PressEnter, and onsecondary: truedo nothing (do not clear the field). - Type "hello", press Home, then Ctrl+Enter.
Expected
The text stays "hello"; the event says the person asked to submit.
Actual
The text becomes "\nhello".
Suggested fix
A secondary Enter in a field that is not a code editor inserts nothing; the event is emitted as before. A code editor keeps its own meaning for Ctrl+Enter.
let secondary_submit = action.secondary && !self.is_code_editor();
let insert_newline =
self.is_multi_line() && !secondary_submit && (!self.submit_on_enter || action.shift);
- Dominant language
- Rust
- Stars
- 20k
- Forks
- 1.2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 276
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from longbridge/gpui-kit
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
longbridge/gpui-kit#3852 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
longbridge/gpui-kit#3850 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
longbridge/gpui-kit#3795 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
longbridge/gpui-kit#3735 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
longbridge/gpui-kit#3711 ·
Maintainers usually reply within 1 day
All issues in longbridge/gpui-kit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bytecodealliance/rustix#1736 ·
Maintainers usually reply within 1 day
-
area:models enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 84/100
servo/rust-smallvec#864 ·
-
bug frontend ui
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day