From 2767ac3718fb462420f2906346490d28af190376 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 3 Jul 2023 22:39:54 +0200 Subject: [PATCH] Skip checking `files` if no filename was provided to `syntax.get` --- data/core/doc/init.lua | 2 +- data/core/syntax.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index bf5895fb..086e9f3e 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -49,7 +49,7 @@ function Doc:reset_syntax() path = core.project_dir .. PATHSEP .. self.filename 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 self.syntax = syn self.highlighter:soft_reset() diff --git a/data/core/syntax.lua b/data/core/syntax.lua index 977983c1..9862fbdf 100644 --- a/data/core/syntax.lua +++ b/data/core/syntax.lua @@ -44,7 +44,7 @@ local function find(string, field) end function syntax.get(filename, header) - return find(filename, "files") + return (filename and find(filename, "files")) or (header and find(header, "headers")) or plain_text_syntax end