mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 02:41:13 +00:00
console.lua: expand ~/ in file completion
Makes Tab expand loadfile ~/ to loadfile /home/$USER/. I used expand-path instead of os.getenv('HOME') to make it work on Windows.
This commit is contained in:
parent
5864b72d1a
commit
448cb4d13d
@ -1049,6 +1049,16 @@ function complete(backwards)
|
||||
completion_start_position = s2
|
||||
end
|
||||
|
||||
-- Expand ~ in file completion.
|
||||
if completer.list == file_list and hint:find('^~' .. path_separator) then
|
||||
local home = mp.command_native({'expand-path', '~/'})
|
||||
before_cur = before_cur:sub(1, completion_start_position - #hint - 1) ..
|
||||
home ..
|
||||
before_cur:sub(completion_start_position - #hint + 1)
|
||||
hint = home .. hint:sub(2)
|
||||
completion_start_position = completion_start_position + #home - 1
|
||||
end
|
||||
|
||||
-- If the completer's pattern found a word, check the completer's
|
||||
-- list for possible completions
|
||||
local part = before_cur:sub(completion_start_position)
|
||||
|
Loading…
Reference in New Issue
Block a user