From 2f9babce8054604ed8bcaa7265c20f9a77fb79b4 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 24 Aug 2020 17:34:15 -0400 Subject: [PATCH] Restore original displayed path when deleting a newly stashed item --- ui/stash.go | 2 ++ ui/ui.go | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ui/stash.go b/ui/stash.go index 9dba650..9ea5876 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -59,6 +59,7 @@ const ( type markdown struct { markdownType markdownType localPath string // only relevant to local files and converted files that are newly stashed + displayPath string // what we show in the note field charm.Markdown } @@ -526,6 +527,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { // If document was stashed during this session, convert it // back to a local file. m.markdowns[i].markdownType = localMarkdown + m.markdowns[i].Note = m.markdowns[i].displayPath } else { // Delete optimistically and remove the stashed item // before we've received a success response. diff --git a/ui/ui.go b/ui/ui.go index 7af03bd..52251c6 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -585,15 +585,12 @@ func localFileToMarkdown(cwd string, res gitcha.SearchResult) *markdown { md := &markdown{ markdownType: localMarkdown, localPath: res.Path, + displayPath: strings.Replace(res.Path, cwd+"/", "", -1), // strip absolute path Markdown: charm.Markdown{}, } - // Strip absolute path - md.Markdown.Note = strings.Replace(res.Path, cwd+"/", "", -1) - - // Get last modified time - t := res.Info.ModTime() - md.CreatedAt = t + md.Markdown.Note = md.displayPath + md.CreatedAt = res.Info.ModTime() // last modified time return md }