Closed nobuhikosawai closed 1 year ago
I've done these
Looks good; I just cannot remember the original problem. I can't replicate the before/after in the description.
What's the test case? I'm trying icons_by_file_extension
["stories.tsx"] = {
icon = "X",
color = "#519aba",
cterm_color = "74",
name = "StoriesTsx",
},
This is the minimum steps to reproduce the original problem:
strict=true
on nvim-web-devicon.
require'nvim-web-devicons'.setup {
strict = true,
}
foo.test.js
in your project. (stories.tsx
has nothing to do with reproducing the problem. Apologies for the confusion.):Telescope find_files
.Expected behavior:
Since "test.js" is in the icons_by_file_extension
table, foo.test.js
should be displayed with the test.js icon.
Actual behavior:
foo.test.js
appears with js
icon, not test.js
icon.
You can reproduce this behavior with many other plugins (such as lualine.nvim) that support integration with nvim-web-devicons.
Please note that this is not a issue on nvim-tree because it has already been solved within the plugin itself after this PR (https://github.com/nvim-tree/nvim-tree.lua/pull/423).
As I have written as an example in my description, I have tested the following filenames:
py
icon correctly.(This is off-topic, but maybe we should have a test code.)
- Set
strict=true
on nvim-web-devicon.
Thank you; that seems to be the bit I was missing.
foo.test.js appears with js icon, not test.js icon.
I cannot replicate this on master. I can replicate it on your fork's master c2c2317 however the test.js and js icons are the same; test.js was updated at 87c3ded
I think I understand now:
local result = ""
local function tst(name, ext)
local icon, hl = require('nvim-web-devicons').get_icon(name, ext, { strict = true })
result = string.format("%s, %s (%s) %s %s", result, name, ext, icon, hl)
end
tst("test.js", "js")
tst("test.js", nil)
tst("foo.test.js", "test.js")
tst("foo.test.js", "js")
tst("foo.test.js", nil)
print(result)
master:
test.js (js) DevIconJs, test.js (nil) DevIconJs, foo.test.js (test.js) DevIconTestJs, foo.test.js (js) DevIconJs, foo.test.js (nil) DevIconJs
branch:
test.js (js) DevIconJs, test.js (nil) DevIconJs, foo.test.js (test.js) DevIconTestJs, foo.test.js (js) DevIconJs, foo.test.js (nil) DevIconTestJs
(This is off-topic, but maybe we should have a test code.)
Yes, that would greatly improve quality and reduce regressions.
I'd be most grateful if you could put something together!
fixes: https://github.com/nvim-tree/nvim-web-devicons/issues/206
I took @gegoune's approach on this comment (https://github.com/nvim-tree/nvim-web-devicons/issues/206#issuecomment-1436045476)
Before
After
(Note that I have set the custom icon on my config for
.stories.tsx
)