diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index b286535ac..be1f165b5 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -579,6 +579,7 @@ function execOperation(type, action, url, $target, name) { async function deleteFile() { const msg = strings["delete entry"].replace("{name}", name); const confirmation = await confirm(strings.warning, msg); + let $parent; if (!confirmation) return; startLoading(); if (!(await fsOperation(url).exists())) return; @@ -586,6 +587,7 @@ function execOperation(type, action, url, $target, name) { recents.removeFile(url); if (helpers.isFile(type)) { await fsOperation(url).delete(); + $parent = $target.parentElement; $target.remove(); const file = editorManager.getFile(url, "uri"); if (file) file.uri = null; @@ -617,6 +619,7 @@ function execOperation(type, action, url, $target, name) { } recents.removeFolder(url); helpers.updateUriOfAllActiveFiles(url, null); + $parent = $target.parentElement?.parentElement; $target.parentElement.remove(); editorManager.onupdate("delete-folder"); editorManager.emit("update", "delete-folder"); @@ -624,6 +627,7 @@ function execOperation(type, action, url, $target, name) { toast(strings.success); FileList.remove(url); + await removeEntryFromFileTree(url, $parent); } async function renameFile() { @@ -1055,6 +1059,14 @@ async function refreshOpenFolder(folderUrl) { ); } +async function removeEntryFromFileTree(url, $parent){ + const fileTree = $parent?._fileTree; + if (fileTree) { + await fileTree.removeEntry(url); + return; + } +} + /** * Create a folder tile * @param {string} name