Skip to content

Commit

Permalink
feat: improve check hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalYoung committed Nov 30, 2021
1 parent 4fdef39 commit 51202b8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/workbench/explorer/folderTreeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 51202b8

Please sign in to comment.