提交 729cf967 编写于 作者: R Rob Lourens

Fix #51623 - tweak rg error message for \n

上级 d8555f56
......@@ -12,8 +12,6 @@ import * as vscode from 'vscode';
import { rgPath } from 'vscode-ripgrep';
import { anchorGlob } from './ripgrepHelpers';
// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');
......@@ -118,7 +116,7 @@ export class RipgrepTextSearchEngine {
* "failed" when a fatal error was produced.
*/
export function rgErrorMsgForDisplay(msg: string): string | undefined {
const firstLine = msg.split('\n')[0];
const firstLine = msg.split('\n')[0].trim();
if (firstLine.startsWith('Error parsing regex')) {
return firstLine;
......@@ -130,8 +128,13 @@ export function rgErrorMsgForDisplay(msg: string): string | undefined {
return firstLine.charAt(0).toUpperCase() + firstLine.substr(1);
}
if (firstLine === `Literal '\\n' not allowed.`) {
// I won't localize this because none of the Ripgrep error messages are localized
return `Literal '\\n' currently not supported`;
}
if (firstLine.startsWith('Literal ')) {
// e.g. "Literal \n not allowed"
// Other unsupported chars
return firstLine;
}
......
......@@ -4,24 +4,21 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as cp from 'child_process';
import { EventEmitter } from 'events';
import * as path from 'path';
import { StringDecoder, NodeStringDecoder } from 'string_decoder';
import * as cp from 'child_process';
import { rgPath } from 'vscode-ripgrep';
import { NodeStringDecoder, StringDecoder } from 'string_decoder';
import * as glob from 'vs/base/common/glob';
import * as objects from 'vs/base/common/objects';
import * as paths from 'vs/base/common/paths';
import * as platform from 'vs/base/common/platform';
import * as strings from 'vs/base/common/strings';
import * as paths from 'vs/base/common/paths';
import * as extfs from 'vs/base/node/extfs';
import * as encoding from 'vs/base/node/encoding';
import * as glob from 'vs/base/common/glob';
import { TPromise } from 'vs/base/common/winjs.base';
import { ISerializedFileMatch, ISerializedSearchComplete, IRawSearch, IFolderSearch, LineMatch, FileMatch } from './search';
import * as encoding from 'vs/base/node/encoding';
import * as extfs from 'vs/base/node/extfs';
import { IProgress } from 'vs/platform/search/common/search';
import { rgPath } from 'vscode-ripgrep';
import { FileMatch, IFolderSearch, IRawSearch, ISerializedFileMatch, ISerializedSearchComplete, LineMatch } from './search';
// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');
......@@ -148,7 +145,7 @@ export class RipgrepEngine {
* "failed" when a fatal error was produced.
*/
export function rgErrorMsgForDisplay(msg: string): string | undefined {
const firstLine = msg.split('\n')[0];
const firstLine = msg.split('\n')[0].trim();
if (strings.startsWith(firstLine, 'Error parsing regex')) {
return firstLine;
......@@ -160,8 +157,13 @@ export function rgErrorMsgForDisplay(msg: string): string | undefined {
return firstLine.charAt(0).toUpperCase() + firstLine.substr(1);
}
if (firstLine === `Literal '\\n' not allowed.`) {
// I won't localize this because none of the Ripgrep error messages are localized
return `Literal '\\n' currently not supported`;
}
if (strings.startsWith(firstLine, 'Literal ')) {
// e.g. "Literal \n not allowed"
// Other unsupported chars
return firstLine;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册