From 89fef59157a59af1addb730e8d9ae5ab74f6ee1c Mon Sep 17 00:00:00 2001 From: teslae1 Date: Fri, 9 Jan 2026 13:21:29 +0100 Subject: [PATCH 1/2] added conversion to convert vim regex to js regex (without disturbing the displayed text in commandline) --- src/vimscript/pattern.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vimscript/pattern.ts b/src/vimscript/pattern.ts index 230cb3b6b5a..ba945f73a47 100644 --- a/src/vimscript/pattern.ts +++ b/src/vimscript/pattern.ts @@ -305,10 +305,13 @@ export class Pattern { caseOverride, ignoreSmartcase: args.ignoreSmartcase ?? false, }); + + const jsPatternString = Pattern.convertToJsCompatiblePattern(patternString); + return new Pattern( patternString, args.direction, - Pattern.compileRegex(patternString, ignoreCase), + Pattern.compileRegex(jsPatternString, ignoreCase), inSelection ?? false, closed, emptyBranch, @@ -328,6 +331,10 @@ export class Pattern { return configuration.ignorecase; } + private static convertToJsCompatiblePattern(patternString: string): string { + return patternString.replace(/\\\(/g, '(').replace(/\\\)/g, ')'); + } + private constructor( patternString: string, direction: SearchDirection, From b890ae2a472d9e94daa50055fb3cd99a4230e55b Mon Sep 17 00:00:00 2001 From: teslae1 Date: Fri, 9 Jan 2026 15:27:25 +0100 Subject: [PATCH 2/2] added test to verify new functionality --- test/search/search.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/search/search.test.ts b/test/search/search.test.ts index 2b34da6ed44..bcf388bfba3 100644 --- a/test/search/search.test.ts +++ b/test/search/search.test.ts @@ -16,6 +16,13 @@ suite('Search (/ and ?)', () => { end: ['', 'one tw|o2o'], }); + newTest({ + title: '/ can search with regex groupings (search for sequence of aX where X is not b)', + start: ['|', 'ab ac'], + keysPressed: '/a\\([^b]\\)\n', + end: ['', 'ab |ac'], + }); + newTest({ title: '/ can search with newline', start: ['|asdf', '__asdf', 'asdf'],