mirror of
https://github.com/charmbracelet/glow
synced 2024-09-28 20:23:45 +00:00
Fix bug where deleting newly stashed news could delete the wrong item
This commit is contained in:
parent
37a9b6846f
commit
ca0dfecb1c
16
ui/stash.go
16
ui/stash.go
|
@ -898,8 +898,8 @@ func (m *stashModel) handleDeleteConfirmation(msg tea.Msg) tea.Cmd {
|
|||
|
||||
return deleteStashedItem(m.common.cc, smd.ID)
|
||||
|
||||
// Any other key cancels deletion
|
||||
default:
|
||||
// Any other keys cancels deletion
|
||||
m.selectionState = selectionIdle
|
||||
}
|
||||
}
|
||||
|
@ -1356,17 +1356,9 @@ func deleteMarkdown(markdowns []*markdown, target *markdown) ([]*markdown, error
|
|||
index := -1
|
||||
|
||||
for i, v := range markdowns {
|
||||
switch target.markdownType {
|
||||
case ConvertedDoc:
|
||||
if v.markdownType == ConvertedDoc && v.localPath == target.localPath {
|
||||
index = i
|
||||
}
|
||||
case StashedDoc:
|
||||
if v.ID == target.ID {
|
||||
index = i
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("%s documents cannot be deleted", target.markdownType)
|
||||
if v.localID == target.localID {
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue