From 4e2d08c0a629047c78350a8a28e633786d5b67df Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 6 Dec 2020 22:13:52 +0100 Subject: [PATCH] widget: replace newline with space in single-line Editors; cover SetText Move the replacing to Editor.prepend to fix SetText, and replace with space instead of nothing to keep lines separated even in single-line Editors. Signed-off-by: Elias Naur --- widget/editor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widget/editor.go b/widget/editor.go index 264a9929..30c6fb6d 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -645,14 +645,14 @@ func (e *Editor) Insert(s string) { } func (e *Editor) append(s string) { - if e.SingleLine { - s = strings.ReplaceAll(s, "\n", "") - } e.prepend(s) e.rr.caret += len(s) } func (e *Editor) prepend(s string) { + if e.SingleLine { + s = strings.ReplaceAll(s, "\n", " ") + } e.rr.prepend(s) e.caret.xoff = 0 e.invalidate()