Skip to content

Commit 60404b1

Browse files
authored
Have FileSearchProvider use DocumentContentProvider.getUri() to generate URIs (#862)
1 parent 3c2fa74 commit 60404b1

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

src/providers/FileSystemProvider/FileSearchProvider.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as vscode from "vscode";
22
import * as url from "url";
3-
import { AtelierAPI } from "../../api";
43
import { StudioOpenDialog } from "../../queries";
54
import { studioOpenDialogFromURI } from "../../utils/FileProviderUtil";
5+
import { notNull } from "../../utils";
6+
import { DocumentContentProvider } from "../DocumentContentProvider";
67

78
export class FileSearchProvider implements vscode.FileSearchProvider {
89
/**
@@ -32,40 +33,26 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
3233
filter = "";
3334
}
3435
let counter = 0;
36+
if (token.isCancellationRequested) {
37+
return;
38+
}
3539
return studioOpenDialogFromURI(options.folder, { flat: true, filter: filter })
3640
.then((data) => {
3741
return data.result.content;
3842
})
3943
.then((data: StudioOpenDialog[]) => {
40-
const api = new AtelierAPI(options.folder);
4144
return data
4245
.map((item: StudioOpenDialog) => {
43-
// item.Type only matters here if it is 5 (CSP)
44-
if (item.Type == "5" && !csp) {
46+
if (token.isCancellationRequested) {
4547
return null;
4648
}
47-
if (item.Type !== "5") {
48-
if (item.Name.startsWith("%") && api.ns !== "%SYS") {
49-
return null;
50-
}
51-
// Convert dotted name to slashed one, treating the likes of ABC.1.int or DEF.T1.int in the same way
52-
// as the Studio dialog does.
53-
const nameParts = item.Name.split(".");
54-
const dotParts = nameParts
55-
.slice(-2)
56-
.join(".")
57-
.match(/^[A-Z]?\d*[.](mac|int|inc)$/)
58-
? 3
59-
: 2;
60-
item.Name = nameParts.slice(0, -dotParts).join("/") + "/" + nameParts.slice(-dotParts).join(".");
61-
}
6249
if (!options.maxResults || ++counter <= options.maxResults) {
63-
return vscode.Uri.parse(`${options.folder.scheme}://${options.folder.authority}/${item.Name}`, true);
50+
return DocumentContentProvider.getUri(item.Name, "", "", true, options.folder);
6451
} else {
6552
return null;
6653
}
6754
})
68-
.filter((el) => el !== null);
55+
.filter(notNull);
6956
});
7057
}
7158
}

0 commit comments

Comments
 (0)