vscode-explicit-folding
vscode-explicit-folding copied to clipboard
Multi-lined signatures collapsing
Hi. I'm trying to achieve folding to one line if function signature is splitted to multiple lines:
"[typescript]": {
"explicitFolding.rules": [
{
"begin": "{",
"end": "}"
},
{
"begin": "[",
"end": "]"
},
{
"begin": "(",
"end": ")"
}
]
}
The case:
const compareDiagnostics = (
entry1: [vscode.Uri, vscode.Diagnostic[]],
entry2: [vscode.Uri, vscode.Diagnostic[]]
) => {
if (entry1[0].path < entry2[0].path) return -1
if (entry1[0].path > entry2[0].path) return 1
return 0
}
Currently, only function header folds, and body is not foldable.
The best what I managed to achieve, is to add 4th setting:
"[typescript]": {
"explicitFolding.rules": [
{
"begin": "{",
"end": "}"
},
{
"begin": "[",
"end": "]"
},
{
"begin": "(",
"end": ")"
},
{
"beginRegex": "^.*\\($",
"end": "}"
}
]
},
It seems, that 4th rule somehow matches, but doesn't works, and this way it excludes this case from processing by extension. This enables default VS Code folding here, which folds it to 2 lines (keeps trailing } on second line)
Is it possible to fold this case to one line in current version?
I have also tried some regular expressions, something like the (should be placed as first rule):
{
"beginRegex": "^.*\\($",
"middleRegex": "^\\) => \\{$",
"endRegex": "^\\}$"
}
This makes it foldable to two lines, but then the other, one-lined-signature cases stops working