From 59bdc8d3548584b9867e8f2de8f7c8bdbf65bdc2 Mon Sep 17 00:00:00 2001 From: Dominik Schachten Date: Tue, 5 Mar 2024 20:43:49 +0100 Subject: [PATCH] Fix fs.lstatSync throws Exception if no file or dir If it throws the Exception, other valid uris such as atom://teletype/... will not be evaluated in the else branch The old fs-plus did not throw. Newer versions of fs.lstatSync allow for option parameter to control if it throws. --- packages/fuzzy-finder/lib/fuzzy-finder-view.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/fuzzy-finder/lib/fuzzy-finder-view.js b/packages/fuzzy-finder/lib/fuzzy-finder-view.js index 35b943422..1ad503f6c 100644 --- a/packages/fuzzy-finder/lib/fuzzy-finder-view.js +++ b/packages/fuzzy-finder/lib/fuzzy-finder-view.js @@ -166,10 +166,14 @@ module.exports = class FuzzyFinderView { this.moveToCaretPosition(caretPosition) } else if (!uri) { this.cancel() - } else if (fs.lstatSync(uri).isDirectory()) { - this.selectListView.update({errorMessage: 'Selected path is a directory'}) - setTimeout(() => { this.selectListView.update({errorMessage: null}) }, 2000) } else { + try { + if (fs.lstatSync(uri).isDirectory()) { + this.selectListView.update({errorMessage: 'Selected path is a directory'}) + setTimeout(() => { this.selectListView.update({errorMessage: null}) }, 2000) + return + } + } catch (e) {} const caretPosition = this.getCaretPosition() this.cancel() this.openURI(uri, caretPosition, openOptions)