Skip to content

Commit

Permalink
Merge pull request #2563 from microsoft/bugfix/code-filter-fix
Browse files Browse the repository at this point in the history
- fixes a bug where the extension filter would not include matching nodes with children
  • Loading branch information
baywet authored Apr 14, 2023
2 parents 22a80d6 + ab66eb2 commit d664d91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion vscode/microsoft-kiota/src/kiotaInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface KiotaOpenApiNode {
segment: string,
path: string,
children: KiotaOpenApiNode[],
selected: boolean,
selected?: boolean,
}

export interface KiotaShowConfiguration {
Expand Down
18 changes: 9 additions & 9 deletions vscode/microsoft-kiota/src/openApiTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider<OpenApiTreeN
}
private findSelectedPaths(currentNode: KiotaOpenApiNode): string[] {
const result: string[] = [];
if(currentNode.selected) {
if(currentNode.selected || false) {
result.push(currentNode.path.replace(/\\/g, '/'));
}
currentNode.children.forEach(x => result.push(...this.findSelectedPaths(x)));
Expand Down Expand Up @@ -167,14 +167,14 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider<OpenApiTreeN
vscode.TreeItemCollapsibleState.Collapsed :
vscode.TreeItemCollapsibleState.Expanded);
}
getTreeNodeFromKiotaNode(node: KiotaOpenApiNode, parent?: OpenApiTreeNode): OpenApiTreeNode {
getTreeNodeFromKiotaNode(node: KiotaOpenApiNode): OpenApiTreeNode {
const result = new OpenApiTreeNode(
node.path,
node.segment,
node.selected,
node.segment,
node.selected || false,
this.getCollapsedState(node.children.length > 0)
);
result.children = node.children.map(x => this.getTreeNodeFromKiotaNode(x, result));
result.children = node.children.map(x => this.getTreeNodeFromKiotaNode(x));
return result;
}
getChildren(element?: OpenApiTreeNode): OpenApiTreeNode[] {
Expand All @@ -198,7 +198,7 @@ export class OpenApiTreeNode extends vscode.TreeItem {
constructor(
public readonly path: string,
public readonly label: string,
public readonly selected: boolean,
selected: boolean,
public collapsibleState: vscode.TreeItemCollapsibleState,
_children?: OpenApiTreeNode[]
) {
Expand All @@ -214,9 +214,9 @@ export class OpenApiTreeNode extends vscode.TreeItem {
if (tokenizedFilter.length === 0) {
return true;
}
if (this.children.length === 0) {
const lowerCaseSegment = this.label.toLowerCase();
return tokenizedFilter.some(x => lowerCaseSegment.includes(x.toLowerCase()));
const lowerCaseSegment = this.label.toLowerCase();
if (tokenizedFilter.some(x => lowerCaseSegment.includes(x.toLowerCase()))) {
return true;
}
return this.children.some(x => x.isNodeVisible(tokenizedFilter));
}
Expand Down

0 comments on commit d664d91

Please sign in to comment.