New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code folding issue with trailing closures #1035
Comments
Tracked in Apple’s issue tracker as rdar://121580050 |
Just to be clear, you’re saying that it should have one for each trailing closure, right?
That sounds reasonable to me.
Thank you 🙏🏽 You’re already at the correct place for the implementation. I would start by adding a test case to https://github.com/apple/sourcekit-lsp/blob/main/Tests/SourceKitLSPTests/FoldingRangeTests.swift. Once you have that, you should be able to set breakpoints in |
Correct 👍🏻
Upon further thinking, this only fixes the issue of it covering up another brace... it wouldn't necessarily cause another folding range to be added for the closure. Right? I'll get to debugging :) |
I think (haven’t verified) that sourcekit-lsp does report a folding range for the second closure as well but VS Code just doesn’t display it because it overlaps with the folding range of the previous closure. sourcekit-lsp/Sources/SourceKitLSP/Swift/FoldingRange.swift Lines 128 to 133 in d5b06c8
|
@NSExceptional Are you still interested in pursuing this issue? |
Hey, yes, I'm sorry, I've just had a lot on my plate recently. I will try to get to it ASAP. |
Not an issue at all. Just wanted to check. |
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.
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:
sourcekit-lsp/Sources/SourceKitLSP/Swift/FoldingRange.swift
Lines 128 to 133 in a9242f8
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?The text was updated successfully, but these errors were encountered: