diff --git a/vendor/clink.lua b/vendor/clink.lua index d39a5ac..5e47246 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -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)