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

Method skipMultiCursor

internal/action/actions.go:2270–2305  ·  view source on GitHub ↗
(forward bool)

Source from the content-addressed store, hash-verified

2268}
2269
2270func (h *BufPane) skipMultiCursor(forward bool) bool {
2271 lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1)
2272 if !lastC.HasSelection() {
2273 return false
2274 }
2275 sel := lastC.GetSelection()
2276 searchStart := lastC.CurSelection[1]
2277 if !forward {
2278 searchStart = lastC.CurSelection[0]
2279 }
2280
2281 search := string(sel)
2282 search = regexp.QuoteMeta(search)
2283 if h.multiWord {
2284 search = "\\b" + search + "\\b"
2285 }
2286
2287 match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, forward, true)
2288 if err != nil {
2289 InfoBar.Error(err)
2290 }
2291 if found {
2292 lastC.SetSelectionStart(match[0])
2293 lastC.SetSelectionEnd(match[1])
2294 lastC.OrigSelection[0] = lastC.CurSelection[0]
2295 lastC.OrigSelection[1] = lastC.CurSelection[1]
2296 lastC.Loc = lastC.CurSelection[1]
2297
2298 h.Buf.MergeCursors()
2299 h.Buf.SetCurCursor(h.Buf.NumCursors() - 1)
2300 } else {
2301 InfoBar.Message("No matches found")
2302 }
2303 h.Relocate()
2304 return true
2305}
2306
2307// SkipMultiCursor moves the current multiple cursor to the next available position
2308func (h *BufPane) SkipMultiCursor() bool {

Callers 2

SkipMultiCursorMethod · 0.95
SkipMultiCursorBackMethod · 0.95

Calls 14

GetCursorMethod · 0.80
NumCursorsMethod · 0.80
SetSelectionStartMethod · 0.80
SetSelectionEndMethod · 0.80
MergeCursorsMethod · 0.80
SetCurCursorMethod · 0.80
MessageMethod · 0.65
RelocateMethod · 0.65
HasSelectionMethod · 0.45
GetSelectionMethod · 0.45
FindNextMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected