mirror of
https://github.com/neovim/neovim.git
synced 2026-04-25 08:44:06 +00:00
fix(filetype): normalize full path before matching #32227
Problem: On Windows, treesitter query files are not recognized as such when opened from inside their directory, because the full path returned from fnamemodify(_, ':p') contains backslashes, while the filetype patterns expect forward slashes. Solution: Normalize the result of fnamemodify(_, ':p') before trying to match it to filetype patterns. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -173,6 +173,23 @@ describe('vim.filetype', function()
|
||||
|
||||
eq(buf, api.nvim_get_current_buf())
|
||||
end)
|
||||
|
||||
it('matches full paths', function()
|
||||
mkdir('Xfiletype')
|
||||
command('lcd Xfiletype')
|
||||
eq(
|
||||
'Xfiletype',
|
||||
exec_lua(function()
|
||||
vim.filetype.add({
|
||||
pattern = {
|
||||
['.*/Xfiletype/Xfilename'] = 'Xfiletype',
|
||||
},
|
||||
})
|
||||
return vim.filetype.match({ filename = 'Xfilename' })
|
||||
end)
|
||||
)
|
||||
rmdir('Xfiletype')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('filetype.lua', function()
|
||||
|
||||
Reference in New Issue
Block a user