Commit 44bf335
basicwidget: clear dropped elements in reused buffers
A buffer reused across calls keeps its dropped elements in the backing
array when truncated with s[:0], pinning every reference those elements
hold. Replace such truncations with slices.Delete, which zeroes the
removed range while keeping the capacity.
The affected buffers:
- PieceTable.history, in both the redo truncation and resetHistory.
Each dropped historyItem owns a cloned items slice, so a discarded
redo state, or a previous document's entire undo history, stayed
alive.
- Combobox.filteredItems, refilled on every keystroke while
filtering, stranding the strings and content widgets of the items
that a narrowed query no longer matches.
- tmpLocales and prevLocales in resolveFace, as language.Tag embeds
an interface. tmpLocales kept its whole contents live after the
function returned.
- tableRowWidget.textColumnLayouts, the only one of the three
buffers reset together there that was not already cleared.
appendVisualLinesFromCachedStarts had the same problem on its failure
path: it returned dst[:base] after having appended, leaving those
elements uncleared past the caller's length, out of reach of the
caller's deferred clear. Drop the redundant re-truncation in Draw as
well, which only ran when theVisualLinesBuffer was already empty.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent c3b2cc2 commit 44bf335
5 files changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
| 576 | + | |
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| |||
0 commit comments