commit d659947
Hubert Hirtz
·
2021-07-13 19:43:49 +0000 UTC
parent 7c26eb5
Don't send typing=done when input is already empty
3 files changed,
+8,
-7
M
app.go
+3,
-2
1@@ -320,8 +320,9 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
2 func (app *App) handleKeyEvent(ev *tcell.EventKey) {
3 switch ev.Key() {
4 case tcell.KeyCtrlC:
5- app.win.InputClear()
6- app.typing()
7+ if app.win.InputClear() {
8+ app.typing()
9+ }
10 case tcell.KeyCtrlL:
11 app.win.Resize()
12 case tcell.KeyCtrlU, tcell.KeyPgUp:
+3,
-3
1@@ -164,16 +164,16 @@ func (e *Editor) Flush() (content string) {
2 return
3 }
4
5-func (e *Editor) Clear() {
6+func (e *Editor) Clear() bool {
7 if e.TextLen() == 0 {
8- return
9+ return false
10 }
11 e.text[e.lineIdx] = []rune{}
12 e.textWidth = e.textWidth[:1]
13 e.cursorIdx = 0
14 e.offsetIdx = 0
15 e.autoCache = nil
16- return
17+ return true
18 }
19
20 func (e *Editor) Right() {
M
ui/ui.go
+2,
-2
1@@ -236,8 +236,8 @@ func (ui *UI) InputEnter() (content string) {
2 return ui.e.Flush()
3 }
4
5-func (ui *UI) InputClear() {
6- ui.e.Clear()
7+func (ui *UI) InputClear() bool {
8+ return ui.e.Clear()
9 }
10
11 func (ui *UI) Resize() {