fix: also populate stash when starting with a document

This commit is contained in:
themanyone 2026-05-28 05:22:29 -08:00
commit 4abc462f8e

View file

@ -117,6 +117,7 @@ type model struct {
func (m *model) unloadDocument() []tea.Cmd {
m.state = stateShowStash
m.stash.viewState = stashStateReady
m.stash.markdowns = nil
m.pager.unload()
m.pager.showHelp = false
@ -128,6 +129,12 @@ func (m *model) unloadDocument() []tea.Cmd {
if !m.stash.shouldSpin() {
batch = append(batch, m.stash.spinner.Tick)
}
// If we are transitioning from a document to the stash, we need to populate the stash.
if m.common.cwd != "" {
batch = append(batch, findLocalFiles(*m.common))
}
return batch
}
@ -397,6 +404,9 @@ func findLocalFiles(m commonModel) tea.Cmd {
info, err = os.Stat(cwd)
if err == nil && info.IsDir() {
cwd, err = filepath.Abs(cwd)
} else if err == nil {
cwd = filepath.Dir(cwd)
cwd, err = filepath.Abs(cwd)
}
}