Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: delete-file-prev not working as intended #726

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions scripts/uosc/lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down