Restore original displayed path when deleting a newly stashed item

This commit is contained in:
Christian Rocha 2020-08-24 17:34:15 -04:00 committed by Christian Muehlhaeuser
parent 5515460f32
commit 2f9babce80
2 changed files with 5 additions and 6 deletions

View file

@ -59,6 +59,7 @@ const (
type markdown struct { type markdown struct {
markdownType markdownType markdownType markdownType
localPath string // only relevant to local files and converted files that are newly stashed 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 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 // If document was stashed during this session, convert it
// back to a local file. // back to a local file.
m.markdowns[i].markdownType = localMarkdown m.markdowns[i].markdownType = localMarkdown
m.markdowns[i].Note = m.markdowns[i].displayPath
} else { } else {
// Delete optimistically and remove the stashed item // Delete optimistically and remove the stashed item
// before we've received a success response. // before we've received a success response.

View file

@ -585,15 +585,12 @@ func localFileToMarkdown(cwd string, res gitcha.SearchResult) *markdown {
md := &markdown{ md := &markdown{
markdownType: localMarkdown, markdownType: localMarkdown,
localPath: res.Path, localPath: res.Path,
displayPath: strings.Replace(res.Path, cwd+"/", "", -1), // strip absolute path
Markdown: charm.Markdown{}, Markdown: charm.Markdown{},
} }
// Strip absolute path md.Markdown.Note = md.displayPath
md.Markdown.Note = strings.Replace(res.Path, cwd+"/", "", -1) md.CreatedAt = res.Info.ModTime() // last modified time
// Get last modified time
t := res.Info.ModTime()
md.CreatedAt = t
return md return md
} }