diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index 40f4379c..4c5b8858 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -150,29 +150,31 @@ func BufMapEvent(k Event, action string) { actionfns = append(actionfns, afn) } bufAction := func(h *BufPane, te *tcell.EventMouse) bool { - success := true for i, a := range actionfns { - innerSuccess := true - cursors := h.Buf.GetCursors() - for j, c := range cursors { - if c == nil { - continue - } - h.Buf.SetCurCursor(c.Num) - h.Cursor = c - if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') { - innerSuccess = innerSuccess && h.execAction(a, names[i], j, te) - } else { - break + var success bool + if _, ok := MultiActions[names[i]]; ok { + success = true + for _, c := range h.Buf.GetCursors() { + h.Buf.SetCurCursor(c.Num) + h.Cursor = c + success = success && h.execAction(a, names[i], te) } + } else { + h.Buf.SetCurCursor(0) + h.Cursor = h.Buf.GetActiveCursor() + success = h.execAction(a, names[i], te) } + // if the action changed the current pane, update the reference h = MainTab().CurPane() - success = innerSuccess if h == nil { // stop, in case the current pane is not a BufPane break } + + if (!success && types[i] == '&') || (success && types[i] == '|') { + break + } } return true } @@ -562,39 +564,33 @@ func (h *BufPane) DoKeyEvent(e Event) bool { return more } -func (h *BufPane) execAction(action BufAction, name string, cursor int, te *tcell.EventMouse) bool { +func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse) bool { if name != "Autocomplete" && name != "CycleAutocompleteBack" { h.Buf.HasSuggestions = false } - _, isMulti := MultiActions[name] - if (!isMulti && cursor == 0) || isMulti { - if h.PluginCB("pre" + name) { - var success bool - switch a := action.(type) { - case BufKeyAction: - success = a(h) - case BufMouseAction: - success = a(h, te) - } - success = success && h.PluginCB("on"+name) - - if isMulti { - if recordingMacro { - if name != "ToggleMacro" && name != "PlayMacro" { - curmacro = append(curmacro, action) - } - } - } - - return success - } - } else { - // do nothing but return true, to not break the chain - return true + if !h.PluginCB("pre" + name) { + return false } - return false + var success bool + switch a := action.(type) { + case BufKeyAction: + success = a(h) + case BufMouseAction: + success = a(h, te) + } + success = success && h.PluginCB("on"+name) + + if _, ok := MultiActions[name]; ok { + if recordingMacro { + if name != "ToggleMacro" && name != "PlayMacro" { + curmacro = append(curmacro, action) + } + } + } + + return success } func (h *BufPane) completeAction(action string) {