microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.79k stars 28.74k forks source link

[Bug]: Incorrect outdentation when several closing braces are found on the same line #209537

Open aiday-mar opened 5 months ago

aiday-mar commented 5 months ago

Consider the following code:

function f() {
....if (1) {
....}}
....

Where the dots represent whitespaces. If you run Reindent Lines this will not change the indentation of the code, because the current language configuration file does not allow indentation and outdentation by more than 1 unit.

aiday-mar commented 5 months ago

To specify that we want to outdent twice, we can introduce a new enum value: IndentByNumberOfCaptureGroups, which will indent the number of times capture groups are detected from the regex test. If the regex is appropriately crafted, we could make it return 2 capture groups for the case above.