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

Method FindEndOfCurrentWord

document.go:191–198  ·  view source on GitHub ↗

FindEndOfCurrentWord returns an index relative to the cursor position. pointing to the end of the current word. Return 0 if nothing was found.

()

Source from the content-addressed store, hash-verified

189// FindEndOfCurrentWord returns an index relative to the cursor position.
190// pointing to the end of the current word. Return 0 if nothing was found.
191func (d *Document) FindEndOfCurrentWord() int {
192 x := d.TextAfterCursor()
193 i := strings.IndexByte(x, ' ')
194 if i != -1 {
195 return i
196 }
197 return len(x)
198}
199
200// FindEndOfCurrentWordWithSpace is almost the same as FindEndOfCurrentWord.
201// The only difference is to ignore contiguous spaces.

Calls 1

TextAfterCursorMethod · 0.95

Tested by 1