From 187ea0da1c70e6a906596a7538c43f2aea410054 Mon Sep 17 00:00:00 2001 From: James Tancock Date: Sun, 4 Sep 2016 15:50:39 +0100 Subject: [PATCH] Correct the number of spaces to add when a tab is inserted at an offset cursor. Fixes #268 --- cmd/micro/actions.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index e1b66c90..590719f5 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -687,6 +687,9 @@ func (v *View) InsertTab(usePlugin bool) bool { // Insert a tab if v.Buf.Settings["tabstospaces"].(bool) { tabSize := int(v.Buf.Settings["tabsize"].(float64)) + if remainder := v.Cursor.Loc.X % tabSize; remainder != 0 { + tabSize = tabSize - remainder + } v.Buf.Insert(v.Cursor.Loc, Spaces(tabSize)) for i := 0; i < tabSize; i++ { v.Cursor.Right()