Skip to content

Commit

Permalink
fix display limit only showing up to half the set size
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyasuda committed Aug 14, 2023
1 parent 392b39c commit 61c9686
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mpv-youtube-queue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,17 @@ function YouTubeQueue.print_queue(duration)
local ass = assdraw.ass_new()
local current_index = index
if #video_queue > 0 then
local start_index = math.max(1,
selected_index - options.display_limit / 2)
local end_index = math.min(#video_queue,
start_index + options.display_limit - 1)
display_offset = start_index - 1
local half_limit = math.floor(options.display_limit / 2)
local start_index, end_index

if selected_index <= half_limit then
start_index = 1
else
start_index = selected_index - half_limit
end

end_index = start_index + options.display_limit - 1
if end_index > #video_queue then end_index = #video_queue end

ass:append(
style.header .. "MPV-YOUTUBE-QUEUE{\\u0\\b0}" .. style.reset ..
Expand Down

0 comments on commit 61c9686

Please sign in to comment.