From 17645ba4ecef15ca45ebf8b6b47a79493481f6b8 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 22 Mar 2022 10:17:42 -0400 Subject: [PATCH 1/2] Fixed anonyous syntaxes. --- data/plugins/detectindent.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/data/plugins/detectindent.lua b/data/plugins/detectindent.lua index ea9c8b28..405a5243 100644 --- a/data/plugins/detectindent.lua +++ b/data/plugins/detectindent.lua @@ -76,7 +76,7 @@ end local function get_comment_patterns(syntax) - if comments_cache[syntax.name] then + if syntax.name and comments_cache[syntax.name] then if #comments_cache[syntax.name] > 0 then return comments_cache[syntax.name] else @@ -123,7 +123,8 @@ local function get_comment_patterns(syntax) end end elseif pattern.syntax then - local subsyntax = core_syntax.get("file"..pattern.syntax, "") + local subsyntax = type(pattern.syntax) == 'table' and pattern.syntax + or core_syntax.get("file"..pattern.syntax, "") local sub_comments = get_comment_patterns(subsyntax) if sub_comments then for s=1, #sub_comments do @@ -149,7 +150,9 @@ local function get_comment_patterns(syntax) table.insert(comments, {"p", "^%s*" .. block_comment[1], block_comment[2]}) end end - comments_cache[syntax.name] = comments + if syntax.name then + comments_cache[syntax.name] = comments + end if #comments > 0 then return comments end From 3e7a97737e273d69ff1bcceb99fb68a3fb1f9132 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 22 Mar 2022 10:35:44 -0400 Subject: [PATCH 2/2] Re-enabled comment cache. --- data/plugins/detectindent.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/data/plugins/detectindent.lua b/data/plugins/detectindent.lua index 405a5243..ee03f034 100644 --- a/data/plugins/detectindent.lua +++ b/data/plugins/detectindent.lua @@ -76,9 +76,9 @@ end local function get_comment_patterns(syntax) - if syntax.name and comments_cache[syntax.name] then - if #comments_cache[syntax.name] > 0 then - return comments_cache[syntax.name] + if comments_cache[syntax] then + if #comments_cache[syntax] > 0 then + return comments_cache[syntax] else return nil end @@ -150,9 +150,7 @@ local function get_comment_patterns(syntax) table.insert(comments, {"p", "^%s*" .. block_comment[1], block_comment[2]}) end end - if syntax.name then - comments_cache[syntax.name] = comments - end + comments_cache[syntax] = comments if #comments > 0 then return comments end