Fix TUI regression where stash memo contained file path

This commit is contained in:
Christian Rocha 2022-01-29 21:44:25 -05:00
parent 11f627a132
commit 6aca2f5fe7
3 changed files with 5 additions and 4 deletions

View file

@ -297,7 +297,7 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) {
m.state = pagerStateStashing
cmds = append(
cmds,
stashDocument(m.common.cc, md),
stashDocument(m.common.cc, m.common.cwd, md),
m.spinner.Tick,
)
}

View file

@ -852,7 +852,7 @@ func (m *stashModel) handleDocumentBrowsing(msg tea.Msg) tea.Cmd {
m.common.filesStashing[md.stashID] = struct{}{}
m.common.latestFileStashed = md.stashID
cmds = append(cmds,
stashDocument(m.common.cc, *md),
stashDocument(m.common.cc, m.common.cwd, *md),
m.newStatusMessage(stashingStatusMessage),
)

View file

@ -615,7 +615,7 @@ func saveDocumentNote(cc *client.Client, id string, note string) tea.Cmd {
}
}
func stashDocument(cc *client.Client, md markdown) tea.Cmd {
func stashDocument(cc *client.Client, cwd string, md markdown) tea.Cmd {
return func() tea.Msg {
if cc == nil {
err := errors.New("can't stash; no charm client")
@ -660,7 +660,8 @@ func stashDocument(cc *client.Client, md markdown) tea.Cmd {
}
}
newMd, err := cc.StashMarkdown(md.Note, md.Body)
memo := stripAbsolutePath(md.Note, cwd)
newMd, err := cc.StashMarkdown(memo, md.Body)
if err != nil {
if debug {
log.Println("error stashing document:", err)