提交 98e5b5c0 编写于 作者: J Joao Moreno

fixes #67720

上级 3c2c17dd
......@@ -870,12 +870,36 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
this.model = this.createModel(this.view, _options);
onDidChangeCollapseStateRelay.input = this.model.onDidChangeCollapseState;
this.model.onDidSplice(e => {
this.eventBufferer.bufferEvents(() => {
this.focus.remove(e.deletedNodes);
this.selection.remove(e.deletedNodes);
});
}, null, this.disposables);
if (this.options.identityProvider) {
const identityProvider = this.options.identityProvider;
this.model.onDidSplice(e => {
if (e.deletedNodes.length === 0) {
return;
}
this.eventBufferer.bufferEvents(() => {
const map = new Map<string, ITreeNode<T, TFilterData>>();
for (const node of e.deletedNodes) {
map.set(identityProvider.getId(node.element).toString(), node);
}
for (const node of e.insertedNodes) {
map.delete(identityProvider.getId(node.element).toString());
}
if (map.size === 0) {
return;
}
const deletedNodes = values(map);
this.focus.remove(deletedNodes);
this.selection.remove(deletedNodes);
});
}, null, this.disposables);
}
this.view.onTap(this.reactOnMouseClick, this, this.disposables);
this.view.onMouseClick(this.reactOnMouseClick, this, this.disposables);
......
......@@ -173,7 +173,7 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
}
const result = Iterator.map(Iterator.fromArray(deletedNodes), treeNodeToElement);
this._onDidSplice.fire({ deletedNodes });
this._onDidSplice.fire({ insertedNodes: nodesToInsert, deletedNodes });
return result;
}
......
......@@ -98,6 +98,7 @@ export interface ICollapseStateChangeEvent<T, TFilterData> {
}
export interface ITreeModelSpliceEvent<T, TFilterData> {
insertedNodes: ITreeNode<T, TFilterData>[];
deletedNodes: ITreeNode<T, TFilterData>[];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册