Added IndentString method on Buffer (#415)

* Added IndentString function to retrun the string used for indentation (n-spaces or a tab) based on buffer settings

* Combined redundant  statements

* Removed duplicate leading whitespace check

* Better IndentString description

* Fixed remainder logic that I broke
This commit is contained in:
Jon Craton
2016-10-15 10:09:20 -04:00
committed by Zachary Yedidia
parent 766f836952
commit fe0dce0960
2 changed files with 27 additions and 40 deletions

View File

@@ -182,6 +182,15 @@ func (b *Buffer) FileType() string {
return b.Settings["filetype"].(string)
}
// IndentString returns a string representing one level of indentation
func (b *Buffer) IndentString() string {
if b.Settings["tabstospaces"].(bool) {
return Spaces(int(b.Settings["tabsize"].(float64)))
} else {
return "\t"
}
}
// CheckModTime makes sure that the file this buffer points to hasn't been updated
// by an external program since it was last read
// If it has, we ask the user if they would like to reload the file