More actions and view relocation

This commit is contained in:
Zachary Yedidia
2018-12-31 16:36:54 -05:00
parent 4815e9481a
commit 367a7bbb5f
6 changed files with 237 additions and 17 deletions

View File

@@ -231,3 +231,19 @@ func EscapePath(path string) string {
path = filepath.ToSlash(path)
return strings.Replace(path, "/", "%", -1)
}
// GetLeadingWhitespace returns the leading whitespace of the given byte array
func GetLeadingWhitespace(b []byte) []byte {
ws := []byte{}
for len(b) > 0 {
r, size := utf8.DecodeRune(b)
if r == ' ' || r == '\t' {
ws = append(ws, byte(r))
} else {
break
}
b = b[size:]
}
return ws
}