From 3924e363d134bda6f618b4d14bd522ebe3a0e029 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 17 Jan 2018 17:37:17 -0500 Subject: [PATCH] Fix minor autoindent issue Fixes #985 --- cmd/micro/actions.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index b05abdfb..3a8b89dc 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -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()