arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.29k stars 389 forks source link

comment function can't automatically close comment statement #833

Open raffeale opened 2 years ago

raffeale commented 2 years ago

Describe the bug there is a bug in Arduino IDE 2.0, when I type /** and press enter key , the ide did not automatic close the comment statement!

Desktop (please complete the following information): os: MacOS 11.6 BigSur

per1234 commented 2 years ago

I'll add some additional information:

Arduino IDE 1.x adds a closing */ when Enter is pressed on a line that starts with an unclosed /*:

1-autoclose

Arduino IDE 2.x does not have any auto closing of block comments:

2-default

The VS Code built-in cpp extension used by Arduino IDE 2.x does allow this to be configured via the autoClosingPairs key in its language-configuration.json file:

--- a/resources/app/plugins/vscode-builtin-cpp/extension/language-configuration.json
+++ b/resources/app/plugins/vscode-builtin-cpp/extension/language-configuration.json
@@ -8,11 +8,12 @@
   "autoClosingPairs": [
     { "open": "[", "close": "]" },
     { "open": "{", "close": "}" },
     { "open": "(", "close": ")" },
     { "open": "'", "close": "'", "notIn": ["string", "comment"] },
-    { "open": "\"", "close": "\"", "notIn": ["string"] }
+    { "open": "\"", "close": "\"", "notIn": ["string"] },
+    { "open": "/*", "close": "*/", "notIn": ["string", "comment"] }
   ],
   "surroundingPairs": [
     ["{", "}"],
     ["[", "]"],
     ["(", ")"],

It seems this is not configurable via the settings UI: https://github.com/microsoft/vscode/issues/38352

However, that configuration does not result in behavior matching Arduino IDE 1.x:

2-autoclose

And that auto-closing behavior seems to be the source of frustration for people who are attempting to comment out blocks of existing code, which is a relatively common use for block comments: