mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-20 23:24:18 +02:00
fix: also populate stash when starting with a document
This commit is contained in:
parent
5fc505d42e
commit
4abc462f8e
1 changed files with 10 additions and 0 deletions
10
ui/ui.go
10
ui/ui.go
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue