commit 435d102
Hubert Hirtz
·
2020-08-18 16:56:32 +0000 UTC
parent 6c00c6e
editor: Don't add another line if the last one is empty
1 files changed,
+6,
-2
+6,
-2
1@@ -101,8 +101,12 @@ func (e *editor) remRuneAt(idx int) {
2
3 func (e *editor) Flush() (content string) {
4 content = string(e.text[e.lineIdx])
5- e.lineIdx = len(e.text)
6- e.text = append(e.text, []rune{})
7+ if len(e.text[len(e.text)-1]) == 0 {
8+ e.lineIdx = len(e.text) - 1
9+ } else {
10+ e.lineIdx = len(e.text)
11+ e.text = append(e.text, []rune{})
12+ }
13 e.textWidth = e.textWidth[:1]
14 e.cursorIdx = 0
15 e.offsetIdx = 0