Compare commits

...

3 Commits

Author SHA1 Message Date
Massimo Mund
e5ba376b82
Merge bbf6ec292e into dc7759204b 2024-07-04 13:46:20 +00:00
Massimo Mund
bbf6ec292e Implemented 'ResetSearch' to allow a search to be resetted
Added ResetSearch to the list of bindable actions in keybindings.md
2024-07-04 15:44:36 +02:00
Massimo Mund
f4d576b6e0 Allow action chaining of 'FindNext' and 'FindPrevious' 2024-06-08 11:06:54 +02:00
3 changed files with 17 additions and 0 deletions

View File

@ -1072,8 +1072,20 @@ func (h *BufPane) UnhighlightSearch() bool {
return true
}
// ResetSearch resets the last used search term
func (h *BufPane) ResetSearch() bool {
if h.Buf.LastSearch != "" {
h.Buf.LastSearch = ""
return true
}
return false
}
// FindNext searches forwards for the last used search term
func (h *BufPane) FindNext() bool {
if h.Buf.LastSearch == "" {
return false
}
// If the cursor is at the start of a selection and we search we want
// to search from the end of the selection in the case that
// the selection is a search result in which case we wouldn't move at
@ -1100,6 +1112,9 @@ func (h *BufPane) FindNext() bool {
// FindPrevious searches backwards for the last used search term
func (h *BufPane) FindPrevious() bool {
if h.Buf.LastSearch == "" {
return false
}
// If the cursor is at the end of a selection and we search we want
// to search from the beginning of the selection in the case that
// the selection is a search result in which case we wouldn't move at

View File

@ -811,6 +811,7 @@ var BufKeyActions = map[string]BufKeyAction{
"ToggleRuler": (*BufPane).ToggleRuler,
"ToggleHighlightSearch": (*BufPane).ToggleHighlightSearch,
"UnhighlightSearch": (*BufPane).UnhighlightSearch,
"ResetSearch": (*BufPane).ResetSearch,
"ClearStatus": (*BufPane).ClearStatus,
"ShellMode": (*BufPane).ShellMode,
"CommandMode": (*BufPane).CommandMode,

View File

@ -241,6 +241,7 @@ ToggleHelp
ToggleDiffGutter
ToggleRuler
JumpLine
ResetSearch
ClearStatus
ShellMode
CommandMode