add ~ match to vendor/clink.lua/

This commit is contained in:
Dax T. Games 2019-09-27 18:17:24 -04:00
parent 45e5600249
commit 3a44bc809d

17
vendor/clink.lua vendored
View File

@ -385,7 +385,24 @@ local function svn_prompt_filter()
return false
end
local function tilde_match (text, f, l)
if text == '~' then
clink.add_match(clink.get_env('userprofile'))
clink.matches_are_files()
return true
end
if text:sub(1, 1) == '~' then
clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1))
-- second match prevents adding a space so we can look for more matches
clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1) .. '+')
clink.matches_are_files()
return true
end
end
-- insert the set_prompt at the very beginning so that it runs first
clink.register_match_generator(tilde_match, 1)
clink.prompt.register_filter(set_prompt_filter, 1)
clink.prompt.register_filter(hg_prompt_filter, 50)
clink.prompt.register_filter(git_prompt_filter, 50)