diff --git a/src/vs/base/common/glob.ts b/src/vs/base/common/glob.ts index 41d0b57525acd0524e5dc06b0f2ceb6a9e4bd57f..00e6628a216dc57aee3a45ce8f44912a6a7f3ad9 100644 --- a/src/vs/base/common/glob.ts +++ b/src/vs/base/common/glob.ts @@ -299,7 +299,7 @@ function matchExpression(expression: IExpression, path: string, siblings?: strin } let clause = value; - let clausePattern = strings.replaceAll(clause.when, '$(basename)', basename); + let clausePattern = clause.when.replace('$(basename)', basename); if (siblings.some((sibling) => sibling === clausePattern)) { return pattern; } else { diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index 74f6813f563aca5b27e2c5dc1eeab074c9c9523b..9053b5fb65daca139b53002c47c2924587586425 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -65,13 +65,6 @@ export function escapeRegExpCharacters(value: string): string { return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&'); } -/** - * Searches for all occurrences of needle in haystack and replaces them with replacement. - */ -export function replaceAll(haystack: string, needle: string, replacement: string): string { - return haystack.replace(new RegExp(escapeRegExpCharacters(needle.toString()), 'g'), replacement); -} - /** * Removes all occurrences of needle from the beginning and end of haystack. * @param haystack string to trim @@ -145,7 +138,7 @@ export function convertSimple2RegExpPattern(pattern: string): string { } export function stripWildcards(pattern: string): string { - return replaceAll(pattern, '*', ''); + return pattern.replace(/\*/g, ''); } /** diff --git a/src/vs/workbench/parts/output/common/outputWorker.ts b/src/vs/workbench/parts/output/common/outputWorker.ts index 3102fa90b6fdc3fe5386cecbc1f3e1f6f85be422..ec7a30efae4e2c6d4ec7078927e3c46f558ce00d 100644 --- a/src/vs/workbench/parts/output/common/outputWorker.ts +++ b/src/vs/workbench/parts/output/common/outputWorker.ts @@ -105,7 +105,7 @@ export class OutputWorker { while ((match = pattern.exec(line)) !== null) { // Convert the relative path information to a resource that we can use in links - let workspaceRelativePath = strings.replaceAll(strings.rtrim(match[1], '.'), '\\', '/'); // remove trailing "." that likely indicate end of sentence + let workspaceRelativePath = strings.rtrim(match[1], '.').replace(/\\/g, '/'); // remove trailing "." that likely indicate end of sentence let resource:string; try { resource = contextService.toResource(workspaceRelativePath).toString(); diff --git a/src/vs/workbench/parts/output/test/outputWorker.test.ts b/src/vs/workbench/parts/output/test/outputWorker.test.ts index 88fefc28dfdc4977cf8e7aaaf794beb9ece3efe9..809a99273af109e8c87dcbafc3948e4916736614 100644 --- a/src/vs/workbench/parts/output/test/outputWorker.test.ts +++ b/src/vs/workbench/parts/output/test/outputWorker.test.ts @@ -6,7 +6,6 @@ 'use strict'; import * as assert from 'assert'; -import {replaceAll} from 'vs/base/common/strings'; import URI from 'vs/base/common/uri'; import {isMacintosh, isLinux} from 'vs/base/common/platform'; import {OutputWorker} from 'vs/workbench/parts/output/common/outputWorker'; @@ -14,7 +13,7 @@ import {TestContextService} from 'vs/workbench/test/browser/servicesTestUtils'; function toOSPath(p: string): string { if (isMacintosh || isLinux) { - return replaceAll(p, '\\', '/'); + return p.replace(/\\/g, '/'); } return p; diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index bde394f7420388f3061f08bd1699f1e7923c643c..33073851bd9912e1b6675ae734524d81fa03bc10 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -45,7 +45,7 @@ export class FileWalker { this.isLimitHit = false; if (this.filePattern) { - this.filePattern = strings.replaceAll(this.filePattern, '\\', '/'); // Normalize file patterns to forward slashes + this.filePattern = this.filePattern.replace(/\\/g, '/'); // Normalize file patterns to forward slashes this.normalizedFilePatternLowercase = strings.stripWildcards(this.filePattern).toLowerCase(); } }