Skip to content

Commit

Permalink
Sort files/folders with folders first (#2491)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Nov 13, 2020
1 parent e2fdd3c commit a77b643
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/tree/containers/files/DirectoryTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ export class DirectoryTreeItem extends AzExtParentTreeItemIntermediate {
return items.map(item => this.createTreeItemForDirectoryItem(item, actualUri));
}

public compareChildrenImpl(item1: DirectoryTreeItem | FileTreeItem, item2: DirectoryTreeItem | FileTreeItem): number {
if ((item1 instanceof DirectoryTreeItem && item2 instanceof DirectoryTreeItem) ||
(item1 instanceof FileTreeItem && item2 instanceof FileTreeItem)) {
// If both are directories, or both are files, go alphabetical
return item1.label.localeCompare(item2.label);
} else if (item1 instanceof DirectoryTreeItem) {
// item1 is a directory and item2 is a file, so item1 should show first
return -1;
} else {
// item2 is a directory and item1 is a file, so item2 should show first
return 1;
}
}

private createTreeItemForDirectoryItem(item: [string, vscode.FileType], parentUri: DockerUri): AzExtTreeItem {
const name = item[0];
const fileType = item[1];
Expand Down

0 comments on commit a77b643

Please sign in to comment.