Skip to content

Commit bb3c657

Browse files
author
Jackson Kearl
committed
1 parent 6d3294d commit bb3c657

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/vs/workbench/contrib/files/browser/explorerService.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,17 @@ export class ExplorerService implements IExplorerService {
372372
// Delete
373373
else if (e.isOperation(FileOperation.DELETE)) {
374374
const modelElements = this.model.findAll(e.resource);
375-
await Promise.all(modelElements.map(async element => {
376-
if (element.parent) {
377-
const parent = element.parent;
375+
await Promise.all(modelElements.map(async modelElement => {
376+
if (modelElement.parent) {
378377
// Remove Element from Parent (Model)
379-
parent.removeChild(element);
378+
const parent = modelElement.parent;
379+
parent.removeChild(modelElement);
380+
381+
const oldNestedParent = modelElement.nestedParent;
382+
if (oldNestedParent) {
383+
oldNestedParent.removeChild(modelElement);
384+
await this.view?.refresh(false, oldNestedParent);
385+
}
380386
// Refresh Parent (View)
381387
await this.view?.refresh(false, parent);
382388
}

src/vs/workbench/contrib/files/common/explorerModel.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ export class ExplorerItem {
301301
const nestingConfig = this.configService.getValue<IFilesConfiguration>({ resource: this.root.resource }).explorer.experimental.fileNesting;
302302

303303
// fast path when the children can be resolved sync
304-
if (nestingConfig.enabled && this.nestedChildren) { return this.nestedChildren; }
304+
if (nestingConfig.enabled && this.nestedChildren) {
305+
return this.nestedChildren;
306+
}
305307

306308
return (async () => {
307309
if (!this._isDirectoryResolved) {
@@ -383,11 +385,13 @@ export class ExplorerItem {
383385
* Removes a child element from this folder.
384386
*/
385387
removeChild(child: ExplorerItem): void {
388+
this.nestedChildren = undefined;
386389
this.children.delete(this.getPlatformAwareName(child.name));
387390
}
388391

389392
forgetChildren(): void {
390393
this.children.clear();
394+
this.nestedChildren = undefined;
391395
this._isDirectoryResolved = false;
392396
this._fileNester = undefined;
393397
}
@@ -400,6 +404,9 @@ export class ExplorerItem {
400404
* Moves this element under a new parent element.
401405
*/
402406
move(newParent: ExplorerItem): void {
407+
if (this.nestedParent) {
408+
this.nestedParent.removeChild(this);
409+
}
403410
if (this._parent) {
404411
this._parent.removeChild(this);
405412
}

0 commit comments

Comments
 (0)