diff --git a/internal/action/actions.go b/internal/action/actions.go index defc2b3e..cf6d954f 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -2167,14 +2167,16 @@ func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool { return true } -// SkipMultiCursor moves the current multiple cursor to the next available position -func (h *BufPane) SkipMultiCursor() bool { +func (h *BufPane) skipMultiCursor(forward bool) bool { lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1) if !lastC.HasSelection() { return false } sel := lastC.GetSelection() searchStart := lastC.CurSelection[1] + if !forward { + searchStart = lastC.CurSelection[0] + } search := string(sel) search = regexp.QuoteMeta(search) @@ -2182,7 +2184,7 @@ func (h *BufPane) SkipMultiCursor() bool { search = "\\b" + search + "\\b" } - match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, true, true) + match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, forward, true) if err != nil { InfoBar.Error(err) } @@ -2202,6 +2204,16 @@ func (h *BufPane) SkipMultiCursor() bool { return true } +// SkipMultiCursor moves the current multiple cursor to the next available position +func (h *BufPane) SkipMultiCursor() bool { + return h.skipMultiCursor(true) +} + +// SkipMultiCursorBack moves the current multiple cursor to the previous available position +func (h *BufPane) SkipMultiCursorBack() bool { + return h.skipMultiCursor(false) +} + // RemoveMultiCursor removes the latest multiple cursor func (h *BufPane) RemoveMultiCursor() bool { if h.Buf.NumCursors() > 1 { diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index b642a7e6..34cf0f30 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -851,6 +851,7 @@ var BufKeyActions = map[string]BufKeyAction{ "RemoveMultiCursor": (*BufPane).RemoveMultiCursor, "RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors, "SkipMultiCursor": (*BufPane).SkipMultiCursor, + "SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack, "JumpToMatchingBrace": (*BufPane).JumpToMatchingBrace, "JumpLine": (*BufPane).JumpLine, "Deselect": (*BufPane).Deselect, diff --git a/runtime/help/keybindings.md b/runtime/help/keybindings.md index d1eb3b05..a77d6a7b 100644 --- a/runtime/help/keybindings.md +++ b/runtime/help/keybindings.md @@ -274,6 +274,7 @@ SpawnMultiCursorSelect RemoveMultiCursor RemoveAllMultiCursors SkipMultiCursor +SkipMultiCursorBack None JumpToMatchingBrace Autocomplete