From e8272ea397ca79ef3e1c5b1e17b9cdcd658f3fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Sat, 8 Feb 2025 09:18:24 +0100 Subject: complete-filename: speed-up the tilda handling --- lua/plugins/complete-filename.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua index 02b9f3a..604361c 100644 --- a/lua/plugins/complete-filename.lua +++ b/lua/plugins/complete-filename.lua @@ -23,9 +23,10 @@ local complete_filename = function(expand) end -- Expand tilda for the home directory - if prefix:find('^~') then + _, j = prefix:find('^~') + if j ~= nil then local home = assert(os.getenv("HOME"), "$HOME variable not set!") - prefix = prefix:gsub("^~", home, 1) + prefix = home .. prefix:sub(j + 1) end local cmdfmt = "vis-complete --file '%s'" -- cgit v1.2.3