File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -63,18 +63,21 @@ ft["zscript"] = "// %s"
6363ft [" zsh" ] = " # %s"
6464
6565function updateCommentType (buf )
66- -- NOTE: Don't use SetOptionNative() to set "comment.type",
67- -- otherwise "comment.type" can't be reset by a "filetype" change.
68- if buf .Settings [" comment.type" ] == " " then
66+ -- NOTE: Using DoSetOptionNative to avoid LocalSettings[option] = true
67+ -- so that "comment.type" can be reset by a "filetype" change to default.
68+ if (buf .Settings [" comment.type" ] == " " ) then
69+ -- NOTE: This won't get triggered if a filetype is change via `setlocal filetype`
70+ -- since it is not registered with `RegisterGlobalOption()``
6971 if buf .Settings [" commenttype" ] ~= nil then
7072 micro .InfoBar ():Error (" \" commenttype\" option has been renamed to \" comment.type\" " ,
7173 " , please update your configuration" )
72- end
73-
74- if ft [buf .Settings [" filetype" ]] ~= nil then
75- buf .Settings [" comment.type" ] = ft [buf .Settings [" filetype" ]]
74+ buf :DoSetOptionNative (" comment.type" , buf .Settings [" commenttype" ])
7675 else
77- buf .Settings [" comment.type" ] = " # %s"
76+ if (ft [buf .Settings [" filetype" ]] ~= nil ) then
77+ buf :DoSetOptionNative (" comment.type" , ft [buf .Settings [" filetype" ]])
78+ else
79+ buf :DoSetOptionNative (" comment.type" , " # %s" )
80+ end
7881 end
7982 end
8083end
You can’t perform that action at this time.
0 commit comments