From a770a2425c08e3401250343fdc5c4065f6eafaa4 Mon Sep 17 00:00:00 2001 From: Larry Clapp Date: Sun, 10 Nov 2019 16:02:11 -0500 Subject: [PATCH] widget: no newline in editor on submit When you press enter to "submit" an editor widget, don't also append the newline to the editor text. Enter should be "submit" or "add newline" but not both. Also add parens to the Enter check: x && y || z => x && (y || z). Signed-off-by: Larry Clapp --- widget/editor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widget/editor.go b/widget/editor.go index 6c2a64d8..6e63f925 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -153,11 +153,12 @@ func (e *Editor) processKey(gtx *layout.Context) { if !e.focused { break } - if e.Submit && ke.Name == key.NameReturn || ke.Name == key.NameEnter { + if e.Submit && (ke.Name == key.NameReturn || ke.Name == key.NameEnter) { if !ke.Modifiers.Contain(key.ModShift) { e.events = append(e.events, SubmitEvent{ Text: e.Text(), }) + return } } if e.command(ke) {