Skip to content

Commit 1abd2a0

Browse files
guidocellakasper93
authored andcommitted
console.lua: don't clip items if OSD dimensions are not initialized
If you open the menu at startup, e.g. with --input-commands, it rarely clips items completely because OSD dimensions are still 0, or as if they were 100 because those are the default values before receiving property notifications. Avoid this.
1 parent 609acc7 commit 1abd2a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

player/lua/console.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ end
203203

204204
-- Functions to calculate the font width.
205205
local width_length_ratio = 0.5
206-
local osd_width, osd_height = 100, 100
206+
local osd_width, osd_height = 0, 0
207207
local text_osd = mp.create_osd_overlay("ass-events")
208208
text_osd.compute_bounds, text_osd.hidden = true, true
209209

@@ -1651,7 +1651,12 @@ mp.register_script_message("get-input", function (script_name, args)
16511651

16521652
-- Limit the number of characters to prevent libass from freezing mpv.
16531653
-- Not important for terminal output.
1654-
local limit = terminal_output() and 5000 or (5 * osd_width / opts.font_size)
1654+
local limit
1655+
if osd_width == 0 or terminal_output() then
1656+
limit = 5000
1657+
else
1658+
limit = 5 * osd_width / opts.font_size
1659+
end
16551660

16561661
for i, item in ipairs(args.items) do
16571662
selectable_items[i] = item:gsub("[\r\n].*", ""):sub(1, limit)

0 commit comments

Comments
 (0)