Fix for Sqlproj tree bug (#10605)

Fixes bug where files located in a subfolder defined before the folders themselves in .sqlproj would result in those files not appearing in the ADS treeview
This commit is contained in:
Benjin Dubishar
2020-06-01 22:41:00 -07:00
committed by GitHub
parent 8fc8a79e26
commit 0ac6a07c5f
4 changed files with 106 additions and 12 deletions

View File

@@ -32,14 +32,7 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
const output: BaseProjectTreeItem[] = [];
output.push(this.dataSourceNode);
// sort children so that folders come first, then alphabetical
const sortedChildren = Object.values(this.fileChildren).sort((a: (fileTree.FolderNode | fileTree.FileNode), b: (fileTree.FolderNode | fileTree.FileNode)) => {
if (a instanceof fileTree.FolderNode && !(b instanceof fileTree.FolderNode)) { return -1; }
else if (!(a instanceof fileTree.FolderNode) && b instanceof fileTree.FolderNode) { return 1; }
else { return a.uri.fsPath.localeCompare(b.uri.fsPath); }
});
return output.concat(sortedChildren);
return output.concat(Object.values(this.fileChildren).sort(fileTree.sortFileFolderNodes));
}
public get treeItem(): vscode.TreeItem {
@@ -53,6 +46,10 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
for (const entry of this.project.files) {
const parentNode = this.getEntryParentNode(entry);
if (Object.keys(parentNode.fileChildren).includes(path.basename(entry.fsUri.path))) {
continue; // ignore duplicate entries
}
let newNode: fileTree.FolderNode | fileTree.FileNode;
switch (entry.type) {