Skip to content

Commit c05c22e

Browse files
authored
Improve regex server-side search (intersystems-community#1153)
1 parent 3b1e161 commit c05c22e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/providers/FileSystemProvider/TextSearchProvider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
340340
});
341341
};
342342

343+
// Generate the query pattern that gets sent to the server
344+
// Needed because the server matches the full line against the regex and ignores the case parameter when in regex mode
345+
const pattern = query.isRegExp ? `${!query.isCaseSensitive ? "(?i)" : ""}.*${query.pattern}.*` : query.pattern;
346+
343347
if (api.config.apiVersion >= 6) {
344348
// Build the request object
345349
const project = params.has("project") && params.get("project").length ? params.get("project") : undefined;
@@ -352,7 +356,7 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
352356
const request: AsyncSearchRequest = {
353357
request: "search",
354358
console: false, // Passed so the server doesn't send us back console output
355-
query: query.pattern,
359+
query: pattern,
356360
regex: query.isRegExp,
357361
project,
358362
word: query.isWordMatch, // Ignored if regex is true
@@ -473,7 +477,7 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
473477
throttleRequests((group: string[]) =>
474478
api
475479
.actionSearch({
476-
query: query.pattern,
480+
query: pattern,
477481
regex: query.isRegExp,
478482
word: query.isWordMatch,
479483
case: query.isCaseSensitive,
@@ -553,7 +557,7 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
553557

554558
searchPromise = api
555559
.actionSearch({
556-
query: query.pattern,
560+
query: pattern,
557561
regex: query.isRegExp,
558562
word: query.isWordMatch,
559563
case: query.isCaseSensitive,

0 commit comments

Comments
 (0)