From 0cbd329e34613c64cebc761ceead2dd84ef62b1b Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Fri, 17 May 2019 12:11:27 +0200 Subject: [PATCH] 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). --- src/ripgrep-directory-searcher.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ripgrep-directory-searcher.js b/src/ripgrep-directory-searcher.js index d1bfcf833..6f0f4f1fa 100644 --- a/src/ripgrep-directory-searcher.js +++ b/src/ripgrep-directory-searcher.js @@ -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]