Commit 1425c18
committed
[ty] Add code folding support
This PR implements the `textDocument/foldingRange` LSP request,
enabling code folding in editors. We also support tagging each
folding range with its "kind." So for example, this enables one
to ask your editor to "collapse all block comments."
The implementation works by doing a simple AST traversal to identify
"blocks" in a Python program. We also do a line oriented search to
extract ranges that are more difficult to do from the AST: blocks of
comments, blocks of imports and special custom "regions."
Closes astral-sh/ty#25881 parent 97acaae commit 1425c18
12 files changed
Lines changed: 1926 additions & 8 deletions
File tree
- crates
- ruff_text_size/src
- ty_ide/src
- ty_server
- src
- server
- api
- requests
- tests/e2e
- snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
348 | 394 | | |
349 | 395 | | |
350 | 396 | | |
| |||
0 commit comments