mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
slight refactor around freeze/unfreeze
This commit is contained in:
parent
eb3da9c70f
commit
19f9bd1be9
27
action.go
27
action.go
|
|
@ -900,6 +900,17 @@ func doGoToPreviousSelection(ctx context.Context, state *Peco, _ Event) {
|
|||
}
|
||||
}
|
||||
|
||||
// resetQueryState clears the query, resets the caret, and (unless sticky
|
||||
// selection is enabled) clears the selection. Used by freeze/unfreeze to
|
||||
// return to a clean query state.
|
||||
func resetQueryState(state *Peco) {
|
||||
state.Query().Reset()
|
||||
state.Caret().SetPos(0)
|
||||
if !state.config.StickySelection {
|
||||
state.Selection().Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func doFreezeResults(ctx context.Context, state *Peco, _ Event) {
|
||||
if pdebug.Enabled {
|
||||
g := pdebug.Marker("doFreezeResults")
|
||||
|
|
@ -921,13 +932,7 @@ func doFreezeResults(ctx context.Context, state *Peco, _ Event) {
|
|||
frozen.MarkComplete()
|
||||
|
||||
state.SetFrozenSource(frozen)
|
||||
state.Query().Reset()
|
||||
state.Caret().SetPos(0)
|
||||
|
||||
if !state.config.StickySelection {
|
||||
state.Selection().Reset()
|
||||
}
|
||||
|
||||
resetQueryState(state)
|
||||
state.SetCurrentLineBuffer(frozen)
|
||||
state.Hub().SendStatusMsg(ctx, "Results frozen")
|
||||
state.Hub().SendDrawPrompt(ctx)
|
||||
|
|
@ -945,13 +950,7 @@ func doUnfreezeResults(ctx context.Context, state *Peco, _ Event) {
|
|||
}
|
||||
|
||||
state.ClearFrozenSource()
|
||||
state.Query().Reset()
|
||||
state.Caret().SetPos(0)
|
||||
|
||||
if !state.config.StickySelection {
|
||||
state.Selection().Reset()
|
||||
}
|
||||
|
||||
resetQueryState(state)
|
||||
state.ResetCurrentLineBuffer()
|
||||
state.Hub().SendStatusMsg(ctx, "Results unfrozen")
|
||||
state.Hub().SendDrawPrompt(ctx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue