]> git.lizzy.rs Git - micro.git/commitdiff
Correct the number of spaces to add when a tab is inserted at an offset cursor.
authorJames Tancock <james.tancock@momentumft.co.uk>
Sun, 4 Sep 2016 14:50:39 +0000 (15:50 +0100)
committerJames Tancock <james.tancock@momentumft.co.uk>
Sun, 4 Sep 2016 14:50:39 +0000 (15:50 +0100)
Fixes #268

cmd/micro/actions.go

index e1b66c90bcf98bc21283a993b9a732fb86f0b991..590719f5395fa7791f82085b98613fa962721f98 100644 (file)
@@ -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()