History

{osc,select}.lua: show playlist entries with trailing /

If a playlist entry ends with a slash these scripts only show the basename which is empty. Fix this by stripping trailing slashes so that the last directory component becomes the basename.

Guido Cella committed 2 years ago

Commit ee058041 parent 67bd00f2 files · +8 −2Browse files

Showing the changes to player/lua/select.lua (1 of 2 files). Show all

Unified · Split

player/lua/select.lua+4−1
@@ -29,13 +29,16 @@ mp.add_forced_key_binding(nil, "select-playlist", function () · 28 unmodified lines
2929 local playlist = {}
3030 local default_item
3131 local show = mp.get_property_native("osd-playlist-entry")
32+ local trailing_slash_pattern = mp.get_property("platform") == "windows"
33+ and "[/\\]+$" or "/+$"
3234
3335 for i, entry in ipairs(mp.get_property_native("playlist")) do
3436 playlist[i] = entry.title
3537 if not playlist[i] or show ~= "title" then
3638 playlist[i] = entry.filename
3739 if not playlist[i]:find("://") then
38− playlist[i] = select(2, utils.split_path(playlist[i]))
40+ playlist[i] = select(2, utils.split_path(
41+ playlist[i]:gsub(trailing_slash_pattern, "")))
3942 end
4043 end
4144 if entry.title and show == "both" then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t