fix(icons): add guard against a stale cwd#2458
Conversation
This is what I'd expect, since
I did think about this, but 1) the current |
Our conversation yesterday, which in hindsight, I did not understand completely...). |
| local ok, ft = pcall(H.filetype_match, ('aaa.' .. name)) | ||
| if not ok then | ||
| ok, ft = pcall(H.filetype_match, ('~/aaa.' .. name)) | ||
| end | ||
| if ok and ft ~= nil then return MiniIcons.get('filetype', ft) end |
There was a problem hiding this comment.
I'd expect this all to be done in H.filetype_match with early return for the "happy" path. Less lines and covers more cases.
There doesn't seem to be a reason for why filetype matching for extension and file cases should differ.
|
Thanks for the PR! I've made some stylistic tweaks to make code more concise, have more direct "happy path", and with extra explanatory comment about why this is needed. |
Resolve #2455
Other approaches I considered:
mini.iconsshould never fail...aaa.<the_extension>, only test for~/aaa.<the_extension>. Reasoning:vim.filetype.matchwill create an absolute path anyway...