fix(previewer): only run ftdetect for files (#2559)
This commit is contained in:
@@ -10,7 +10,7 @@ local utils = {}
|
|||||||
|
|
||||||
local detect_from_shebang = function(p)
|
local detect_from_shebang = function(p)
|
||||||
local s = p:readbyterange(0, 256)
|
local s = p:readbyterange(0, 256)
|
||||||
if not s then
|
if s then
|
||||||
local lines = vim.split(s, "\n")
|
local lines = vim.split(s, "\n")
|
||||||
return vim.filetype.match { contents = lines }
|
return vim.filetype.match { contents = lines }
|
||||||
end
|
end
|
||||||
@@ -40,7 +40,7 @@ utils.filetype_detect = function(filepath)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local p = Path:new(filepath)
|
local p = Path:new(filepath)
|
||||||
if p and p:exists() then
|
if p and p:is_file() then
|
||||||
match = detect_from_shebang(p)
|
match = detect_from_shebang(p)
|
||||||
if match and match ~= "" then
|
if match and match ~= "" then
|
||||||
return match
|
return match
|
||||||
|
|||||||
Reference in New Issue
Block a user