Skip to content

Commit 380be44

Browse files
committed
DLS: Be better at matching an open file URI to a compiler instance
The DLS runs as many compiler instances as there are subprojects in the build . When a file is opened we need to decide which compiler instance should handle it, this is done by matching the file URI against the source directories configured for each subproject. This commit improves this matching in two way: - Use URI#getPath instead of URI#getRawPath to decode percent-encoded characters in the URI - Use File#getCanonicalPath instead of File#getAbsolutePath The first fix is necessary to get the DLS running in Windows, because URIs start with file:///C%3A/.../ and we need getPath to decode "C%3A" to "C:".
1 parent 369fdec commit 380be44

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class DottyLanguageServer extends LanguageServer
7676
def driverFor(uri: URI): InteractiveDriver = {
7777
val matchingConfig =
7878
drivers.keys.find(config => config.sourceDirectories.exists(sourceDir =>
79-
uri.getRawPath.startsWith(sourceDir.getAbsolutePath.toString)))
79+
new File(uri.getPath).getCanonicalPath.startsWith(sourceDir.getCanonicalPath)))
8080
matchingConfig match {
8181
case Some(config) =>
8282
drivers(config)

0 commit comments

Comments
 (0)