MCPcopy Index your code
hub / github.com/c-bata/go-prompt / FindStartOfPreviousWordUntilSeparator

Method FindStartOfPreviousWordUntilSeparator

document.go:157–168  ·  view source on GitHub ↗

FindStartOfPreviousWordUntilSeparator is almost the same as FindStartOfPreviousWord. But this can specify Separator. Return 0 if nothing was found.

(sep string)

Source from the content-addressed store, hash-verified

155// FindStartOfPreviousWordUntilSeparator is almost the same as FindStartOfPreviousWord.
156// But this can specify Separator. Return 0 if nothing was found.
157func (d *Document) FindStartOfPreviousWordUntilSeparator(sep string) int {
158 if sep == "" {
159 return d.FindStartOfPreviousWord()
160 }
161
162 x := d.TextBeforeCursor()
163 i := strings.LastIndexAny(x, sep)
164 if i != -1 {
165 return i + 1
166 }
167 return 0
168}
169
170// FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor is almost the same as FindStartOfPreviousWordWithSpace.
171// But this can specify Separator. Return 0 if nothing was found.

Calls 2

TextBeforeCursorMethod · 0.95

Tested by 1