MCPcopy
hub / github.com/micro-editor/micro / GetLeadingWhitespace

Function GetLeadingWhitespace

internal/util/util.go:500–513  ·  view source on GitHub ↗

GetLeadingWhitespace returns the leading whitespace of the given byte array

(b []byte)

Source from the content-addressed store, hash-verified

498
499// GetLeadingWhitespace returns the leading whitespace of the given byte array
500func GetLeadingWhitespace(b []byte) []byte {
501 ws := []byte{}
502 for len(b) > 0 {
503 r, _, size := DecodeCharacter(b)
504 if r == ' ' || r == '\t' {
505 ws = append(ws, byte(r))
506 } else {
507 break
508 }
509
510 b = b[size:]
511 }
512 return ws
513}
514
515// GetTrailingWhitespace returns the trailing whitespace of the given byte array
516func GetTrailingWhitespace(b []byte) []byte {

Callers 6

displayBufferMethod · 0.92
InsertNewlineMethod · 0.92
OutdentLineMethod · 0.92
OutdentSelectionMethod · 0.92
pasteMethod · 0.92
RetabMethod · 0.92

Calls 1

DecodeCharacterFunction · 0.70

Tested by

no test coverage detected