diff options
| author | xeluxee <88047141+xeluxee@users.noreply.github.com> | 2022-05-15 21:58:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-15 21:58:03 +0200 |
| commit | 20040cac31aac7cd41fc255178cf3f1351993359 (patch) | |
| tree | b9bbbea74b0b87a811098fed0f929921fd6fef97 /lua | |
| parent | 39b12d84e86f5054e2ed98829b367598ae53ab41 (diff) | |
fix: correctly use nvim-web-devicons (#1937)
Also performance improvements for utils.path_tail
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/utils.lua | 12 |
1 files 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 |
