Skip to content

Commit 4f4a13a

Browse files
authored
Implemented SkipMultiCursorBack as a counterpart to SkipMultiCursor (zyedidia#3404)
1 parent 9eaeb19 commit 4f4a13a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

internal/action/actions.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,22 +2167,24 @@ func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool {
21672167
return true
21682168
}
21692169

2170-
// SkipMultiCursor moves the current multiple cursor to the next available position
2171-
func (h *BufPane) SkipMultiCursor() bool {
2170+
func (h *BufPane) skipMultiCursor(forward bool) bool {
21722171
lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1)
21732172
if !lastC.HasSelection() {
21742173
return false
21752174
}
21762175
sel := lastC.GetSelection()
21772176
searchStart := lastC.CurSelection[1]
2177+
if !forward {
2178+
searchStart = lastC.CurSelection[0]
2179+
}
21782180

21792181
search := string(sel)
21802182
search = regexp.QuoteMeta(search)
21812183
if h.multiWord {
21822184
search = "\\b" + search + "\\b"
21832185
}
21842186

2185-
match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, true, true)
2187+
match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, forward, true)
21862188
if err != nil {
21872189
InfoBar.Error(err)
21882190
}
@@ -2202,6 +2204,16 @@ func (h *BufPane) SkipMultiCursor() bool {
22022204
return true
22032205
}
22042206

2207+
// SkipMultiCursor moves the current multiple cursor to the next available position
2208+
func (h *BufPane) SkipMultiCursor() bool {
2209+
return h.skipMultiCursor(true)
2210+
}
2211+
2212+
// SkipMultiCursorBack moves the current multiple cursor to the previous available position
2213+
func (h *BufPane) SkipMultiCursorBack() bool {
2214+
return h.skipMultiCursor(false)
2215+
}
2216+
22052217
// RemoveMultiCursor removes the latest multiple cursor
22062218
func (h *BufPane) RemoveMultiCursor() bool {
22072219
if h.Buf.NumCursors() > 1 {

internal/action/bufpane.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ var BufKeyActions = map[string]BufKeyAction{
851851
"RemoveMultiCursor": (*BufPane).RemoveMultiCursor,
852852
"RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors,
853853
"SkipMultiCursor": (*BufPane).SkipMultiCursor,
854+
"SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack,
854855
"JumpToMatchingBrace": (*BufPane).JumpToMatchingBrace,
855856
"JumpLine": (*BufPane).JumpLine,
856857
"Deselect": (*BufPane).Deselect,

runtime/help/keybindings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ SpawnMultiCursorSelect
274274
RemoveMultiCursor
275275
RemoveAllMultiCursors
276276
SkipMultiCursor
277+
SkipMultiCursorBack
277278
None
278279
JumpToMatchingBrace
279280
Autocomplete

0 commit comments

Comments
 (0)