mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
When clearing the filter forget which markdowns were stashed in-session
This commit is contained in:
parent
3c74079669
commit
58df854466
1 changed files with 18 additions and 1 deletions
19
ui/stash.go
19
ui/stash.go
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue