mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(filetype): return on_detect function when matching by file contents
This commit is contained in:
parent
020d1f626a
commit
af38b46a25
@ -2377,11 +2377,16 @@ function M.match(args)
|
|||||||
-- If the function tries to use the filename that is nil then it will fail,
|
-- If the function tries to use the filename that is nil then it will fail,
|
||||||
-- but this enables checks which do not need a filename to still work.
|
-- but this enables checks which do not need a filename to still work.
|
||||||
local ok
|
local ok
|
||||||
ok, ft = pcall(require('vim.filetype.detect').match_contents, contents, name, function(ext)
|
ok, ft, on_detect = pcall(
|
||||||
return dispatch(extension[ext], name, bufnr)
|
require('vim.filetype.detect').match_contents,
|
||||||
end)
|
contents,
|
||||||
if ok and ft then
|
name,
|
||||||
return ft
|
function(ext)
|
||||||
|
return dispatch(extension[ext], name, bufnr)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
if ok then
|
||||||
|
return ft, on_detect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user