Closed lastobelus closed 3 years ago
+1
@lastobelus I've took another look at the issue. It seems that ElixirLS
doesn't provide any foldings so VSCode uses the indentation provider as a fallback. So when my extension provides a folding, that fallback doesn't happened and so the rest of the code doesn't have any foldings...
I'm not sure how the language foldings are defined but here what I've found in ElixirLS
:
elixir-language-configuration.json
"folding": {
"markers": {
"start": "^\\s*(@(moduledoc|typedoc|doc)\\b\\s+\"\"\")|(#\\s*region\\b)",
"end": "^\\s+(\"\"\")|(#\\s*endregion\\b)",
}
}
syntaxes/elixir.json
"foldingStartMarker": "(after\|else\|catch\|rescue\|\\-\\>\|\\{\|\\[\|do)\\s*$",
"foldingStopMarker": "^\\s*((\\}\|\\]\|after\|else\|catch\|rescue)\\s*$\|end\\b)",
Looks like # region
should have been already folded.
If you remove the do
and the end of the first line of your code, VSCode is still folding the module when it shouldn't based on the given regexes (it's folded due to the indent).
I've just added the support for "editor.foldingStrategy": "explicit & indentation"
in MrCode (my version of VSCode).
With that config, both my extension and the indentation provider can provide foldings at the same time. I've tested it and it's working.
@lastobelus Can you try the following configuration with the latest version of the extension?
"folding": {
"elixir": [
{
"beginRegex": "#\\s*region\\b",
"endRegex": "#\\s*endregion\\b"
},
{
"indentation": true
}
],
}
"folding": {
"python": [
{
"beginRegex": "\"\"\"",
"endRegex": "\"\"\""
},
{
"indentation": true
}
],
},
Works fantastic in Python 🥳
VSCode Version: 1.50.1
With this extension installed and a folding rule added, Elixir code folds only by this extension's rules (as though your explicit strategy PR were implemented :) )
This also seems to be happening in other folding extensions and/or language servers (ex: see this issue).
Not all languages have this problem, for example javascript files seemed fine.
Some elixir code for testing (using the ElixirLS extension):
Adding any rule to "folding" settings will break default folding, whether or not it matches.
(my reason for using your extension is that the built-in VSCode
# region
folding requires no indent on the# region
comment, but the elixir ls autoformats all comments to match the indent of surrounding code.)