Add new line comment when pressing Enter from within line comment for languages that use double slash for line comment (#235407)

* add decrease and increase indent patterns for cpp

* adding new line with line comment on next line from within languages that use double slash for line comment
This commit is contained in:
Aiday Marlen Kyzy 2024-12-06 11:51:50 +01:00 committed by GitHub
parent 2443bffc6c
commit 359ec5270a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 941 additions and 169 deletions

View File

@ -1,29 +1,94 @@
{
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{ "open": "[", "close": "]" },
{ "open": "{", "close": "}" },
{ "open": "(", "close": ")" },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "/*", "close": "*/", "notIn": ["string", "comment"] },
{ "open": "/**", "close": " */", "notIn": ["string"] }
{
"open": "[",
"close": "]"
},
{
"open": "{",
"close": "}"
},
{
"open": "(",
"close": ")"
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "/*",
"close": "*/",
"notIn": [
"string",
"comment"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["<", ">"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"<",
">"
]
],
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
"folding": {
@ -32,6 +97,14 @@
"end": "^\\s*#pragma\\s+endregion\\b"
}
},
"indentationRules": {
"decreaseIndentPattern": {
"pattern": "^\\s*[\\}\\]\\)].*$"
},
"increaseIndentPattern": {
"pattern": "^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"
},
},
"onEnterRules": [
{
// Decrease indentation after single line if/else if/else, for, or while
@ -41,6 +114,19 @@
"action": {
"indent": "outdent"
}
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,32 +1,100 @@
{
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string",
"comment"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["<", ">"],
["'", "'"],
["\"", "\""]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"<",
">"
],
[
"'",
"'"
],
[
"\"",
"\""
]
],
"folding": {
"markers": {
"start": "^\\s*#region\\b",
"end": "^\\s*#endregion\\b"
}
}
},
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,28 +1,86 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "`", "close": "`", "notIn": ["string"]},
{ "open": "\"", "close": "\"", "notIn": ["string"]},
{ "open": "'", "close": "'", "notIn": ["string", "comment"]}
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "`",
"close": "`",
"notIn": [
"string"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"`",
"`"
]
],
"indentationRules": {
"increaseIndentPattern": "^.*(\\bcase\\b.*:|\\bdefault\\b:|(\\b(func|if|else|switch|select|for|struct)\\b.*)?{[^}\"'`]*|\\([^)\"'`]*)$",
@ -33,5 +91,20 @@
"start": "^\\s*//\\s*#?region\\b",
"end": "^\\s*//\\s*#?endregion\\b"
}
}
}
},
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,25 +1,88 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
]
],
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,28 +1,85 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "/**", "close": " */", "notIn": ["string"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["<", ">"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"<",
">"
]
],
"folding": {
"markers": {
@ -97,6 +154,19 @@
"action": {
"indent": "indent"
}
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,22 +1,84 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"]
[
"{",
"}"
],
[
"[",
"]"
]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string"] },
{ "open": "[", "close": "]", "notIn": ["string"] },
{ "open": "(", "close": ")", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }
{
"open": "{",
"close": "}",
"notIn": [
"string"
]
},
{
"open": "[",
"close": "]",
"notIn": [
"string"
]
},
{
"open": "(",
"close": ")",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string",
"comment"
]
},
{
"open": "`",
"close": "`",
"notIn": [
"string",
"comment"
]
}
],
"indentationRules": {
"increaseIndentPattern": "({+(?=((\\\\.|[^\"\\\\])*\"(\\\\.|[^\"\\\\])*\")*[^\"}]*)$)|(\\[+(?=((\\\\.|[^\"\\\\])*\"(\\\\.|[^\"\\\\])*\")*[^\"\\]]*)$)",
"decreaseIndentPattern": "^\\s*[}\\]],?\\s*$"
}
},
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,26 +1,88 @@
{
"comments": {
"blockComment": ["/*", "*/"],
"blockComment": [
"/*",
"*/"
],
"lineComment": "//"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string", "comment"] },
{ "open": "[", "close": "]", "notIn": ["string", "comment"] },
{ "open": "(", "close": ")", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
{
"open": "{",
"close": "}",
"notIn": [
"string",
"comment"
]
},
{
"open": "[",
"close": "]",
"notIn": [
"string",
"comment"
]
},
{
"open": "(",
"close": ")",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string",
"comment"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
]
],
"folding": {
"markers": {
@ -32,5 +94,20 @@
"increaseIndentPattern": "(^.*\\{[^}]*$)",
"decreaseIndentPattern": "^\\s*\\}"
},
"wordPattern": "(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]+(?=[^,{;]*[,{]))|(([@#.!])?[\\w-?]+%?|[@#!.])"
"wordPattern": "(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]+(?=[^,{;]*[,{]))|(([@#.!])?[\\w-?]+%?|[@#!.])",
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,25 +1,88 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
]
],
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,28 +1,96 @@
{
"comments": {
"lineComment": "//", // "#"
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string"] },
{ "open": "[", "close": "]", "notIn": ["string"] },
{ "open": "(", "close": ")", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "/**", "close": " */", "notIn": ["string"] }
{
"open": "{",
"close": "}",
"notIn": [
"string"
]
},
{
"open": "[",
"close": "]",
"notIn": [
"string"
]
},
{
"open": "(",
"close": ")",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string",
"comment"
]
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string",
"comment"
]
},
{
"open": "/**",
"close": " */",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["'", "'"],
["\"", "\""],
["`", "`"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"'",
"'"
],
[
"\"",
"\""
],
[
"`",
"`"
]
],
"indentationRules": {
"increaseIndentPattern": "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)",
@ -85,6 +153,19 @@
"action": {
"indent": "outdent"
}
}
},
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,25 +1,67 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["<", ">"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"<",
">"
]
],
"indentationRules": {
"increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$",
@ -30,5 +72,20 @@
"start": "^\\s*//\\s*#?region\\b",
"end": "^\\s*//\\s*#?endregion\\b"
}
}
},
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}

View File

@ -1,27 +1,99 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "`", "close": "`", "notIn": ["string"] }
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
},
{
"open": "'",
"close": "'",
"notIn": [
"string"
]
},
{
"open": "`",
"close": "`",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"]
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
],
[
"'",
"'"
],
[
"`",
"`"
]
],
"onEnterRules": [
// Add // when pressing enter from inside line comment
{
"beforeText": {
"pattern": "\/\/.*"
},
"afterText": {
"pattern": "^(?!\\s*$).+"
},
"action": {
"indent": "none",
"appendText": "// "
}
},
]
}