mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 13:57:07 +09:00
Remove auto indented spaces if the line is empty
This commit is contained in:
@@ -428,6 +428,11 @@ func (v *View) InsertNewline(usePlugin bool) bool {
|
||||
for i := 0; i < len(ws); i++ {
|
||||
v.Cursor.Right()
|
||||
}
|
||||
|
||||
if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y - 1)) {
|
||||
line := v.Buf.Line(v.Cursor.Y - 1)
|
||||
v.Buf.Remove(Loc{0, v.Cursor.Y - 1}, Loc{Count(line), v.Cursor.Y - 1})
|
||||
}
|
||||
}
|
||||
v.Cursor.LastVisualX = v.Cursor.GetVisualX()
|
||||
|
||||
|
||||
@@ -112,6 +112,17 @@ func IsSpaces(str string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsSpacesOrTabs checks if a given string contains only spaces and tabs
|
||||
func IsSpacesOrTabs(str string) bool {
|
||||
for _, c := range str {
|
||||
if c != ' ' && c != '\t' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// ParseBool is almost exactly like strconv.ParseBool, except it also accepts 'on' and 'off'
|
||||
// as 'true' and 'false' respectively
|
||||
func ParseBool(str string) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user