Skip to content

Commit

Permalink
When clearing the filter forget which markdowns were stashed in-session
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Dec 24, 2020
1 parent 3c74079 commit 58df854
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ui/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,27 @@ func (m *stashModel) setSize(width, height int) {
m.updatePagination()
}

// bakeConvertedDocs turns converted documents into stashed ones. Essentially,
// we're discarding the fact that they were ever converted so we can stop
// treating them like converted documents.
func (m *stashModel) bakeConvertedDocs() {
for _, md := range m.markdowns {
if md.docType == ConvertedDoc {
md.docType = StashedDoc
}
}
}

func (m *stashModel) resetFiltering() {
m.filterState = unfiltered
m.filterInput.Reset()
sort.Stable(markdownsByLocalFirst(m.markdowns))
m.filteredMarkdowns = nil

// Turn converted markdowns into stashed ones so that the next time we
// filter we get both local and stashed results.
m.bakeConvertedDocs()

sort.Stable(markdownsByLocalFirst(m.markdowns))
m.updatePagination()

if m.sections[len(m.sections)-1].key == filterSection {
Expand Down Expand Up @@ -759,6 +775,7 @@ func (m *stashModel) handleDocumentBrowsing(msg tea.Msg) tea.Cmd {
// Filter your notes
case "/":
m.hideStatusMessage()
m.bakeConvertedDocs()

// Build values we'll filter against
for _, md := range m.markdowns {
Expand Down

0 comments on commit 58df854

Please sign in to comment.