Skip to content

Commit

Permalink
[BSP] Use consistent file URI format (#2803)
Browse files Browse the repository at this point in the history
Previously we were emitting different URI formats if the sourceFile info
was missing or not.
Not sure if this is a problem, but `targetId.getUri` is returning files
as `file:///foo/bar/file.scala` while our `java.io.File` `toURI` returns
`file:/foo/bar/file.scala`
Changing it to `.toPath.toUri` for consistency

Pull request: #2803

Co-authored-by: Tobias Roeser <le.petit.fou@web.de>
  • Loading branch information
lolgab and lefou authored Oct 2, 2023
1 parent b95cf46 commit 7c2114e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ private class BspCompileProblemReporter(
val diagnostic = getSingleDiagnostic(problem)
val sourceFile = problem.position.sourceFile
val textDocument = new TextDocumentIdentifier(
sourceFile.getOrElse(None) match {
sourceFile match {
case None => targetId.getUri
case f: File => f.toURI.toString
case Some(f) =>
// The extra step invoking `toPath` results in a nicer URI starting with `file:///`
f.toPath.toUri.toString
}
)
val params = new bsp.PublishDiagnosticsParams(
Expand Down

0 comments on commit 7c2114e

Please sign in to comment.