Commit 7e9471b
committed
fix(files): handle stale treesitter nodes gracefully
When a buffer changes after parsing, node positions become invalid.
Calling get_node_text on stale nodes throws "Index out of bounds"
errors, crashing async callers like org-roam.
Changes:
- Wrap get_node_text in pcall, return '' on failure
- Add is_tree_stale() for callers needing explicit detection
- Track buffer changedtick at parse time for comparison1 parent e448c72 commit 7e9471b
1 file changed
+25
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
196 | 204 | | |
197 | 205 | | |
198 | 206 | | |
| |||
487 | 495 | | |
488 | 496 | | |
489 | 497 | | |
| 498 | + | |
| 499 | + | |
490 | 500 | | |
491 | 501 | | |
492 | 502 | | |
493 | 503 | | |
494 | 504 | | |
495 | 505 | | |
496 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
497 | 511 | | |
498 | | - | |
| 512 | + | |
499 | 513 | | |
500 | 514 | | |
501 | 515 | | |
502 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
503 | 525 | | |
504 | | - | |
| 526 | + | |
| 527 | + | |
505 | 528 | | |
506 | 529 | | |
507 | 530 | | |
| |||
0 commit comments