File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed
Expand file tree Collapse file tree 2 files changed +14
-11
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
Original file line number Diff line number Diff line change @@ -80,18 +80,18 @@ but it is only available for certain filetypes:
8080* zsh: ` # %s `
8181
8282If your filetype is not available here, you can simply modify
83- the ` commenttype ` option:
83+ the ` comment.type ` option:
8484
8585```
86- set commenttype "/* %s */"
86+ set comment.type "/* %s */"
8787```
8888
8989Or in your ` settings.json ` :
9090
9191``` json
9292{
9393 "*.c" : {
94- "commenttype " : " /* %s */"
94+ "comment.type " : " /* %s */"
9595 }
9696}
9797```
You can’t perform that action at this time.
0 commit comments