1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

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 lucasmerlin
parent c749f372f7
commit ae94d815e2

View File

@@ -947,8 +947,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 {