Remove line breaks when pasting into single line TextEdit (#7441)

The line breaks are now replaced by spaces, matching the usual behavior
of text fields in HTML.

* Closes <https://github.com/emilk/egui/issues/7389>
* [x] I have followed the instructions in the PR template

Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
This commit is contained in:
YgorSouza 2025-09-04 13:53:02 +02:00 committed by GitHub
parent 1c460b6dc0
commit 669cdc1fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -944,8 +944,12 @@ fn events(
Event::Paste(text_to_insert) => {
if !text_to_insert.is_empty() {
let mut ccursor = text.delete_selected(&cursor_range);
text.insert_text_at(&mut ccursor, text_to_insert, char_limit);
if multiline {
text.insert_text_at(&mut ccursor, text_to_insert, char_limit);
} else {
let single_line = text_to_insert.replace(['\r', '\n'], " ");
text.insert_text_at(&mut ccursor, &single_line, char_limit);
}
Some(CCursorRange::one(ccursor))
} else {