Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 2bfe611

Browse files
committed
check that config file exists before reading
1 parent 793ba06 commit 2bfe611

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,15 @@ class RustLanguageClient extends AutoLanguageClient {
452452
// Don't build straight after initialize, wait for first `workspace/didChangeConfiguration`
453453
params.initializationOptions.omitInitBuild = true
454454

455-
try {
456-
let rlsConfigPath = path.join(projectPath, "rust-analyzer.json")
457-
let options = fs.readFileSync(rlsConfigPath)
458-
Object.assign(params.initializationOptions, JSON.parse(options))
459-
} catch(e) {
460-
console.warn("Could not read config file")
455+
let rlsConfigPath = path.join(projectPath, "rust-analyzer.json")
456+
457+
if (fs.existsSync(rlsConfigPath)) {
458+
try {
459+
let options = fs.readFileSync(rlsConfigPath)
460+
Object.assign(params.initializationOptions, JSON.parse(options))
461+
} catch(e) {
462+
console.warn("Error reading config file\n", e)
463+
}
461464
}
462465

463466
return params

0 commit comments

Comments
 (0)