Change:
Hei! Found issue with folder delete operation. The point is, when you delete folder (first time), no matter how, via mouse or keyboard combination, then select another folder and try to delete it, you will get popup message saying "Cannot read property 'isDirectory' of undefined" Only when you select another folder again (second time), delete operation will be successful. Tried several times with same results. And as i remember, this bug i found some time ago, so it is not introduced exactly in last insiders build. Visual Code Insiders 1.41.0 from 2019-12-02, commit: macOS 10.15.1
thanks for filling this great issue. You should have the fix tommorrow in vscode insiders
the problem was that it was happening that the tree would sometimes set the trait on one element two times. In this particular case Selection would be set on the element A and A. So if I say tree.getSelection I would get the same item twice. Instead of the array with one item. I decided to fix this with a workaround on the trait level. Repro steps: set compact tree to true. Go up and down with the focus always ending up with the focus on the one select item. Put a conditional breakpoint tree will try to set the double selection trait
This seems to be coming from Where the selection would already contain the folder, but as oldSelection/oldFocus also has the id, it will push the same object to the selection again. You could also fix it there by doing some sort of duplicate filtering or selection.indexOf to prevent duplciates being I could reproduce it consistently by: Putting a breakpoint there Creating a new folder Focusing on that folder Result: The function ends up setting selection to contain the same object twice.
great pointer. I think you are right, give me a sec and I will push a better fix. Thanks a lot!
I was planning to submit something along the lines of But I'm not sure if this is considered good code, it might be better to create a set of Ids (like oldSelection) does, but as selection is of type T, I could not access the id parameter.
If you would like to create a PR you are more than welcome to! It would be great if you could do it today since we are wrapping up the milestone and we need this fix asap. Just make sure to remove my wokraound introduced with Thanks! And make sure to ping me on the PR

Discussion:
} private _set(nodes: ITreeNode<T, any>[], silent: boolean, browserEvent?: UIEvent): void { <del> this.nodes = nodes.length > 1 && this.identityProvider ? distinct(nodes, node => this.identityProvider!.getId(node.element).toString()) : [...nodes]; </del> <ins> this.nodes = [...nodes]; </ins> this.elements = undefined; this._nodeSet = undefined;

if (compressedNode) { for (let i = 0; i < compressedNode.elements.length; i++) { const id = getId(compressedNode.elements[i].element as T); <ins> const element = compressedNode.elements[compressedNode.elements.length - 1].element as T; </ins> <del> if (oldSelection.has(id)) { selection.push(compressedNode.elements[compressedNode.elements.length - 1].element as T); </del> <ins> // github.com/microsoft/vscode/issues/85938 if (oldSelection.has(id) && selection.indexOf(element) === -1) { selection.push(element); </ins> didChangeSelection = true; } <del> if (oldFocus.has(id)) { focus.push(compressedNode.elements[compressedNode.elements.length - 1].element as T); </del> <ins> if (oldFocus.has(id) && focus.indexOf(element) === -1) { focus.push(element); </ins> didChangeFocus = true; } }