From ac8df0a330fd3709e589bf85079acb311c0e408e Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:15:48 +0530 Subject: [PATCH 1/8] fix(files): stale state in fileTree This commit attempts to fix the stale files state issue occuring from Internal State of fileTree. regression: to be found, how it occurred recently. --- src/lib/openFolder.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index b286535ac..fda4fc3c2 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -624,6 +624,7 @@ function execOperation(type, action, url, $target, name) { toast(strings.success); FileList.remove(url); + removeEntryFromFileTree(url); } async function renameFile() { @@ -1055,6 +1056,24 @@ async function refreshOpenFolder(folderUrl) { ); } +async function removeEntryFromFileTree(url){ + const filesApp = sidebarApps.get("files"); + const $els = filesApp.getAll(`[data-url="${folderUrl}"]`); + + await Promise.all( + Array.from($els).map(async ($el) => { + if (!(helpers.isDir($el.dataset.type) || $el.dataset.type === "root")) { + return; + } + + const fileTree = getLoadedFileTree($el); + if (fileTree) { + await fileTree.removeEntity(url); + } + }), + ); +} + /** * Create a folder tile * @param {string} name From e54d46b16076571a5968e2cf060d265b5307e523 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:18:49 +0530 Subject: [PATCH 2/8] Update openFolder.js --- src/lib/openFolder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index fda4fc3c2..8cbb784f7 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -624,7 +624,7 @@ function execOperation(type, action, url, $target, name) { toast(strings.success); FileList.remove(url); - removeEntryFromFileTree(url); + await removeEntryFromFileTree(url); } async function renameFile() { From 2132267bad504982823752b507a445ddc7777688 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:22:09 +0530 Subject: [PATCH 3/8] Update src/lib/openFolder.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/lib/openFolder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 8cbb784f7..508070493 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -624,7 +624,7 @@ function execOperation(type, action, url, $target, name) { toast(strings.success); FileList.remove(url); - await removeEntryFromFileTree(url); + await removeEntryFromFileTree(url); } async function renameFile() { From 5e12d603f4ab76dfef885316dbf87d6442530876 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 09:57:41 +0530 Subject: [PATCH 4/8] Update src/lib/openFolder.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/lib/openFolder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 508070493..58d060ccf 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -1068,7 +1068,7 @@ async function removeEntryFromFileTree(url){ const fileTree = getLoadedFileTree($el); if (fileTree) { - await fileTree.removeEntity(url); + await fileTree.removeEntry(url); } }), ); From 8f4004405dd71414eeb80c2db862010972dc6946 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:16:17 +0530 Subject: [PATCH 5/8] Update src/lib/openFolder.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/lib/openFolder.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 58d060ccf..48b5ec358 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -1058,7 +1058,12 @@ async function refreshOpenFolder(folderUrl) { async function removeEntryFromFileTree(url){ const filesApp = sidebarApps.get("files"); - const $els = filesApp.getAll(`[data-url="${folderUrl}"]`); +async function removeEntryFromFileTree(url, $parent){ + const fileTree = $parent?._fileTree; + if (fileTree) { + await fileTree.removeEntry(url); + } +} await Promise.all( Array.from($els).map(async ($el) => { From 03802ad161671ded91c796521de7616d7b0c15c7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:22:31 +0530 Subject: [PATCH 6/8] Update openFolder.js --- src/lib/openFolder.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index 48b5ec358..d1fb1279b 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,7 +627,7 @@ function execOperation(type, action, url, $target, name) { toast(strings.success); FileList.remove(url); - await removeEntryFromFileTree(url); + await removeEntryFromFileTree(url, $parent); } async function renameFile() { @@ -1056,12 +1059,11 @@ async function refreshOpenFolder(folderUrl) { ); } -async function removeEntryFromFileTree(url){ - const filesApp = sidebarApps.get("files"); async function removeEntryFromFileTree(url, $parent){ const fileTree = $parent?._fileTree; if (fileTree) { await fileTree.removeEntry(url); + return; } } From 7ae9a4c696205a5a0d315c1cd7350a30e8cbcf2e Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:27:57 +0530 Subject: [PATCH 7/8] Update src/lib/openFolder.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/lib/openFolder.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index d1fb1279b..d355a7f90 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -1067,20 +1067,11 @@ async function removeEntryFromFileTree(url, $parent){ } } - await Promise.all( - Array.from($els).map(async ($el) => { - if (!(helpers.isDir($el.dataset.type) || $el.dataset.type === "root")) { - return; - } - - const fileTree = getLoadedFileTree($el); - if (fileTree) { - await fileTree.removeEntry(url); - } - }), - ); } +/** + * Create a folder tile + /** * Create a folder tile * @param {string} name From 71eb0f673f07ce6130ef92b6095b6411874fa2f5 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 14 Apr 2026 10:46:12 +0530 Subject: [PATCH 8/8] Fix formatting and remove redundant comments in openFolder.js --- src/lib/openFolder.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index d355a7f90..be1f165b5 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -579,7 +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; + let $parent; if (!confirmation) return; startLoading(); if (!(await fsOperation(url).exists())) return; @@ -587,7 +587,7 @@ function execOperation(type, action, url, $target, name) { recents.removeFile(url); if (helpers.isFile(type)) { await fsOperation(url).delete(); - $parent = $target.parentElement; + $parent = $target.parentElement; $target.remove(); const file = editorManager.getFile(url, "uri"); if (file) file.uri = null; @@ -619,7 +619,7 @@ function execOperation(type, action, url, $target, name) { } recents.removeFolder(url); helpers.updateUriOfAllActiveFiles(url, null); - $parent = $target.parentElement?.parentElement; + $parent = $target.parentElement?.parentElement; $target.parentElement.remove(); editorManager.onupdate("delete-folder"); editorManager.emit("update", "delete-folder"); @@ -1067,11 +1067,6 @@ async function removeEntryFromFileTree(url, $parent){ } } -} - -/** - * Create a folder tile - /** * Create a folder tile * @param {string} name