Fix the terminal width calculation for the select menu with these options.
Showing the changes to player/lua/console.lua (1 of 1 file). Show all
Unified · Split
| @@ -368,6 +368,21 @@ local function fuzzy_find(needle, haystacks) · 367 unmodified lines | ||
| 368 | 368 | return result |
| 369 | 369 | end |
| 370 | 370 | |
| 371 | +local function calculate_max_terminal_width() | |
| 372 | + local max_width = mp.get_property_native('term-size/w', 80) | |
| 373 | + | |
| 374 | + -- The longest module name is vo/gpu-next/libplacebo. | |
| 375 | + if mp.get_property_native('msg-module') then | |
| 376 | + max_width = max_width - 24 | |
| 377 | + end | |
| 378 | + | |
| 379 | + if mp.get_property_native('msg-time') then | |
| 380 | + max_width = max_width - 13 | |
| 381 | + end | |
| 382 | + | |
| 383 | + return max_width | |
| 384 | +end | |
| 385 | + | |
| 371 | 386 | local function populate_log_with_matches(max_width) |
| 372 | 387 | if not selectable_items or selected_match == 0 then |
| 373 | 388 | return |
| @@ -459,7 +474,7 @@ local function print_to_terminal() · 85 unmodified lines | ||
| 459 | 474 | return |
| 460 | 475 | end |
| 461 | 476 | |
| 462 | − populate_log_with_matches(mp.get_property_native('term-size/w', 80)) | |
| 477 | + populate_log_with_matches(calculate_max_terminal_width()) | |
| 463 | 478 | |
| 464 | 479 | local log = '' |
| 465 | 480 | for _, log_line in ipairs(log_buffers[id]) do |