Skip checking files if no filename was provided to syntax.get

This commit is contained in:
Guldoman authored and takase1121 committed 2023-08-19 13:29:48 +08:00
1 parent b5617a3eef
commit e9678cc140
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ function Doc:reset_syntax()
path = core.project_dir .. PATHSEP .. self.filename path = core.project_dir .. PATHSEP .. self.filename
end end
if path then path = common.normalize_path(path) end if path then path = common.normalize_path(path) end
local syn = syntax.get(path or "", header) local syn = syntax.get(path, header)
if self.syntax ~= syn then if self.syntax ~= syn then
self.syntax = syn self.syntax = syn
self.highlighter:soft_reset() self.highlighter:soft_reset()
+1 -1
View File
@@ -44,7 +44,7 @@ local function find(string, field)
end end
function syntax.get(filename, header) function syntax.get(filename, header)
return find(filename, "files") return (filename and find(filename, "files"))
or (header and find(header, "headers")) or (header and find(header, "headers"))
or plain_text_syntax or plain_text_syntax
end end