From 1b2a81fe6574e9b43098825dabe9ed1906329381 Mon Sep 17 00:00:00 2001 From: christoph-heinrich Date: Sat, 21 Oct 2023 16:31:37 +0200 Subject: [PATCH] fix: `delete-file-prev` not working as intended --- scripts/uosc/lib/utils.lua | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/scripts/uosc/lib/utils.lua b/scripts/uosc/lib/utils.lua index 7daeba0c..2945849e 100644 --- a/scripts/uosc/lib/utils.lua +++ b/scripts/uosc/lib/utils.lua @@ -548,35 +548,23 @@ function delete_file(path) end function delete_file_navigate(delta) - local next_file = nil - local is_local_file = state.path and not is_protocol(state.path) + local path, playlist_pos = state.path, state.playlist_pos + local is_local_file = path and not is_protocol(path) - if is_local_file then - if Menu:is_open('open-file') then Elements:maybe('menu', 'delete_value', state.path) end - end - - if state.has_playlist then - mp.commandv('playlist-remove', 'current') - else - if is_local_file then - local paths, current_index = get_adjacent_files(state.path, { - types = config.types.autoload, - hidden = options.show_hidden_files, - }) - if paths and current_index then - local index, path = decide_navigation_in_list(paths, current_index, delta) - if path then next_file = path end - end + if navigate_item(delta) then + if state.has_playlist then + mp.commandv('playlist-remove', playlist_pos - 1) end + else + mp.command('stop') + end - if next_file then - mp.commandv('loadfile', next_file) - else - mp.commandv('stop') + if is_local_file then + if Menu:is_open('open-file') then + Elements:maybe('menu', 'delete_value', path) end + delete_file(path) end - - if is_local_file then delete_file(state.path) end end function serialize_chapter_ranges(normalized_chapters)