Skip to content

Commit 6e57279

Browse files
committed
Respect type=cls etc on isfs uri, and handle packages in include/exclude
1 parent e0e9b74 commit 6e57279

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/providers/FileSystemProvider/TextSearchProvider.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,16 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
106106
const genStr = params.has("generated") && params.get("generated").length ? params.get("generated") : "0";
107107

108108
let uri = options.folder;
109-
const uriQuery = new URLSearchParams(uri.query);
110109

111-
if (!uriQuery.has("filter")) {
112-
// Unless isfs spec already includes a filter (which it rarely does), apply includes and excludes at the server side.
110+
if (!params.get("filter")) {
111+
// Unless isfs spec already includes a non-empty filter (which it rarely does), apply includes and excludes at the server side.
113112
// If include or exclude field is set to, say, A1B2M*.int there will be two consecutive options.[in|ex]cludes elements:
114113
// **/A1B2M*.int/**
115114
// **/A1B2M*.int
116115
//
117116
// Ignore first, and strip **/ prefix from second.
118117
// When 'Use Exclude Settings and Ignore Files' is enabled (which is typical) options.excludes will also contain entries from files.exclude and search.exclude settings.
119-
// This will result in additional server-side filtering which is probably superfluous but harmless (other than perhaps incurring a performance cost, probably small).
118+
// This will result in additional server-side filtering which is superfluous but harmless other than perhaps incurring a small(?) performance cost.
120119
const tidyFilters = (filters: string[]): string[] => {
121120
return filters
122121
.map((value, index, array) =>
@@ -128,12 +127,18 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
128127
)
129128
.filter((value) => value !== "");
130129
};
131-
const tidiedIncludes = tidyFilters(options.includes);
132-
const tidiedExcludes = tidyFilters(options.excludes);
133-
const filter = tidiedIncludes.join(",") + (tidiedExcludes.length === 0 ? "" : ",'" + tidiedExcludes.join(",'"));
130+
const filterExclude = tidyFilters(options.excludes).join(",'");
131+
const filterInclude =
132+
options.includes.length > 0
133+
? tidyFilters(options.includes).join(",")
134+
: filterExclude
135+
? fileSpecFromURI(uri) // Excludes were specified but no includes, so start with the default includes (this makes type=cls|rtn work)
136+
: "";
137+
const filter = filterInclude + (!filterExclude ? "" : ",'" + filterExclude);
134138
if (filter) {
135-
uriQuery.append("filter", filter);
136-
uri = options.folder.with({ query: uriQuery.toString() });
139+
const csp = params.has("csp") && ["", "1"].includes(params.get("csp"));
140+
params.append("filter", csp ? filter : filter.replace(/\//g, "."));
141+
uri = options.folder.with({ query: params.toString() });
137142
}
138143
}
139144

0 commit comments

Comments
 (0)