]> git.lizzy.rs Git - micro.git/commitdiff
Fix minor autoindent issue
authorZachary Yedidia <zyedidia@gmail.com>
Wed, 17 Jan 2018 22:37:17 +0000 (17:37 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 17 Jan 2018 22:37:17 +0000 (17:37 -0500)
Fixes #985

cmd/micro/actions.go

index b05abdfb46cef1196d50b43d223b10eec22a3fd6..3a8b89dca62534d8345934f815f7d4ec4d527ee2 100644 (file)
@@ -695,10 +695,14 @@ func (v *View) InsertNewline(usePlugin bool) bool {
        }
 
        ws := GetLeadingWhitespace(v.Buf.Line(v.Cursor.Y))
+       cx := v.Cursor.X
        v.Buf.Insert(v.Cursor.Loc, "\n")
        // v.Cursor.Right()
 
        if v.Buf.Settings["autoindent"].(bool) {
+               if cx < len(ws) {
+                       ws = ws[0:cx]
+               }
                v.Buf.Insert(v.Cursor.Loc, ws)
                // for i := 0; i < len(ws); i++ {
                //      v.Cursor.Right()