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

Enhance setSelection of TreeContributor #147

Merged
merged 1 commit into from
Feb 1, 2019
Merged
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
23 changes: 8 additions & 15 deletions src/contributors/TreeContributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ export class TreeContributor extends Contributor {
const currentSelectedNodesPathsMap = new Map();
selectedNodesPathsList.forEach(path => {
let id = '';
path.forEach(node => {
id += node.fieldName + node.fieldValue ;
});
currentSelectedNodesPathsMap.set(id, path);
for (let i = 1; i <= path.length; i++) {
id += path[path.length - i].fieldName + path[path.length - i].fieldValue;
currentSelectedNodesPathsMap.set(id, path.slice(path.length - i, path.length));
}
});
// Array of array to Map
const olderSelectedNodesPathsMap = new Map();
this.selectedNodesPathsList.forEach(path => {
let id = '';
path.forEach(node => {
id += node.fieldName + node.fieldValue;
});
olderSelectedNodesPathsMap.set(id, path);
for (let i = 1; i <= path.length; i++) {
id += path[path.length - i].fieldName + path[path.length - i].fieldValue;
olderSelectedNodesPathsMap.set(id, path.slice(path.length - i, path.length));
}
});
const mergedMap = new Map([...Array.from(currentSelectedNodesPathsMap.entries()),
...Array.from(olderSelectedNodesPathsMap.entries())]);
Expand All @@ -161,13 +161,6 @@ export class TreeContributor extends Contributor {
break;
}
}
// check if there is a path that is already included in a longer path
for (const k of Array.from(mergedMap.keys())) {
if (k.includes(key) && key !== k) {
addpath = false;
break;
}
}
if (addpath) {
selectedPaths.push(value);
}
Expand Down