Skip to content

Commit 80cd664

Browse files
Merge branch 'master' into dev
2 parents 205fb32 + 2259fd1 commit 80cd664

File tree

10 files changed

+171
-61
lines changed

10 files changed

+171
-61
lines changed

.github/workflows/release.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release builds
2+
on:
3+
workflow_dispatch: # Allows manual trigger
4+
# push:
5+
# tags:
6+
# - 'v*.*.*' # automatically react on semantic versioned tags
7+
jobs:
8+
release:
9+
strategy:
10+
matrix:
11+
go-version: [1.19.x]
12+
os: [ubuntu-latest]
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Setup
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: ${{ matrix.go-version }}
19+
cache: false
20+
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
fetch-tags: true
26+
27+
- name: Build
28+
run: tools/cross-compile.sh
29+
30+
- name: Publish
31+
uses: softprops/action-gh-release@v2
32+
with:
33+
files: binaries/*
34+
35+
- name: Cleanup
36+
run: rm -rf binaries

internal/action/actions.go

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (h *BufPane) paragraphPrevious() {
500500
}
501501
// Find the first empty line
502502
for ; line > 0; line-- {
503-
if len(h.Buf.LineBytes(line)) == 0 && line != h.Cursor.Y {
503+
if len(h.Buf.LineBytes(line)) == 0 {
504504
h.Cursor.X = 0
505505
h.Cursor.Y = line
506506
break
@@ -522,7 +522,7 @@ func (h *BufPane) paragraphNext() {
522522
}
523523
// Find the first empty line
524524
for ; line < h.Buf.LinesNum(); line++ {
525-
if len(h.Buf.LineBytes(line)) == 0 && line != h.Cursor.Y {
525+
if len(h.Buf.LineBytes(line)) == 0 {
526526
h.Cursor.X = 0
527527
h.Cursor.Y = line
528528
break
@@ -534,23 +534,29 @@ func (h *BufPane) paragraphNext() {
534534
}
535535
}
536536

537-
// ParagraphPrevious moves the cursor to the first empty line that comes before the paragraph closest to the cursor, or beginning of the buffer if there isn't a paragraph
537+
// ParagraphPrevious moves the cursor to the first empty line that comes before
538+
// the paragraph closest to the cursor, or beginning of the buffer if there
539+
// isn't a paragraph
538540
func (h *BufPane) ParagraphPrevious() bool {
539541
h.Cursor.Deselect(true)
540542
h.paragraphPrevious()
541543
h.Relocate()
542544
return true
543545
}
544546

545-
// ParagraphNext moves the cursor to the first empty line that comes after the paragraph closest to the cursor, or end of the buffer if there isn't a paragraph
547+
// ParagraphNext moves the cursor to the first empty line that comes after the
548+
// paragraph closest to the cursor, or end of the buffer if there isn't a
549+
// paragraph
546550
func (h *BufPane) ParagraphNext() bool {
547551
h.Cursor.Deselect(true)
548552
h.paragraphNext()
549553
h.Relocate()
550554
return true
551555
}
552556

553-
// SelectToParagraphPrevious selects to the first empty line that comes before the paragraph closest to the cursor, or beginning of the buffer if there isn't a paragraph
557+
// SelectToParagraphPrevious selects to the first empty line that comes before
558+
// the paragraph closest to the cursor, or beginning of the buffer if there
559+
// isn't a paragraph
554560
func (h *BufPane) SelectToParagraphPrevious() bool {
555561
if !h.Cursor.HasSelection() {
556562
h.Cursor.OrigSelection[0] = h.Cursor.Loc
@@ -561,7 +567,9 @@ func (h *BufPane) SelectToParagraphPrevious() bool {
561567
return true
562568
}
563569

564-
// SelectToParagraphNext selects to the first empty line that comes after the paragraph closest to the cursor, or end of the buffer if there isn't a paragraph
570+
// SelectToParagraphNext selects to the first empty line that comes after the
571+
// paragraph closest to the cursor, or end of the buffer if there isn't a
572+
// paragraph
565573
func (h *BufPane) SelectToParagraphNext() bool {
566574
if !h.Cursor.HasSelection() {
567575
h.Cursor.OrigSelection[0] = h.Cursor.Loc
@@ -1109,12 +1117,27 @@ func (h *BufPane) ToggleHighlightSearch() bool {
11091117

11101118
// UnhighlightSearch unhighlights all instances of the last used search term
11111119
func (h *BufPane) UnhighlightSearch() bool {
1120+
if !h.Buf.HighlightSearch {
1121+
return false
1122+
}
11121123
h.Buf.HighlightSearch = false
11131124
return true
11141125
}
11151126

1127+
// ResetSearch resets the last used search term
1128+
func (h *BufPane) ResetSearch() bool {
1129+
if h.Buf.LastSearch != "" {
1130+
h.Buf.LastSearch = ""
1131+
return true
1132+
}
1133+
return false
1134+
}
1135+
11161136
// FindNext searches forwards for the last used search term
11171137
func (h *BufPane) FindNext() bool {
1138+
if h.Buf.LastSearch == "" {
1139+
return false
1140+
}
11181141
// If the cursor is at the start of a selection and we search we want
11191142
// to search from the end of the selection in the case that
11201143
// the selection is a search result in which case we wouldn't move at
@@ -1141,6 +1164,9 @@ func (h *BufPane) FindNext() bool {
11411164

11421165
// FindPrevious searches backwards for the last used search term
11431166
func (h *BufPane) FindPrevious() bool {
1167+
if h.Buf.LastSearch == "" {
1168+
return false
1169+
}
11441170
// If the cursor is at the end of a selection and we search we want
11451171
// to search from the beginning of the selection in the case that
11461172
// the selection is a search result in which case we wouldn't move at
@@ -1189,15 +1215,19 @@ func (h *BufPane) DiffPrevious() bool {
11891215

11901216
// Undo undoes the last action
11911217
func (h *BufPane) Undo() bool {
1192-
h.Buf.Undo()
1218+
if !h.Buf.Undo() {
1219+
return false
1220+
}
11931221
InfoBar.Message("Undid action")
11941222
h.Relocate()
11951223
return true
11961224
}
11971225

11981226
// Redo redoes the last action
11991227
func (h *BufPane) Redo() bool {
1200-
h.Buf.Redo()
1228+
if !h.Buf.Redo() {
1229+
return false
1230+
}
12011231
InfoBar.Message("Redid action")
12021232
h.Relocate()
12031233
return true
@@ -1596,10 +1626,9 @@ func (h *BufPane) ToggleRuler() bool {
15961626
return true
15971627
}
15981628

1599-
// ClearStatus clears the messenger bar
1629+
// ClearStatus clears the infobar. It is an alias for ClearInfo.
16001630
func (h *BufPane) ClearStatus() bool {
1601-
InfoBar.Message("")
1602-
return true
1631+
return h.ClearInfo()
16031632
}
16041633

16051634
// ToggleHelp toggles the help screen
@@ -1654,12 +1683,18 @@ func (h *BufPane) Escape() bool {
16541683

16551684
// Deselect deselects on the current cursor
16561685
func (h *BufPane) Deselect() bool {
1686+
if !h.Cursor.HasSelection() {
1687+
return false
1688+
}
16571689
h.Cursor.Deselect(true)
16581690
return true
16591691
}
16601692

16611693
// ClearInfo clears the infobar
16621694
func (h *BufPane) ClearInfo() bool {
1695+
if InfoBar.Msg == "" {
1696+
return false
1697+
}
16631698
InfoBar.Message("")
16641699
return true
16651700
}
@@ -1750,6 +1785,10 @@ func (h *BufPane) AddTab() bool {
17501785
// PreviousTab switches to the previous tab in the tab list
17511786
func (h *BufPane) PreviousTab() bool {
17521787
tabsLen := len(Tabs.List)
1788+
if tabsLen == 1 {
1789+
return false
1790+
}
1791+
17531792
a := Tabs.Active() + tabsLen
17541793
Tabs.SetActive((a - 1) % tabsLen)
17551794

@@ -1758,8 +1797,13 @@ func (h *BufPane) PreviousTab() bool {
17581797

17591798
// NextTab switches to the next tab in the tab list
17601799
func (h *BufPane) NextTab() bool {
1800+
tabsLen := len(Tabs.List)
1801+
if tabsLen == 1 {
1802+
return false
1803+
}
1804+
17611805
a := Tabs.Active()
1762-
Tabs.SetActive((a + 1) % len(Tabs.List))
1806+
Tabs.SetActive((a + 1) % tabsLen)
17631807

17641808
return true
17651809
}
@@ -1795,6 +1839,10 @@ func (h *BufPane) Unsplit() bool {
17951839

17961840
// NextSplit changes the view to the next split
17971841
func (h *BufPane) NextSplit() bool {
1842+
if len(h.tab.Panes) == 1 {
1843+
return false
1844+
}
1845+
17981846
a := h.tab.active
17991847
if a < len(h.tab.Panes)-1 {
18001848
a++
@@ -1809,6 +1857,10 @@ func (h *BufPane) NextSplit() bool {
18091857

18101858
// PreviousSplit changes the view to the previous split
18111859
func (h *BufPane) PreviousSplit() bool {
1860+
if len(h.tab.Panes) == 1 {
1861+
return false
1862+
}
1863+
18121864
a := h.tab.active
18131865
if a > 0 {
18141866
a--
@@ -2010,6 +2062,9 @@ func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool {
20102062
// SkipMultiCursor moves the current multiple cursor to the next available position
20112063
func (h *BufPane) SkipMultiCursor() bool {
20122064
lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1)
2065+
if !lastC.HasSelection() {
2066+
return false
2067+
}
20132068
sel := lastC.GetSelection()
20142069
searchStart := lastC.CurSelection[1]
20152070

@@ -2045,17 +2100,24 @@ func (h *BufPane) RemoveMultiCursor() bool {
20452100
h.Buf.RemoveCursor(h.Buf.NumCursors() - 1)
20462101
h.Buf.SetCurCursor(h.Buf.NumCursors() - 1)
20472102
h.Buf.UpdateCursors()
2048-
} else {
2103+
} else if h.multiWord {
20492104
h.multiWord = false
2105+
h.Cursor.Deselect(true)
2106+
} else {
2107+
return false
20502108
}
20512109
h.Relocate()
20522110
return true
20532111
}
20542112

20552113
// RemoveAllMultiCursors removes all cursors except the base cursor
20562114
func (h *BufPane) RemoveAllMultiCursors() bool {
2057-
h.Buf.ClearCursors()
2058-
h.multiWord = false
2115+
if h.Buf.NumCursors() > 1 || h.multiWord {
2116+
h.Buf.ClearCursors()
2117+
h.multiWord = false
2118+
} else {
2119+
return false
2120+
}
20592121
h.Relocate()
20602122
return true
20612123
}

internal/action/bufpane.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,31 @@ func BufMapEvent(k Event, action string) {
150150
actionfns = append(actionfns, afn)
151151
}
152152
bufAction := func(h *BufPane, te *tcell.EventMouse) bool {
153-
cursors := h.Buf.GetCursors()
154-
success := true
155153
for i, a := range actionfns {
156-
innerSuccess := true
157-
for j, c := range cursors {
158-
if c == nil {
159-
continue
160-
}
161-
h.Buf.SetCurCursor(c.Num)
162-
h.Cursor = c
163-
if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') {
164-
innerSuccess = innerSuccess && h.execAction(a, names[i], j, te)
165-
} else {
166-
break
154+
var success bool
155+
if _, ok := MultiActions[names[i]]; ok {
156+
success = true
157+
for _, c := range h.Buf.GetCursors() {
158+
h.Buf.SetCurCursor(c.Num)
159+
h.Cursor = c
160+
success = success && h.execAction(a, names[i], te)
167161
}
162+
} else {
163+
h.Buf.SetCurCursor(0)
164+
h.Cursor = h.Buf.GetActiveCursor()
165+
success = h.execAction(a, names[i], te)
168166
}
167+
169168
// if the action changed the current pane, update the reference
170169
h = MainTab().CurPane()
171-
success = innerSuccess
172170
if h == nil {
173171
// stop, in case the current pane is not a BufPane
174172
break
175173
}
174+
175+
if (!success && types[i] == '&') || (success && types[i] == '|') {
176+
break
177+
}
176178
}
177179
return true
178180
}
@@ -562,36 +564,33 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
562564
return more
563565
}
564566

565-
func (h *BufPane) execAction(action BufAction, name string, cursor int, te *tcell.EventMouse) bool {
567+
func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse) bool {
566568
if name != "Autocomplete" && name != "CycleAutocompleteBack" {
567569
h.Buf.HasSuggestions = false
568570
}
569571

570-
_, isMulti := MultiActions[name]
571-
if (!isMulti && cursor == 0) || isMulti {
572-
if h.PluginCB("pre" + name) {
573-
var success bool
574-
switch a := action.(type) {
575-
case BufKeyAction:
576-
success = a(h)
577-
case BufMouseAction:
578-
success = a(h, te)
579-
}
580-
success = success && h.PluginCB("on"+name)
572+
if !h.PluginCB("pre" + name) {
573+
return false
574+
}
581575

582-
if isMulti {
583-
if recordingMacro {
584-
if name != "ToggleMacro" && name != "PlayMacro" {
585-
curmacro = append(curmacro, action)
586-
}
587-
}
588-
}
576+
var success bool
577+
switch a := action.(type) {
578+
case BufKeyAction:
579+
success = a(h)
580+
case BufMouseAction:
581+
success = a(h, te)
582+
}
583+
success = success && h.PluginCB("on"+name)
589584

590-
return success
585+
if _, ok := MultiActions[name]; ok {
586+
if recordingMacro {
587+
if name != "ToggleMacro" && name != "PlayMacro" {
588+
curmacro = append(curmacro, action)
589+
}
591590
}
592591
}
593592

594-
return false
593+
return success
595594
}
596595

597596
func (h *BufPane) completeAction(action string) {
@@ -813,6 +812,7 @@ var BufKeyActions = map[string]BufKeyAction{
813812
"ToggleRuler": (*BufPane).ToggleRuler,
814813
"ToggleHighlightSearch": (*BufPane).ToggleHighlightSearch,
815814
"UnhighlightSearch": (*BufPane).UnhighlightSearch,
815+
"ResetSearch": (*BufPane).ResetSearch,
816816
"ClearStatus": (*BufPane).ClearStatus,
817817
"ShellMode": (*BufPane).ShellMode,
818818
"CommandMode": (*BufPane).CommandMode,

internal/action/defaults_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ var bufdefaults = map[string]string{
6262
"PageDown": "CursorPageDown",
6363
"CtrlPageUp": "PreviousTab",
6464
"CtrlPageDown": "NextTab",
65+
"ShiftPageUp": "SelectPageUp",
66+
"ShiftPageDown": "SelectPageDown",
6567
"Ctrl-g": "ToggleHelp",
6668
"Alt-g": "ToggleKeyMenu",
6769
"Ctrl-r": "ToggleRuler",

0 commit comments

Comments
 (0)