fix(filetype): error when vim.filetype.match{buf=fn.bufadd('a.sh')} #34155

Problem: Error when `vim.filetype.match` a buffer with suffix `sh`.

Solution: fallback to an empty string as buffer content.
This commit is contained in:
phanium
2025-05-27 21:56:29 +08:00
committed by GitHub
parent 70697417c4
commit 8af28ab9cb

View File

@@ -1536,7 +1536,7 @@ local function sh(path, contents, name)
end
-- Get the name from the first line if not specified
name = name or contents[1]
name = name or contents[1] or ''
if name:find('^csh$') or matchregex(name, [[^#!.\{-2,}\<csh\>]]) then
-- Some .sh scripts contain #!/bin/csh.
return M.shell(path, contents, 'csh')