Skip to content

Commit cc2b1c1

Browse files
committed
fix #334 connect FileSearchProvider call to server
1 parent 0415088 commit cc2b1c1

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/api/atelier.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ export interface SearchResult {
5656
matches: SearchMatch[];
5757
}
5858

59+
export interface DocSearchResult {
60+
name: string;
61+
cat: "RTN" | "CLS" | "CSP" | "OTH";
62+
ts: string;
63+
db: string;
64+
gen: boolean;
65+
}
66+
5967
export interface AtelierJob {
6068
pid: number;
6169
namespace: string;

src/providers/FileSystemPovider/FileSearchProvider.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as vscode from "vscode";
2+
import { DocSearchResult } from "../../api/atelier";
3+
import { AtelierAPI } from "../../api";
24

35
export class FileSearchProvider implements vscode.FileSearchProvider {
46
/**
@@ -12,6 +14,32 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
1214
options: vscode.FileSearchOptions,
1315
token: vscode.CancellationToken
1416
): vscode.ProviderResult<vscode.Uri[]> {
15-
return [];
17+
const category = `&${options.folder.query}&`.includes("&csp&") ? "CSP" : "*";
18+
const generated = `&${options.folder.query}&`.includes("&generated=1&");
19+
const api = new AtelierAPI(options.folder);
20+
let counter = 0;
21+
if (!api.enabled) {
22+
return null;
23+
}
24+
return api
25+
.getDocNames({
26+
filter: query.pattern,
27+
category,
28+
generated
29+
})
30+
.then((data) => data.result.content)
31+
.then((files: DocSearchResult[]) =>
32+
files.map((file) => {
33+
if (category === "*" && file.cat === "CSP") {
34+
return null;
35+
}
36+
if (!options.maxResults || ++counter <= options.maxResults) {
37+
return options.folder.with({ path: `/${file.name}` });
38+
} else {
39+
return null;
40+
}
41+
})
42+
.filter((el) => el !== null)
43+
);
1644
}
1745
}

0 commit comments

Comments
 (0)