Delay the require of the vscode-ripgrep module

Since a new RipgrepDirectorySearcher is constructed during the snapshot
creation, we cannot require vscode-ripgrep from there (since it's not in
the snapshot).
This commit is contained in:
Rafael Oleza
2019-05-17 12:11:27 +02:00
parent d35aef3bf0
commit 0cbd329e34

View File

@@ -74,10 +74,6 @@ function updateTrailingContexts (message, pendingTrailingContexts, options) {
}
module.exports = class RipgrepDirectorySearcher {
constructor () {
this.rgPath = require('vscode-ripgrep').rgPath
}
canSearchDirectory () {
return true
}
@@ -116,6 +112,11 @@ module.exports = class RipgrepDirectorySearcher {
// Returns a *thenable* `DirectorySearch` that includes a `cancel()` method. If `cancel()` is
// invoked before the `DirectorySearch` is determined, it will resolve the `DirectorySearch`.
search (directories, regexp, options) {
// Delay the require of vscode-ripgrep to not mess with the snapshot creation.
if (!this.rgPath) {
this.rgPath = require('vscode-ripgrep').rgPath
}
const paths = directories.map(d => d.getPath())
const args = ['--json', '--regexp', regexp.source]