From 20040cac31aac7cd41fc255178cf3f1351993359 Mon Sep 17 00:00:00 2001 From: xeluxee <88047141+xeluxee@users.noreply.github.com> Date: Sun, 15 May 2022 21:58:03 +0200 Subject: [PATCH] fix: correctly use nvim-web-devicons (#1937) Also performance improvements for utils.path_tail --- lua/telescope/utils.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index 46eee27..133a120 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -179,10 +179,14 @@ end)() utils.path_tail = (function() local os_sep = utils.get_separator() - local match_string = "[^" .. os_sep .. "]*$" return function(path) - return string.match(path, match_string) + for i = #path, 1, -1 do + if path:sub(i, i) == os_sep then + return path:sub(i + 1, -1) + end + end + return path end end)() @@ -431,7 +435,7 @@ utils.transform_devicons = load_once(function() return display end - local icon, icon_highlight = devicons.get_icon(filename, string.match(filename, "%a+$"), { default = true }) + local icon, icon_highlight = devicons.get_icon(utils.path_tail(filename), nil, { default = true }) local icon_display = (icon or " ") .. " " .. (display or "") if conf.color_devicons then @@ -461,7 +465,7 @@ utils.get_devicons = load_once(function() return "" end - local icon, icon_highlight = devicons.get_icon(filename, string.match(filename, "%a+$"), { default = true }) + local icon, icon_highlight = devicons.get_icon(utils.path_tail(filename), nil, { default = true }) if conf.color_devicons then return icon, icon_highlight else