summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-07-13 21:43:49 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-07-13 21:43:49 +0200
commitd6599473549aa8aee16106c0b80634d6510014dd (patch)
tree82b04a20806a47170617420dd8868dabe6dde594
parentAlways update prompt (diff)
Don't send typing=done when input is already empty
-rw-r--r--app.go5
-rw-r--r--ui/editor.go6
-rw-r--r--ui/ui.go4
3 files changed, 8 insertions, 7 deletions
diff --git a/app.go b/app.go
index 7a70c6e..820a356 100644
--- a/app.go
+++ b/app.go
@@ -320,8 +320,9 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
func (app *App) handleKeyEvent(ev *tcell.EventKey) {
switch ev.Key() {
case tcell.KeyCtrlC:
- app.win.InputClear()
- app.typing()
+ if app.win.InputClear() {
+ app.typing()
+ }
case tcell.KeyCtrlL:
app.win.Resize()
case tcell.KeyCtrlU, tcell.KeyPgUp:
diff --git a/ui/editor.go b/ui/editor.go
index 15785e8..a714587 100644
--- a/ui/editor.go
+++ b/ui/editor.go
@@ -164,16 +164,16 @@ func (e *Editor) Flush() (content string) {
return
}
-func (e *Editor) Clear() {
+func (e *Editor) Clear() bool {
if e.TextLen() == 0 {
- return
+ return false
}
e.text[e.lineIdx] = []rune{}
e.textWidth = e.textWidth[:1]
e.cursorIdx = 0
e.offsetIdx = 0
e.autoCache = nil
- return
+ return true
}
func (e *Editor) Right() {
diff --git a/ui/ui.go b/ui/ui.go
index 6fe0798..03a0aee 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -236,8 +236,8 @@ func (ui *UI) InputEnter() (content string) {
return ui.e.Flush()
}
-func (ui *UI) InputClear() {
- ui.e.Clear()
+func (ui *UI) InputClear() bool {
+ return ui.e.Clear()
}
func (ui *UI) Resize() {