Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tree provider uniqueness #930

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions src/lib/deleteFolderAppMaps.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import AppMapCollection from '../services/appmapCollection';
import { IAppMapTreeItem } from '../tree/appMapTreeDataProvider';
import deleteAppMap from './deleteAppMap';
import { AppMapTreeDataProvider } from '../tree/appMapTreeDataProvider';
import * as vscode from 'vscode';

export default async function deleteFolderAppMaps(
appmaps: AppMapCollection,
folderName: string
selectedTreeItem: IAppMapTreeItem
): Promise<number> {
const filteredAppMaps = appmaps.appMaps().filter((appmap) => {
const folderProperties = AppMapTreeDataProvider.appMapFolderItems(appmap);
const workspaceFolder = vscode.workspace.getWorkspaceFolder(appmap.descriptor.resourceUri);
return (
AppMapTreeDataProvider.folderName(folderProperties) === folderName ||
workspaceFolder?.name === folderName
);
});
await Promise.all(
filteredAppMaps.map((appmap) => deleteAppMap(appmap.descriptor.resourceUri, appmaps))
);
return filteredAppMaps.length;
let numDeleted = 0;
const deleteTreeItem = async (treeItem: IAppMapTreeItem) => {
if (treeItem.appmap) {
await deleteAppMap(treeItem.appmap.descriptor.resourceUri, appmaps);
numDeleted++;
}
for (const child of treeItem.children) deleteTreeItem(child);
};
await deleteTreeItem(selectedTreeItem);

return numDeleted;
}
Loading
Loading