From 0dd0bcc1f8aebbd0ea6025055f67c09fcf3555af Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Tue, 5 Dec 2023 10:10:00 +0100 Subject: [PATCH] improvement: Check if Scala file exists before calculating md5 This used to break after renaming file. --- .../src/main/scala/scala/meta/internal/mtags/Semanticdbs.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/Semanticdbs.scala b/mtags/src/main/scala/scala/meta/internal/mtags/Semanticdbs.scala index 8ec3da4a96c..e7822d4cae9 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/Semanticdbs.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/Semanticdbs.scala @@ -66,7 +66,7 @@ object Semanticdbs { val sdocs = loadTextDocuments(semanticdbPath) sdocs.documents.find(_.uri.replace("\\", "/") == reluri) match { case None => TextDocumentLookup.NoMatchingUri(scalaPath, sdocs) - case Some(sdoc) => + case Some(sdoc) if scalaPath.exists => val text = FileIO.slurp(scalaPath, charset) val md5 = MD5.compute(text) val sdocMd5 = sdoc.md5.toUpperCase() @@ -81,6 +81,7 @@ object Semanticdbs { } else { TextDocumentLookup.Success(sdoc.withText(text)) } + case _ => TextDocumentLookup.NotFound(scalaPath) } } def printTextDocument(doc: s.TextDocument): String = {