From eb6daab1693f60d15daca0865fa1af01d1529eab Mon Sep 17 00:00:00 2001 From: Rein F Date: Mon, 6 Feb 2023 03:30:12 +0100 Subject: [PATCH] Make the commenttype option useful (#2735) --- runtime/plugins/comment/comment.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/runtime/plugins/comment/comment.lua b/runtime/plugins/comment/comment.lua index b06982d0..578f7422 100644 --- a/runtime/plugins/comment/comment.lua +++ b/runtime/plugins/comment/comment.lua @@ -60,11 +60,17 @@ ft["zig"] = "// %s" ft["zscript"] = "// %s" ft["zsh"] = "# %s" +local last_ft + function updateCommentType(buf) - if ft[buf.Settings["filetype"]] ~= nil and ft[buf.Settings["filetype"]] ~= nil then - buf.Settings["commenttype"] = ft[buf.Settings["filetype"]] - elseif buf.Settings["commenttype"] == nil then - buf.Settings["commenttype"] = "# %s" + if buf.Settings["commenttype"] == nil or last_ft ~= buf.Settings["filetype"] then + if ft[buf.Settings["filetype"]] ~= nil then + buf.Settings["commenttype"] = ft[buf.Settings["filetype"]] + else + buf.Settings["commenttype"] = "# %s" + end + + last_ft = buf.Settings["filetype"] end end