LSP: Allow for folding documentation in code editors
#5813 aperta il 5 giu 2026
Metriche repository
- Star
- (21.417 stelle)
- Metriche merge PR
- (Merge medio 10g 19h) (69 PR mergiate in 30 g)
Descrizione
Similar to the feature that allows for code editors to collapse the contents of a function.
Telling the code editor about which sections of the code can be folded and which can't is the LSP's job, and so the issue is made here.
Implementation idea
Note: I'm not at all familiar with the inner workings of the LSP protocol, so take everything I say here with a healthy pinch of salt
Make the LSP keep track of the beginning and end of code documentation (module-level documentation marked by ////, and type and function documentation marked by ///), and communicate this information to the code editor through textDocument/foldingRange.
Since documentation is already kept track of by the LSP (since it can communicate this to the user through hovering over function calls and type constructions), it should be quite simple to implement.