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)
local items = {}
chapters = normalize_chapters(chapters)
local active_found = false
for index, chapter in ipairs(chapters) do
for _, chapter in ipairs(chapters) do
local item = {
title = chapter.title or '',
hint = mp.format_time(chapter.time),
value = chapter.time,
}
items[#items + 1] = item
if active_found == false then
local is_active = chapter.time >= state.time
if is_active then
item.active = true
active_found = true
end
end
for index = #items, 1, -1 do
if state.time >= items[index].value then
items[index].active = true
break
end
end
return items