From 51202b8e1d8540563e20d5c4f9e5f55054120ab0 Mon Sep 17 00:00:00 2001 From: mortalYoung Date: Tue, 30 Nov 2021 12:02:01 +0800 Subject: [PATCH] feat: improve check hidden files --- src/services/workbench/explorer/folderTreeService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/workbench/explorer/folderTreeService.ts b/src/services/workbench/explorer/folderTreeService.ts index 34b7ff8b3..df9dedda8 100644 --- a/src/services/workbench/explorer/folderTreeService.ts +++ b/src/services/workbench/explorer/folderTreeService.ts @@ -157,6 +157,10 @@ export class FolderTreeService this.builtinService = container.resolve(BuiltinService); } + private isHiddenFile(file: IFolderTreeNodeProps) { + return !!file.name?.startsWith('.'); + } + private sortTree(tree: IFolderTreeNodeProps[]) { tree.sort((pre, cur) => { // folder before file @@ -166,8 +170,8 @@ export class FolderTreeService // in general, both have name if (pre.name && cur.name) { - const isHiddenFilePre = pre.name.startsWith('.') ? 1 : 0; - const isHiddenFileCur = cur.name.startsWith('.') ? 1 : 0; + const isHiddenFilePre = Number(this.isHiddenFile(pre)); + const isHiddenFileCur = Number(this.isHiddenFile(cur)); // one is hidden file and another is not if (isHiddenFilePre ^ isHiddenFileCur) { return isHiddenFilePre ? -1 : 1;