Skip to content

Commit 889ad28

Browse files
Merge pull request #335 from gjsjohnmurray/fix-334
fix #334 connect FileSearchProvider call to server
2 parents 06258df + 4e8d7ee commit 889ad28

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-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: 30 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,33 @@ 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
33+
.map((file) => {
34+
if (category === "*" && file.cat === "CSP") {
35+
return null;
36+
}
37+
if (!options.maxResults || ++counter <= options.maxResults) {
38+
return options.folder.with({ path: `/${file.name}` });
39+
} else {
40+
return null;
41+
}
42+
})
43+
.filter((el) => el !== null)
44+
);
1645
}
1746
}

0 commit comments

Comments
 (0)