Skip to content

Commit 018baa3

Browse files
Merge pull request #590 from gjsjohnmurray/fix-581
fix #581 constrain QuickOpen results to isfs path if set
2 parents b933fb1 + 484a7a0 commit 018baa3

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/providers/FileSystemPovider/FileSearchProvider.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from "vscode";
2+
import * as url from "url";
23
import { DocSearchResult } from "../../api/atelier";
34
import { AtelierAPI } from "../../api";
45

@@ -14,32 +15,50 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
1415
options: vscode.FileSearchOptions,
1516
token: vscode.CancellationToken
1617
): vscode.ProviderResult<vscode.Uri[]> {
17-
const category = `&${options.folder.query}&`.includes("&csp&") ? "CSP" : "*";
18-
const generated = `&${options.folder.query}&`.includes("&generated=1&");
18+
const folderQuery = url.parse(options.folder.toString(true), true).query;
19+
const type = folderQuery.type || "all";
20+
const category =
21+
folderQuery.csp === "" || folderQuery.csp === "1" ? "CSP" : type === "cls" ? "CLS" : type === "rtn" ? "RTN" : "*";
22+
const generated = folderQuery.generated === "1";
1923
const api = new AtelierAPI(options.folder);
24+
let filter = query.pattern;
25+
if (category !== "CSP") {
26+
if (options.folder.path !== "/") {
27+
filter = options.folder.path.slice(1) + "/%" + filter;
28+
}
29+
filter = filter.replace(/\//g, ".");
30+
}
2031
let counter = 0;
2132
if (!api.enabled) {
2233
return null;
2334
}
2435
return api
2536
.getDocNames({
26-
filter: query.pattern,
37+
filter,
2738
category,
2839
generated,
2940
})
3041
.then((data) => data.result.content)
3142
.then((files: DocSearchResult[]) =>
3243
files
3344
.map((file) => {
34-
if (category === "*" && file.cat === "CSP") {
45+
if (category !== "CSP" && file.cat === "CSP") {
3546
return null;
3647
}
3748
if (file.cat !== "CSP") {
3849
if (file.name.startsWith("%") && api.ns !== "%SYS") {
3950
return null;
4051
}
52+
// Convert dotted name to slashed one, treating the likes of ABC.1.int or DEF.T1.int in the same way
53+
// as the Studio dialog does.
4154
const nameParts = file.name.split(".");
42-
file.name = nameParts.slice(0, -2).join("/") + "/" + nameParts.slice(-2).join(".");
55+
const dotParts = nameParts
56+
.slice(-2)
57+
.join(".")
58+
.match(/^[A-Z]?\d*[.](mac|int|inc)$/)
59+
? 3
60+
: 2;
61+
file.name = nameParts.slice(0, -dotParts).join("/") + "/" + nameParts.slice(-dotParts).join(".");
4362
}
4463
if (!options.maxResults || ++counter <= options.maxResults) {
4564
return options.folder.with({ path: `/${file.name}` });

0 commit comments

Comments
 (0)