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.
This commit is contained in:
Dominik Schachten 2024-03-05 20:43:49 +01:00
parent 4c6d9071c2
commit 59bdc8d354

View File

@ -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)