From e412248d948163e618bd9a9b6091011bd80601ce Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 1 Aug 2022 16:46:35 -0300 Subject: [PATCH] inlayhint: fix server crashers when open file is removed --- CHANGELOG.md | 1 + analysis/src/Hint.ml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e957cdf72..bad554bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Fix Incorrect semantic highlighting of `external` declarations https://github.com/rescript-lang/rescript-vscode/pull/517 - Fix issue where doc comment with nested comments inside is not shown properly on hover https://github.com/rescript-lang/rescript-vscode/pull/526 +- Fix server crashes when open file is removed from disk with inlayHints enabled https://github.com/rescript-lang/rescript-vscode/issues/538 ## v1.4.2 diff --git a/analysis/src/Hint.ml b/analysis/src/Hint.ml index 0f90ff8ea..1f69cf93a 100644 --- a/analysis/src/Hint.ml +++ b/analysis/src/Hint.ml @@ -82,7 +82,7 @@ let inlay ~path ~pos ~maxLength ~debug = Ast_iterator.default_iterator.value_binding iterator vb in let iterator = {Ast_iterator.default_iterator with value_binding} in - (if Filename.check_suffix path ".res" then + (if Files.exists path && Filename.check_suffix path ".res" then let parser = Res_driver.parsingEngine.parseImplementation ~forPrinter:false in @@ -143,7 +143,7 @@ let codeLens ~path ~debug = let iterator = {Ast_iterator.default_iterator with value_binding} in (* We only print code lenses in implementation files. This is because they'd be redundant in interface files, where the definition itself will be the same thing as what would've been printed in the code lens. *) - (if Filename.check_suffix path ".res" then + (if Files.exists path && Filename.check_suffix path ".res" then let parser = Res_driver.parsingEngine.parseImplementation ~forPrinter:false in