Skip to content

Commit

Permalink
fix(treeview): filters shall use unique id
Browse files Browse the repository at this point in the history
Filters in the tree cannot use the uuid as the same filter is represented
multiple times in the tree view.
Using a uniqueId now for the tree view node.
  • Loading branch information
mbehr1 committed Dec 30, 2020
1 parent 365ecfb commit 41632f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/dltAddEditFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const confSection = 'dlt-logs.filters';

export function deleteFilter(doc: DltDocument, filter: DltFilter) {
console.log(`dlt-log.deleteFilter(${filter.name}) called...`);
return new Promise((resolveDelete) => {
return new Promise<boolean>((resolveDelete) => {
// delete config:
const curFilter = vscode.workspace.getConfiguration().get(confSection);
if (curFilter && Array.isArray(curFilter)) {
Expand All @@ -41,7 +41,7 @@ export function deleteFilter(doc: DltDocument, filter: DltFilter) {
} else {
vscode.window.showErrorMessage(`can't read current config '${confSection}'`);
}
doc.onFilterDelete(filter)?.then(() => resolveDelete());
doc.onFilterDelete(filter)?.then(() => resolveDelete(true));
});
}

Expand All @@ -52,7 +52,7 @@ export function addFilter(doc: DltDocument, arg: any) {
}

export function editFilter(doc: DltDocument, newFilter: DltFilter, optArgs?: { payload?: string, isAdd?: boolean }) {
return new Promise((resolveEdit) => {
return new Promise<boolean>((resolveEdit) => {
const isAdd = optArgs !== undefined && optArgs.isAdd !== undefined ? optArgs.isAdd : false;
console.log(`dlt-log.editFilter(isEdit=${isAdd}) called...${newFilter.name}`);

Expand Down Expand Up @@ -89,7 +89,7 @@ export function editFilter(doc: DltDocument, newFilter: DltFilter, optArgs?: { p
}
doc.onFilterEdit(filter);
}
resolveEdit();
resolveEdit(true);
} else {
vscode.window.showErrorMessage(`can't read current config '${confSection}'`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/dltDocumentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface TreeViewNode {
};

export class FilterNode implements TreeViewNode {
id: string;
tooltip: string | undefined;
//uri: vscode.Uri | null; // index provided as fragment #<index>
//parent: TreeViewNode | null;
Expand All @@ -80,9 +81,10 @@ export class FilterNode implements TreeViewNode {

constructor(public uri: vscode.Uri | null, public parent: TreeViewNode | null, public filter: DltFilter) {
this.children = [];
this.id = createUniqueId();
}

get id(): string { return this.filter.id; }
/* we cannot use the filter id as we have multiple nodes for the same filter in the tree get id(): string { return this.filter.id; } */

get iconPath(): vscode.ThemeIcon | undefined {
return this.filter.iconPath;
Expand Down

0 comments on commit 41632f2

Please sign in to comment.