MCPcopy
hub / github.com/c-bata/go-prompt / FindStartOfPreviousWordWithSpace

Method FindStartOfPreviousWordWithSpace

document.go:141–153  ·  view source on GitHub ↗

FindStartOfPreviousWordWithSpace is almost the same as FindStartOfPreviousWord. The only difference is to ignore contiguous spaces.

()

Source from the content-addressed store, hash-verified

139// FindStartOfPreviousWordWithSpace is almost the same as FindStartOfPreviousWord.
140// The only difference is to ignore contiguous spaces.
141func (d *Document) FindStartOfPreviousWordWithSpace() int {
142 x := d.TextBeforeCursor()
143 end := istrings.LastIndexNotByte(x, ' ')
144 if end == -1 {
145 return 0
146 }
147
148 start := strings.LastIndexByte(x[:end], ' ')
149 if start == -1 {
150 return 0
151 }
152 return start + 1
153}
154
155// FindStartOfPreviousWordUntilSeparator is almost the same as FindStartOfPreviousWord.
156// But this can specify Separator. Return 0 if nothing was found.

Calls 1

TextBeforeCursorMethod · 0.95