From 6aca2f5fe7c45ae3ebf57bb029505c1385c8edfb Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 29 Jan 2022 21:44:25 -0500 Subject: [PATCH] Fix TUI regression where stash memo contained file path --- ui/pager.go | 2 +- ui/stash.go | 2 +- ui/ui.go | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/pager.go b/ui/pager.go index 8f2de3b..29ebac6 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -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, ) } diff --git a/ui/stash.go b/ui/stash.go index 3470596..0adce4c 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -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), ) diff --git a/ui/ui.go b/ui/ui.go index b5d2688..26a699c 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -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)