Code folding improvements + bugs
NSExceptional opened this issue · comments
Tanner Bennett commented
- Multi-line collections cannot be folded at all
- Individual cases in a
switch
cannot be folded at all - This range folds entirely into a single line when only the comment should be folded; instead, the first line of the decl right below it is also collapsed.
- Here, the folding marker is incorrectly on the line above the
return
statement. It is in the correct spot if the comment is removed. It behaves just like the above, where the following line is consumed by folding the comment. I'm guessing this implies all comments should be foldable, but that if a foldable statement exists below a comment, it mistakenly interferes with the ability to fold that statement.
- Trailing
)
's are not folded up the way trailing}
's are
Unless they're preceded by a}
:
Edit: Adding more below as I come across them
- Multiline function/init declarations, such as
func someMethodWithLotsOfArgs( <--- this part arg1: T, arg2: U, arg3: V, arg4: W, ... ) { <--- down to here ... }
Alex Hoppen commented
Tracked in Apple’s issue tracker as rdar://116877123
Alex Hoppen commented
I think the folding issues with comment should be fixed by #804 but the other issues are definitely also ones we should fix.
Alex Hoppen commented
If anyone is interesting in fixing these: The folding ranges are computed in
, which is a fairly isolatedSwiftSyntax
visitor that doesn’t require too much outside knowledge apart from swift-syntax trees.
Tests live in https://github.com/apple/sourcekit-lsp/blob/main/Tests/SourceKitLSPTests/FoldingRangeTests.swift