Maintain previous filtering after unloading a document

This commit is contained in:
Christian Rocha 2020-11-10 17:18:47 -05:00 committed by Christian Rocha
parent 6965caf3af
commit 75528db9f1
2 changed files with 6 additions and 7 deletions

View file

@ -221,7 +221,6 @@ func (m *stashModel) getNotes() []*markdown {
if m.searchInput.Value() == "" {
return m.markdowns
}
if m.state != stashStateSearchNotes &&
m.state != stashStateShowFiltered &&
m.state != stashStatePromptDelete &&
@ -480,11 +479,6 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
md := m.selectedMarkdown()
m.state = stashStateLoadingDocument
// This is only relevant when "enter" was called from the
// filtered stash view
m.searchInput.SetValue("")
m.setTotalPages()
if md.markdownType == localMarkdown {
cmds = append(cmds, loadLocalMarkdown(md))
} else {

View file

@ -156,10 +156,15 @@ type model struct {
// method alters the model we also need to send along any commands returned.
func (m *model) unloadDocument() []tea.Cmd {
m.state = stateShowStash
m.stash.state = stashStateReady
m.pager.unload()
m.pager.showHelp = false
if m.stash.searchInput.Value() == "" {
m.stash.state = stashStateReady
} else {
m.stash.state = stashStateShowFiltered
}
var batch []tea.Cmd
if m.pager.viewport.HighPerformanceRendering {
batch = append(batch, tea.ClearScrollArea)