From eeb2aeee00df76f078c9eb6a7a04a6cf1d411f9e Mon Sep 17 00:00:00 2001 From: WayJam So Date: Tue, 15 Dec 2020 00:53:55 +0800 Subject: [PATCH 1/2] fix: invalid expand path --- src/utils/VisibleNodesGenerator.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/VisibleNodesGenerator.ts b/src/utils/VisibleNodesGenerator.ts index c869319..25638f2 100644 --- a/src/utils/VisibleNodesGenerator.ts +++ b/src/utils/VisibleNodesGenerator.ts @@ -290,7 +290,11 @@ class FlattenLayer extends CompressLayer { [rootNode], async node => { const overflowChar = node.path[path.length + 1] - const match = path.startsWith(node.path) && (overflowChar === '/' || !overflowChar) + const nextChar = path.slice(node.path.length, node.path.length + 1) + const match = + path.startsWith(node.path) && + (overflowChar === '/' || !overflowChar) && + (!node.path || nextChar === '/' || !nextChar) if (node.path) { // rootNode.path === '' if (match) { From 1d73b52d3182f1f83dd49640275fa51fc6ccf7c6 Mon Sep 17 00:00:00 2001 From: Enix Date: Wed, 16 Dec 2020 22:24:27 +0800 Subject: [PATCH 2/2] refactor: simplify logic --- src/utils/VisibleNodesGenerator.ts | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/utils/VisibleNodesGenerator.ts b/src/utils/VisibleNodesGenerator.ts index 25638f2..52f8015 100644 --- a/src/utils/VisibleNodesGenerator.ts +++ b/src/utils/VisibleNodesGenerator.ts @@ -287,22 +287,15 @@ class FlattenLayer extends CompressLayer { const rootNode = this.compressedRoot if (rootNode) { await traverse( - [rootNode], + rootNode.contents, async node => { - const overflowChar = node.path[path.length + 1] - const nextChar = path.slice(node.path.length, node.path.length + 1) - const match = - path.startsWith(node.path) && - (overflowChar === '/' || !overflowChar) && - (!node.path || nextChar === '/' || !nextChar) - if (node.path) { - // rootNode.path === '' - if (match) { - if (node.path === path) { - // do not wait for expansion for the exact node as that will block "jumping from search" - this.$setExpand(node, true) - } else await this.$setExpand(node, true) - } + const overflowChar = path[node.path.length] + const match = path.startsWith(node.path) && (overflowChar === '/' || !overflowChar) + if (match) { + if (node.path === path) { + // do not wait for expansion for the exact node as that will block "jumping from search" + this.$setExpand(node, true) + } else await this.$setExpand(node, true) } return match },