Skip to content

Commit 1bbc85a

Browse files
committed
fix(lsp): if a workspace contains nested folders, only use the outermost one
1 parent 65fb45f commit 1bbc85a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

language-server/src/main/kotlin/tools/samt/ls/SamtLanguageServer.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tools.samt.common.*
66
import java.io.Closeable
77
import java.util.concurrent.CompletableFuture
88
import java.util.logging.Logger
9+
import kotlin.io.path.Path
910
import kotlin.system.exitProcess
1011

1112
class SamtLanguageServer : LanguageServer, LanguageClientAware, Closeable {
@@ -52,9 +53,11 @@ class SamtLanguageServer : LanguageServer, LanguageClientAware, Closeable {
5253
}
5354

5455
private fun buildSamtModel(params: InitializeParams) {
55-
params.workspaceFolders.forEach {
56-
val path = it.uri.uriToPath()
57-
workspaces[path] = buildWorkspace(path)
56+
val folders = params.workspaceFolders.map { it.uri.uriToPath() }
57+
for (folder in folders) {
58+
// if the folder is contained within another folder ignore it
59+
if (folders.any { folder != it && Path(folder).startsWith(it) }) continue
60+
workspaces[folder] = buildWorkspace(folder)
5861
}
5962
}
6063

0 commit comments

Comments
 (0)