Add auto indent

This commit is contained in:
Zachary Yedidia
2016-04-20 21:47:52 -04:00
parent 6aab17f445
commit 6d3344e4bd
3 changed files with 24 additions and 2 deletions

View File

@@ -377,8 +377,17 @@ func (v *View) HandleEvent(event tcell.Event) {
v.cursor.DeleteSelection()
v.cursor.ResetSelection()
}
v.eh.Insert(v.cursor.Loc(), "\n")
ws := GetLeadingWhitespace(v.buf.lines[v.cursor.y])
v.cursor.Right()
if settings.AutoIndent {
v.eh.Insert(v.cursor.Loc(), ws)
for i := 0; i < len(ws); i++ {
v.cursor.Right()
}
}
v.cursor.lastVisualX = v.cursor.GetVisualX()
case tcell.KeySpace:
// Insert a space