mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(filetype): make filetype detection work with :doautocmd (#31470)
This commit is contained in:
parent
367182abd5
commit
1077843b9b
@ -13,8 +13,8 @@ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, {
|
|||||||
end
|
end
|
||||||
local ft, on_detect = vim.filetype.match({
|
local ft, on_detect = vim.filetype.match({
|
||||||
-- The unexpanded file name is needed here. #27914
|
-- The unexpanded file name is needed here. #27914
|
||||||
-- Neither args.file nor args.match are guaranteed to be unexpanded.
|
-- However, bufname() can't be used, as it doesn't work with :doautocmd. #31306
|
||||||
filename = vim.fn.bufname(args.buf),
|
filename = args.file,
|
||||||
buf = args.buf,
|
buf = args.buf,
|
||||||
})
|
})
|
||||||
if not ft then
|
if not ft then
|
||||||
|
@ -208,7 +208,7 @@ describe('filetype.lua', function()
|
|||||||
eq('gitconfig', api.nvim_get_option_value('filetype', {}))
|
eq('gitconfig', api.nvim_get_option_value('filetype', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
pending('works with :doautocmd BufRead #31306', function()
|
it('works with :doautocmd BufRead #31306', function()
|
||||||
clear({ args = { '--clean' } })
|
clear({ args = { '--clean' } })
|
||||||
eq('', api.nvim_get_option_value('filetype', {}))
|
eq('', api.nvim_get_option_value('filetype', {}))
|
||||||
command('doautocmd BufRead README.md')
|
command('doautocmd BufRead README.md')
|
||||||
|
Loading…
Reference in New Issue
Block a user