From d4c5ca1c188ee363dd212f9ef4ca1fa3cda9eea5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Sep 2025 13:56:45 +0000 Subject: [PATCH] Fix folder path normalization in Structure view for proper nesting Co-authored-by: estruyf <2900833+estruyf@users.noreply.github.com> --- .../components/Contents/StructureView.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dashboardWebView/components/Contents/StructureView.tsx b/src/dashboardWebView/components/Contents/StructureView.tsx index a429c292..819f22a8 100644 --- a/src/dashboardWebView/components/Contents/StructureView.tsx +++ b/src/dashboardWebView/components/Contents/StructureView.tsx @@ -38,7 +38,9 @@ export const StructureView: React.FunctionComponent = ({ } const folderPath = page.fmFolder; - const parts = folderPath.split('/').filter(part => part.length > 0); + // Normalize path separators and remove leading/trailing slashes + const normalizedPath = folderPath.replace(/\\/g, '/').replace(/^\/+|\/+$/g, ''); + const parts = normalizedPath.split('/').filter(part => part.length > 0); let currentPath = ''; let currentNode = root; @@ -70,9 +72,14 @@ export const StructureView: React.FunctionComponent = ({ if (!page.fmFolder) { root.pages.push(page); } else { - const folderNode = folderMap.get(page.fmFolder); + // Normalize the folder path for lookup + const normalizedPath = page.fmFolder.replace(/\\/g, '/').replace(/^\/+|\/+$/g, ''); + const folderNode = folderMap.get(normalizedPath); if (folderNode) { folderNode.pages.push(page); + } else { + // If folder not found, add to root as fallback + root.pages.push(page); } } });