Skip to content

Commit

Permalink
fix: playlist menu delete item shortcuts not working/crashing
Browse files Browse the repository at this point in the history
closes #958
  • Loading branch information
tomasklaen committed Aug 31, 2024
1 parent 43510c4 commit c55e9ff
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ function create_self_updating_menu_opener(opts)
---@type MenuAction[]
local actions = opts.actions or {}
if opts.on_move then
actions[#actions + 1] = {name = 'move_up', icon = 'arrow_upward', label = t('Move up') .. ' (ctrl+up)'}
actions[#actions + 1] = {name = 'move_down', icon = 'arrow_downward', label = t('Move down') .. ' (ctrl+down)'}
actions[#actions + 1] = {
name = 'move_up', icon = 'arrow_upward', label = t('Move up') .. ' (ctrl+up/pgup/home)'
}
actions[#actions + 1] = {
name = 'move_down', icon = 'arrow_downward', label = t('Move down') .. ' (ctrl+down/pgdwn/end)'
}
end
if opts.on_remove or opts.on_delete then
local label = (opts.on_remove and t('Remove') or t('Delete')) .. ' (del)'
Expand Down Expand Up @@ -138,11 +142,12 @@ function create_self_updating_menu_opener(opts)
if not event.modifiers then menu:close() end
end
elseif event.type == 'key' then
local item = event.selected_item
if event.id == 'enter' then
menu:close()
elseif event.key == 'del' then
if itable_has({'', 'ctrl'}, event.modifiers) then
remove_or_delete(event.index, event.value, event.menu_id, event.modifiers)
elseif event.key == 'del' and item then
if itable_has({nil, 'ctrl'}, event.modifiers) then
remove_or_delete(item.index, item.value, event.menu_id, event.modifiers)
end
end
elseif event.type == 'paste' and opts.on_paste then
Expand Down

0 comments on commit c55e9ff

Please sign in to comment.