Skip to content

Commit

Permalink
Tweak ripgrep error handling - whitelist errors instead of blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Apr 22, 2017
1 parent 26ce469 commit 4818c79
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vs/workbench/services/search/node/ripgrepTextSearch.ts
Expand Up @@ -131,7 +131,12 @@ export class RipgrepEngine {
});
}

private rgErrorMsgForDisplay(msg: string): string {
/**
* Read the first line of stderr and return an error for display or undefined, based on a whitelist.
* Ripgrep produces stderr output which is not from a fatal error, and we only want the search to be
* "failed" when a fatal error was produced.
*/
private rgErrorMsgForDisplay(msg: string): string | undefined {
const firstLine = msg.split('\n')[0];
if (firstLine.match(/^No files were searched, which means ripgrep/)) {
// Not really a useful message to show in the UI
Expand All @@ -147,7 +152,7 @@ export class RipgrepEngine {
return this.config.searchPaths && this.config.searchPaths.indexOf(errorPath) >= 0 ? firstLine : undefined;
}

return firstLine;
return strings.startsWith(firstLine, 'Error parsing regex') ? firstLine : undefined;
}
}

Expand Down

0 comments on commit 4818c79

Please sign in to comment.