Improve performance of path.tail() and path.extension() by not matching with end-anchor $

main
John Drouhard 3 years ago committed by ibhagwan
parent 02ad885d30
commit c78712c407

@ -155,7 +155,12 @@ end
M.make_entry_file = function(opts, x)
local icon, hl
local ret = {}
local file = utils.strip_ansi_coloring(string.match(x, '[^:]*'))
local file = x
for s in string.gmatch(x, '[^:]+') do
file = s
break
end
file = utils.strip_ansi_coloring(file)
if opts.cwd_only and path.starts_with_separator(file) then
local cwd = opts.cwd or vim.loop.cwd()
if not path.is_relative(file, cwd) then

@ -12,13 +12,21 @@ end
function M.tail(path)
local os_sep = M.separator()
local match_string = '[^' .. os_sep .. ']*$'
local match_string = '[^' .. os_sep .. ']+'
return string.match(path, match_string)
local tail = path
for s in string.gmatch(path, match_string) do
tail = s
end
return tail
end
function M.extension(path)
return string.match(path, '[%w_+$]*$')
local ext = path
for s in string.gmatch(path, '[^.]+') do
ext = s
end
return ext
end
function M.to_matching_str(path)

Loading…
Cancel
Save