mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Dont panic during actions in the filtered stash view w/o items
Filterng down the stash to 0 items (no cursor is displayed as there are no items left) caused a panic during execution of one of these actions: - x: Delete - m: Set Memo - s: Stash file This change prevents that from happening by breaking the switch statement when there are no items left. Also glow now uses the filtered markdown notes in the `stashHelpView` so `m.selectedMarkdown()` cannot return a nil refernce anymore.
This commit is contained in:
parent
56847c1b01
commit
c91501655f
1 changed files with 13 additions and 1 deletions
14
ui/stash.go
14
ui/stash.go
|
@ -505,6 +505,10 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
|
|||
case "m":
|
||||
m.hideStatusMessage()
|
||||
|
||||
if pages == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
md := m.selectedMarkdown()
|
||||
isUserMarkdown := md.markdownType == stashedMarkdown || md.markdownType == convertedMarkdown
|
||||
isSettingNote := m.state == stashStateSettingNote
|
||||
|
@ -523,6 +527,10 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
|
|||
break
|
||||
}
|
||||
|
||||
if pages == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
md := m.selectedMarkdown()
|
||||
|
||||
// is the file in the process of being stashed?
|
||||
|
@ -553,6 +561,10 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
|
|||
case "x":
|
||||
m.hideStatusMessage()
|
||||
|
||||
if pages == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
t := m.selectedMarkdown().markdownType
|
||||
isUserMarkdown := t == stashedMarkdown || t == convertedMarkdown
|
||||
isValidState := m.state != stashStateSettingNote
|
||||
|
@ -933,7 +945,7 @@ func stashHelpView(m stashModel) string {
|
|||
isLocal bool
|
||||
)
|
||||
|
||||
if len(m.markdowns) > 0 {
|
||||
if len(m.getNotes()) > 0 {
|
||||
md := m.selectedMarkdown()
|
||||
isStashed = md != nil && md.markdownType == stashedMarkdown
|
||||
isLocal = md != nil && md.markdownType == localMarkdown
|
||||
|
|
Loading…
Reference in a new issue