input: Fix prevent single-line input panic on multiline text (#2552) - #2586
Merged
huacnlee merged 9 commits intoJul 27, 2026
Merged
Conversation
Activating find (cmd-f) while a selection spans multiple lines pushed the multiline selection into the single-line search input via `set_value`, which later panicked in the single-line text shaper with "text argument should not contain newlines". Strip newlines centrally in `InputState::normalize_input` for single-line inputs, so every edit path (set_value, insert, paste, IME) is protected rather than just paste. The manual `\n` strip in `paste` is now redundant and removed (normalization also handles `\r`). Additionally, when opening search from a multiline selection, use only the first line of the selection as the query instead of the whole block. Adds a regression test reproducing the original panic.
huacnlee
requested changes
Jul 22, 2026
huacnlee
left a comment
Member
There was a problem hiding this comment.
That not a good solution.
We need support multiple paste. For example in Chrome if we have multiline text, the search input will replace \n to space.
Contributor
Author
I get it now, I'll fix it. |
Per review feedback: instead of dropping newlines from single-line inputs, collapse them to spaces (matching browser search/text inputs), so pasting or setting multiline text keeps word boundaries and stays usable. - `normalize_input` now replaces `\r\n`/`\n`/`\r` with a single space for single-line inputs (was: stripped entirely). - Search populated from a multiline selection becomes a single-line, space-joined query instead of just the first line. - Add a focused unit test for set_value/insert newline collapsing, and update the search regression test expectation.
Contributor
Author
|
The real machine test passed, the function is normal |
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
huacnlee
enabled auto-merge (squash)
July 27, 2026 06:50
huacnlee
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2552.
Activating find (cmd-f) while a selection spans multiple lines panicked the app with:
The multiline selection was pushed into the single-line search input via
set_value, and painting a single line whose text contains\npanics in gpui's text shaper (text_system.rs).Changes
InputState::normalize_input: for single-line inputs, collapse newlines to spaces (matching browser search/text inputs) —\r\n/\n/\rbecome a single space. This covers every edit path (set_value,insert,paste, IME), so multiline text stays usable instead of crashing the input.\nstrip inpaste(the central normalization handles it, including\r).test_single_line_collapses_newlines_to_spaces—set_value/insertwith mixed\n,\r\n,\rall collapse to spaces.test_search_with_multiline_selection— regression test for the original panic; asserts the single-line search input never holds a newline.Verification
Full input test suite passes (90 tests) and clippy is clean.