Repository: vscode
Issue: TreeView: MaxCallStackError - Nesting
Labels: bug,tree-widget

repo: https://github.com/RedCMD/TreeViewMaxCallStackError

<details><summary>expand siblings</summary>

```rust
  ERR Maximum call stack size exceeded: RangeError: Maximum call stack size exceeded
    at Roi.U (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:13925)
    at Roi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:12904)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45606
    at Array.forEach (<anonymous>)
    at sIi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45593)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7637
    at D9.bufferEvents (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:3825)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7613)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:72611)
    at OY.value (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:3929)
```

</details>

<details><summary>collapse siblings</summary>

```rust
  ERR Cannot read properties of undefined (reading 'dragStartDisposable'): TypeError: Cannot read properties of undefined (reading 'dragStartDisposable')
    at Roi.U (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:13114)
    at Roi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:12904)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45606
    at Array.forEach (<anonymous>)
    at sIi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45593)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7637
    at D9.bufferEvents (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:3825)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7613)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:72611)
    at OY.value (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:3929)
```

</details>

<details><summary>expand nesting</summary>

```rust
  ERR Maximum call stack size exceeded: RangeError: Maximum call stack size exceeded
    at Object.g [as map] (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:8:16252)
    at RJi.M (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:37404)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:37427
    at Object.g [as map] (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:8:16289)
    at g.next (<anonymous>)
    at Object.g [as map] (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:8:16276)
    at g.next (<anonymous>)
    at MAi.x (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:38775)
    at MAi.x (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:38796)
    at MAi.x (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:38796)
```

</details>

<details><summary>collapse nesting</summary>

```rust
  ERR ListError [TreeView] Invalid index 130001: Error: ListError [TreeView] Invalid index 130001
    at JAi.setFocus (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:9367)
    at JAi.setFocus (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:72954)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:1473
    at D9.bufferEvents (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:3825)
    at Jb.setFocus (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:1339)
    at KAi.v (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:71726)
    at OY.value (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:25:6646)
    at x.B (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:747)
    at x.fire (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:965)
    at OY.value (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:25:6291)
```

</details>

also notice:
after all nested nodes have rendered
scrolling down causes VSCode to freeze

![Image](https://github.com/user-attachments/assets/3cc3aabf-d5f5-4c4a-9268-28793ab6e65d)


2nd repo: install JSON TextMate [extension](https://marketplace.visualstudio.com/items?itemName=RedCMD.tmlanguage-syntax-highlighter)
Create CPP file with text:
```cpp
typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<typename::std::add_pointer<int>::type>::type>::type>::type>::type>::type>::type>::type>::type ptr{nullptr};
```
right click => `Show TextMate Calling Stack`
wait for the file to be parsed
wait even longer for VSCode to attempt to render the tree (notice memory usage going up)


<details><summary>Max Call Stack error</summary>

```rust
  ERR Maximum call stack size exceeded: RangeError: Maximum call stack size exceeded
    at Roi.U (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:13925)
    at Roi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:265:12904)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45606
    at Array.forEach (<anonymous>)
    at sIi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:263:45593)
    at http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7637
    at D9.bufferEvents (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:3825)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:308:7613)
    at JAi.splice (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:416:72611)
    at OY.value (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:417:3929)
```

</details>


- VS Code Version: 1.95.1 (latest [insiders](https://insiders.vscode.dev/))
- OS Version: Windows 11

related: https://github.com/microsoft/vscode/issues/230361

assign @alexr00 ?