~eliasnaur/gio

4e2d08c0a629047c78350a8a28e633786d5b67df — Elias Naur 7 months ago 59720a8
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>
1 files changed, 3 insertions(+), 3 deletions(-)

M widget/editor.go
M widget/editor.go => widget/editor.go +3 -3
@@ 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()