diff --git a/package.json b/package.json index 0c255a74987aa065dcdbc7431e10c0d21530f7c8..1b28cb82b9aa807aef92884008f577426593d0da 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "v8-inspect-profiler": "^0.0.7", "vscode-chokidar": "1.6.2", "vscode-debugprotocol": "1.25.0", - "vscode-ripgrep": "^0.7.1-patch.0", + "vscode-ripgrep": "0.7.1-patch.1.1", "vscode-textmate": "^3.2.0", "vscode-xterm": "3.2.0-beta1", "yauzl": "2.8.0" diff --git a/src/vs/workbench/services/search/node/ripgrepTextSearch.ts b/src/vs/workbench/services/search/node/ripgrepTextSearch.ts index a38556247ef22674508c6d17d124e8224545b95d..fcbb238920390b300d3d7eea2cfa312d785dce3e 100644 --- a/src/vs/workbench/services/search/node/ripgrepTextSearch.ts +++ b/src/vs/workbench/services/search/node/ripgrepTextSearch.ts @@ -164,11 +164,11 @@ export function rgErrorMsgForDisplay(msg: string): string | undefined { } export class RipgrepParser extends EventEmitter { - private static readonly RESULT_REGEX = /^\u001b\[m(\d+)\u001b\[m:(.*)(\r?)/; - private static readonly FILE_REGEX = /^\u001b\[m(.+)\u001b\[m$/; + private static readonly RESULT_REGEX = /^\u001b\[0m(\d+)\u001b\[0m:(.*)(\r?)/; + private static readonly FILE_REGEX = /^\u001b\[0m(.+)\u001b\[0m$/; - public static readonly MATCH_START_MARKER = '\u001b[m\u001b[31m'; - public static readonly MATCH_END_MARKER = '\u001b[m'; + public static readonly MATCH_START_MARKER = '\u001b[0m\u001b[31m'; + public static readonly MATCH_END_MARKER = '\u001b[0m'; private fileMatch: FileMatch; private remainder: string; diff --git a/src/vs/workbench/services/search/test/node/ripgrepTextSearch.test.ts b/src/vs/workbench/services/search/test/node/ripgrepTextSearch.test.ts index 71b2546f9a7ab4143f077555d4b5e4c93698c2fe..6f430e397a2638fcf7261abe735fdbbbaed07651 100644 --- a/src/vs/workbench/services/search/test/node/ripgrepTextSearch.test.ts +++ b/src/vs/workbench/services/search/test/node/ripgrepTextSearch.test.ts @@ -20,11 +20,11 @@ suite('RipgrepParser', () => { const fileSectionEnd = '\n'; function getFileLine(relativePath: string): string { - return `\u001b\[m${relativePath}\u001b\[m`; + return `\u001b\[0m${relativePath}\u001b\[0m`; } function getMatchLine(lineNum: number, matchParts: string[]): string { - let matchLine = `\u001b\[m${lineNum}\u001b\[m:` + + let matchLine = `\u001b\[0m${lineNum}\u001b\[0m:` + `${matchParts.shift()}${RipgrepParser.MATCH_START_MARKER}${matchParts.shift()}${RipgrepParser.MATCH_END_MARKER}${matchParts.shift()}`; while (matchParts.length) { @@ -156,21 +156,21 @@ suite('RipgrepParser', () => { }); test('Parses chunks broken in the middle of a multibyte character', () => { - const multibyteStr = '漢'; - const multibyteBuf = new Buffer(multibyteStr); - const text = getFileLine('foo/bar') + '\n' + getMatchLine(0, ['before', 'match', 'after']) + '\n'; - - // Split the multibyte char into two pieces and divide between the two buffers - const beforeIndex = 24; - const inputBufs = [ - Buffer.concat([new Buffer(text.substr(0, beforeIndex)), multibyteBuf.slice(0, 2)]), - Buffer.concat([multibyteBuf.slice(2), new Buffer(text.substr(beforeIndex))]) - ]; - - const results = parseInput(inputBufs); - assert.equal(results.length, 1); - assert.equal(results[0].lineMatches.length, 1); - assert.deepEqual(results[0].lineMatches[0].offsetAndLengths, [[7, 5]]); + const text = getFileLine('foo/bar') + '\n' + getMatchLine(0, ['before漢', 'match', 'after']) + '\n'; + const buf = new Buffer(text); + + // Split the buffer at every possible position - it should still be parsed correctly + for (let i = 0; i < buf.length; i++) { + const inputBufs = [ + buf.slice(0, i), + buf.slice(i) + ]; + + const results = parseInput(inputBufs); + assert.equal(results.length, 1); + assert.equal(results[0].lineMatches.length, 1); + assert.deepEqual(results[0].lineMatches[0].offsetAndLengths, [[7, 5]]); + } }); }); diff --git a/yarn.lock b/yarn.lock index 821d916f147039df5912ede0d68324a6751f345a..83635b79f2aaaac9b17f6bef4c4a1a7b13f5f93a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5992,9 +5992,9 @@ vscode-nls-dev@3.0.7: xml2js "^0.4.19" yargs "^10.1.1" -vscode-ripgrep@^0.7.1-patch.0: - version "0.7.1-patch.0" - resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-0.7.1-patch.0.tgz#738be8b6da5cb9a8807b528595a884b0dfcb60a5" +vscode-ripgrep@0.7.1-patch.1.1: + version "0.7.1-patch.1.1" + resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-0.7.1-patch.1.1.tgz#d5fd19979998ccd040fd54c144c4190135e9e5c2" vscode-textmate@^3.2.0: version "3.2.0"