mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
parent
07a4dfeb46
commit
50976d6e15
|
@ -44,7 +44,7 @@
|
|||
"v8-inspect-profiler": "^0.0.7",
|
||||
"vscode-chokidar": "1.6.2",
|
||||
"vscode-debugprotocol": "1.26.0",
|
||||
"vscode-ripgrep": "0.7.1-patch.1.1",
|
||||
"vscode-ripgrep": "^0.7.1-patch.0",
|
||||
"vscode-textmate": "^3.2.0",
|
||||
"vscode-xterm": "3.2.0-beta4",
|
||||
"yauzl": "2.8.0"
|
||||
|
|
|
@ -169,11 +169,11 @@ export function rgErrorMsgForDisplay(msg: string): string | undefined {
|
|||
}
|
||||
|
||||
export class RipgrepParser extends EventEmitter {
|
||||
private static readonly RESULT_REGEX = /^\u001b\[0m(\d+)\u001b\[0m:(.*)(\r?)/;
|
||||
private static readonly FILE_REGEX = /^\u001b\[0m(.+)\u001b\[0m$/;
|
||||
private static readonly RESULT_REGEX = /^\u001b\[m(\d+)\u001b\[m:(.*)(\r?)/;
|
||||
private static readonly FILE_REGEX = /^\u001b\[m(.+)\u001b\[m$/;
|
||||
|
||||
public static readonly MATCH_START_MARKER = '\u001b[0m\u001b[31m';
|
||||
public static readonly MATCH_END_MARKER = '\u001b[0m';
|
||||
public static readonly MATCH_START_MARKER = '\u001b[m\u001b[31m';
|
||||
public static readonly MATCH_END_MARKER = '\u001b[m';
|
||||
|
||||
private fileMatch: FileMatch;
|
||||
private remainder: string;
|
||||
|
|
|
@ -20,11 +20,11 @@ suite('RipgrepParser', () => {
|
|||
const fileSectionEnd = '\n';
|
||||
|
||||
function getFileLine(relativePath: string): string {
|
||||
return `\u001b\[0m${relativePath}\u001b\[0m`;
|
||||
return `\u001b\[m${relativePath}\u001b\[m`;
|
||||
}
|
||||
|
||||
function getMatchLine(lineNum: number, matchParts: string[]): string {
|
||||
let matchLine = `\u001b\[0m${lineNum}\u001b\[0m:` +
|
||||
let matchLine = `\u001b\[m${lineNum}\u001b\[m:` +
|
||||
`${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 text = getFileLine('foo/bar') + '\n' + getMatchLine(0, ['before漢', 'match', 'after']) + '\n';
|
||||
const buf = new Buffer(text);
|
||||
const multibyteStr = '漢';
|
||||
const multibyteBuf = new Buffer(multibyteStr);
|
||||
const text = getFileLine('foo/bar') + '\n' + getMatchLine(0, ['before', 'match', 'after']) + '\n';
|
||||
|
||||
// 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)
|
||||
];
|
||||
// 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 results = parseInput(inputBufs);
|
||||
assert.equal(results.length, 1);
|
||||
assert.equal(results[0].lineMatches.length, 1);
|
||||
assert.deepEqual(results[0].lineMatches[0].offsetAndLengths, [[7, 5]]);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -5992,9 +5992,9 @@ vscode-nls-dev@3.0.7:
|
|||
xml2js "^0.4.19"
|
||||
yargs "^10.1.1"
|
||||
|
||||
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-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-textmate@^3.2.0:
|
||||
version "3.2.0"
|
||||
|
|
Loading…
Reference in a new issue