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 <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-12-06 22:13:52 +01:00
parent 59720a8a58
commit 4e2d08c0a6
+3 -3
View File
@@ -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()