-
Notifications
You must be signed in to change notification settings - Fork 37k
Description
Does this issue occur when all (other) extensions are disabled?: Yes
- VS Code Version: 1.107.1
- OS Version: macOS 15.7.2
The main issue I'm seeing is that TreeItems created with the same TreeItemCollapsibleState will occasionally get no-twisty added, which doesn't seem to match the following:
vscode/src/vs/workbench/browser/parts/views/treeView.ts
Lines 1497 to 1503 in ae22fa2
| if (node.parent instanceof Root) { | |
| if (node.collapsibleState === TreeItemCollapsibleState.None) { | |
| templateData.container.classList.add('no-twisty'); | |
| } else { | |
| templateData.container.classList.remove('no-twisty'); | |
| } | |
| } |
For example, in this minimal extension (code further down), tree items with the same collapsible state aren't always showing the same alignment (the ones with no-twisty appear slightly to the right).
TreeItemCollapsibleState.Collapsed
- with
no-twisty:
- normal:
TreeItemCollapsibleState.None
- with
no-twisty:
- normal:
Steps to Reproduce:
Here's a fairly minimal extension that generates a bunch of tree items with random Collapsed/None states (with a refresh button to generate another random batch):
extension.ts
import * as vscode from "vscode";
interface Item {
name: string;
}
class Provider implements vscode.TreeDataProvider<Item> {
getChildren(element?: Item): Item[] {
const children = [];
if (!element) {
// root items
for (let i = 0; i < 50; i++) {
children.push({ name: `Item ${i + 1}` });
}
} else {
// child items of `element`
for (let i = 0; i < 10; i++) {
children.push({ name: `Sub${element.name}.${i + 1}` });
}
}
return children;
}
getTreeItem(element: Item): vscode.TreeItem {
// random chance some can be expanded, some can't
const collapsibleState =
Math.random() < 0.5
? vscode.TreeItemCollapsibleState.Collapsed
: vscode.TreeItemCollapsibleState.None;
const icon = new vscode.TreeItem(element.name, collapsibleState);
icon.id = element.name;
icon.iconPath = new vscode.ThemeIcon("file");
return icon;
}
private _onDidChangeTreeData: vscode.EventEmitter<Item | undefined | void> =
new vscode.EventEmitter<Item | undefined | void>();
readonly onDidChangeTreeData: vscode.Event<Item | undefined | void> =
this._onDidChangeTreeData.event;
refresh(): void {
this._onDidChangeTreeData.fire();
}
}
export function activate(context: vscode.ExtensionContext) {
const provider = new Provider();
context.subscriptions.push(
vscode.window.registerTreeDataProvider("vscode-tree-items-view", provider),
);
const refreshCommand = vscode.commands.registerCommand("vscode-tree-items-view.refresh", () =>
provider.refresh(),
);
context.subscriptions.push(refreshCommand);
}
export function deactivate() {}package.json
{
"name": "vscode-tree-items",
"displayName": "vscode-tree-items",
"description": "",
"version": "0.1.0",
"engines": {
"vscode": "^1.101.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "vscode-tree-items-view.refresh",
"title": "Generate New Tree Items",
"icon": "$(refresh)"
}
],
"viewsContainers": {
"activitybar": [
{
"id": "vscode-tree-items",
"icon": "$(list-tree)",
"title": "Tree Items"
}
]
},
"views": {
"vscode-tree-items": [
{
"id": "vscode-tree-items-view",
"icon": "$(list-tree)",
"name": "Tree Items"
}
]
},
"menus": {
"view/title": [
{
"command": "vscode-tree-items-view.refresh",
"when": "true",
"group": "navigation"
}
]
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src",
"test": "vscode-test"
},
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "22.x",
"@types/sinon": "^17.0.4",
"@types/vscode": "^1.101.0",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.7.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.4.1",
"assert": "^2.1.0",
"eslint": "^9.13.0",
"sinon": "^21.0.0",
"typescript": "^5.6.3"
}
}I also see this on Insiders (note the SubItem 22 children):

Version: 1.108.0-insider (Universal)
Commit: 7f08f95ad54782bd242f5536470b330282197333
Date: 2025-12-19T14:09:25.917Z (1 day ago)
This doesn't seem like the same behavior as #279421, but possibly related? (@alexr00? 👀)