Skip to content

comment function can't automatically close comment statement #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
raffeale opened this issue Feb 14, 2022 · 1 comment
Open

comment function can't automatically close comment statement #833

raffeale opened this issue Feb 14, 2022 · 1 comment
Assignees
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@raffeale
Copy link

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

@raffeale raffeale added the type: imperfection Perceived defect in any part of project label Feb 14, 2022
@per1234
Copy link
Contributor

per1234 commented Feb 14, 2022

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: microsoft/vscode#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:

  • https://github.com/microsoft/vscode-cpptools/issues/3891
  • https://github.com/microsoft/vscode-cpptools/issues/3904
  • https://github.com/microsoft/vscode/issues/77008

@per1234 per1234 added the topic: code Related to content of the project itself label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants