Skip to content

Commit

Permalink
improvement: Check if Scala file exists before calculating md5
Browse files Browse the repository at this point in the history
This used to break after renaming file.
  • Loading branch information
jkciesluk committed Dec 5, 2023
1 parent 1870e89 commit 0dd0bcc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -81,6 +81,7 @@ object Semanticdbs {
} else {
TextDocumentLookup.Success(sdoc.withText(text))
}
case _ => TextDocumentLookup.NotFound(scalaPath)
}
}
def printTextDocument(doc: s.TextDocument): String = {
Expand Down

0 comments on commit 0dd0bcc

Please sign in to comment.