Don't auto-detect commenttype if last_ft is empty

Also fixes commenttype for batch files.

Fixes #2752
This commit is contained in:
Zachary Yedidia
2023-02-15 21:57:12 -08:00
parent c492466583
commit 7dd88c2f23

View File

@@ -7,7 +7,7 @@ local buffer = import("micro/buffer")
local ft = {}
ft["apacheconf"] = "# %s"
ft["bat"] = ":: %s"
ft["batch"] = ":: %s"
ft["c"] = "// %s"
ft["c++"] = "// %s"
ft["cmake"] = "# %s"
@@ -63,7 +63,7 @@ ft["zsh"] = "# %s"
local last_ft
function updateCommentType(buf)
if buf.Settings["commenttype"] == nil or last_ft ~= buf.Settings["filetype"] then
if buf.Settings["commenttype"] == nil or (last_ft ~= buf.Settings["filetype"] and last_ft ~= nil) then
if ft[buf.Settings["filetype"]] ~= nil then
buf.Settings["commenttype"] = ft[buf.Settings["filetype"]]
else