Skip to content

Code folding issue with trailing closures #1035

Closed
@NSExceptional

Description

@NSExceptional

The following code only gets one folding expression, when it should have two, and it should ideally stop folding so that line 57 is not part of the folded range, since it has an opening brace on it as well, so you'd need to be able to show that line to be able to fold it too.

Screenshot 2024-01-24 at 11 55 12 PM

I would like to make a contribution to fix this myself, but I'm not sure where to start except that I know this is probably where the issue lies:

https://github.com/apple/sourcekit-lsp/blob/a9242f8a910487c92b1713eecb87149e69599d4a/Sources/SourceKitLSP/Swift/FoldingRange.swift#L128-L133

Imo, an easy fix—which would also address my personal opinion that we should mimic how Xcode code folds by not consuming the line with the closing } on it—would be to just adjust those lines to always stop on the line above the trailing brace. Then we wouldn't have to special-case this fix, either. Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions