]> git.lizzy.rs Git - micro.git/commitdiff
Use "goto -1" to move cursor to end of document. (#1691)
authorAndrew Clarke <mail@ozzmosis.com>
Fri, 29 May 2020 17:29:09 +0000 (03:29 +1000)
committerGitHub <noreply@github.com>
Fri, 29 May 2020 17:29:09 +0000 (13:29 -0400)
internal/action/command.go

index cae2b3f6d9cda6ebff23cb2a8e34b9bce9cd7c49..b85117b79f5d8677714b0ac72cbf5e623f587008 100644 (file)
@@ -701,6 +701,9 @@ func (h *BufPane) GotoCmd(args []string) {
                                InfoBar.Error(err)
                                return
                        }
+                       if line < 0 {
+                               line = h.Buf.LinesNum() + 1 + line
+                       }
                        line = util.Clamp(line-1, 0, h.Buf.LinesNum()-1)
                        col = util.Clamp(col-1, 0, util.CharacterCount(h.Buf.LineBytes(line)))
                        h.Cursor.GotoLoc(buffer.Loc{col, line})
@@ -710,6 +713,9 @@ func (h *BufPane) GotoCmd(args []string) {
                                InfoBar.Error(err)
                                return
                        }
+                       if line < 0 {
+                               line = h.Buf.LinesNum() + 1 + line
+                       }
                        line = util.Clamp(line-1, 0, h.Buf.LinesNum()-1)
                        h.Cursor.GotoLoc(buffer.Loc{0, line})
                }