Commit 2fc30d3
authored
fix(folds): update fold boundaries after headline edits (#1078)
* fix(foldtext): invalidate cache on buffer changes
The foldtext highlight cache was keyed by line number but never
invalidated when buffer content changed. After edits that insert
or remove lines, cached entries mapped to wrong content.
Track changedtick per buffer and clear the cache in on_win when
it changes. This is checked once per window per redraw cycle.
* fix(folds): update boundaries after edits
Neovim's treesitter foldexpr only re-evaluates fold levels for
lines reported in on_changedtree, which typically covers just the
edited headline. But fold boundaries extend to the end of the
section, so they go stale after TODO, priority or tag changes.
Capture the section range before the edit (TS nodes become stale
after buffer changes), then schedule vim._foldupdate for the full
section range after treesitter has reparsed.1 parent 9deee54 commit 2fc30d3
3 files changed
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
22 | 35 | | |
23 | 36 | | |
24 | 37 | | |
| |||
101 | 114 | | |
102 | 115 | | |
103 | 116 | | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
20 | 39 | | |
21 | 40 | | |
22 | 41 | | |
| |||
50 | 69 | | |
51 | 70 | | |
52 | 71 | | |
| 72 | + | |
| 73 | + | |
53 | 74 | | |
54 | 75 | | |
55 | 76 | | |
| |||
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
72 | | - | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
74 | 96 | | |
75 | 97 | | |
76 | 98 | | |
77 | 99 | | |
78 | 100 | | |
| 101 | + | |
79 | 102 | | |
| 103 | + | |
80 | 104 | | |
81 | 105 | | |
82 | 106 | | |
| |||
344 | 368 | | |
345 | 369 | | |
346 | 370 | | |
| 371 | + | |
347 | 372 | | |
| 373 | + | |
348 | 374 | | |
349 | 375 | | |
350 | 376 | | |
| |||
419 | 445 | | |
420 | 446 | | |
421 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
422 | 451 | | |
423 | 452 | | |
424 | 453 | | |
| |||
428 | 457 | | |
429 | 458 | | |
430 | 459 | | |
| 460 | + | |
| 461 | + | |
431 | 462 | | |
432 | 463 | | |
433 | 464 | | |
| |||
0 commit comments