fix: buggy active chapter detection in chapters menu

closes #226
This commit is contained in:
tomasklaen
2022-09-22 15:05:44 +02:00
parent d2dd7e4415
commit 5082ad0a83

View File

@@ -4380,21 +4380,18 @@ mp.add_key_binding(nil, 'chapters', create_self_updating_menu_opener({
list_serializer = function(_, chapters) list_serializer = function(_, chapters)
local items = {} local items = {}
chapters = normalize_chapters(chapters) chapters = normalize_chapters(chapters)
local active_found = false for _, chapter in ipairs(chapters) do
for index, chapter in ipairs(chapters) do
local item = { local item = {
title = chapter.title or '', title = chapter.title or '',
hint = mp.format_time(chapter.time), hint = mp.format_time(chapter.time),
value = chapter.time, value = chapter.time,
} }
items[#items + 1] = item items[#items + 1] = item
if active_found == false then end
local is_active = chapter.time >= state.time for index = #items, 1, -1 do
if is_active then if state.time >= items[index].value then
item.active = true items[index].active = true
active_found = true break
end
end end
end end
return items return items