From c6b1b610c8013c78600c3ce18fb24d45e944b665 Mon Sep 17 00:00:00 2001 From: Gesa Hentschke Date: Sat, 11 Apr 2026 00:50:16 +0200 Subject: [PATCH] feat: support multiline/block comments for C/C++ Fixes #1003 Extending the onEnterRules --- .../cpp/c.language-configuration.json | 27 +++++++++++++++++++ .../cpp/cpp.language-configuration.json | 26 ++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/org.eclipse.tm4e.language_pack/syntaxes/cpp/c.language-configuration.json b/org.eclipse.tm4e.language_pack/syntaxes/cpp/c.language-configuration.json index cb1fb733b..58b416e33 100644 --- a/org.eclipse.tm4e.language_pack/syntaxes/cpp/c.language-configuration.json +++ b/org.eclipse.tm4e.language_pack/syntaxes/cpp/c.language-configuration.json @@ -122,11 +122,38 @@ }, "afterText": { "pattern": "^(?!\\s*$).+" + }, "action": { "indent": "none", "appendText": "// " } }, + // Start of /* or /** -> create block comment and indent + { + "beforeText": { + "pattern": "^\\s*/\\*\\*?" + }, + "afterText": { + "pattern": "^\\s*(\\*/)?$" + }, + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + // Inside block comment -> keep inside block comment and don't indent + { + "beforeText": { + "pattern": "^\\s*\\*(?!/)(?!.*\\*/\\s*$).*" + }, + "afterText": { + "pattern": "^\\s*" + }, + "action": { + "indent": "none", + "appendText": "* " + } + } ] } diff --git a/org.eclipse.tm4e.language_pack/syntaxes/cpp/cpp.language-configuration.json b/org.eclipse.tm4e.language_pack/syntaxes/cpp/cpp.language-configuration.json index cb1fb733b..b30fee7d1 100644 --- a/org.eclipse.tm4e.language_pack/syntaxes/cpp/cpp.language-configuration.json +++ b/org.eclipse.tm4e.language_pack/syntaxes/cpp/cpp.language-configuration.json @@ -128,5 +128,31 @@ "appendText": "// " } }, + // Start of /* or /** -> create block comment and indent + { + "beforeText": { + "pattern": "^\\s*/\\*\\*?" + }, + "afterText": { + "pattern": "^\\s*(\\*/)?$" + }, + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + // Inside block comment -> keep inside block comment and don't indent + { + "beforeText": { + "pattern": "^\\s*\\*(?!/)(?!.*\\*/\\s*$).*" + }, + "afterText": { + "pattern": "^\\s*" + }, + "action": { + "indent": "none", + "appendText": "* " + } + } ] }