Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseWorkspaceSearchProvider } from '../search-utils/base-provider'
import { fuzzyContains, splitLines } from 'vs/base/common/strings'
import { fuzzyContains, splitLines, createRegExp } from 'vs/base/common/strings'
import type { URI } from 'vs/base/common/uri'
import * as glob from 'vs/base/common/glob'
import type {
Expand Down Expand Up @@ -270,12 +270,13 @@ export class WorkspaceSearchProvider
*/
private createSearchRegex(contentPattern: ITextQuery['contentPattern']): RegExp {
try {
return new RegExp(
contentPattern.pattern || '',
(contentPattern.isCaseSensitive ? 'g' : 'gi') +
(contentPattern.isMultiline ? 'm' : '') +
(contentPattern.isUnicode ? 'u' : '')
)
return createRegExp(contentPattern.pattern || '', !!contentPattern.isRegExp, {
wholeWord: contentPattern.isWordMatch,
global: true,
matchCase: contentPattern.isCaseSensitive,
multiline: contentPattern.isMultiline,
unicode: contentPattern.isUnicode
})
} catch (regexError) {
this.logger.error(`Invalid regex pattern: ${contentPattern.pattern}`, regexError as Error)
const searchError = new SearchError(
Expand Down