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 {
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.

View file

@ -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
}