Skip to content

Commit 4d3a364

Browse files
committed
fix(Initialization): actually read InitializeParams.rootPath and .rootUri
1 parent d26d6ce commit 4d3a364

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/CSharpLanguageServer/Handlers/Initialization.fs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ open CSharpLanguageServer.State.ServerState
1515
open CSharpLanguageServer.Types
1616
open CSharpLanguageServer.Logging
1717
open CSharpLanguageServer.Roslyn.Solution
18+
open CSharpLanguageServer.Util
1819

1920

2021
[<RequireQualifiedAccess>]
@@ -61,8 +62,34 @@ module Initialization =
6162
logger.LogDebug("handleInitialize: p.Capabilities: {caps}", serialize p.Capabilities)
6263
context.Emit(ClientCapabilityChange p.Capabilities)
6364

64-
// TODO use p.RootUri
65-
let rootPath = Directory.GetCurrentDirectory()
65+
logger.LogDebug(
66+
"handleInitialize: p.RootPath={rootPath}, p.RootUri={rootUri}, p.WorkspaceFolders={wf}",
67+
p.RootPath,
68+
p.RootUri,
69+
p.WorkspaceFolders
70+
)
71+
72+
// TODO use p.WorkspaceFolders
73+
let rootPath, rootPathSource =
74+
p.RootUri
75+
|> Option.map (fun rootUri -> (Uri.toPath rootUri, "InitializeParams.rootUri"))
76+
|> Option.orElse (
77+
p.RootPath
78+
|> Option.map (fun rootPath -> (rootPath, "InitializeParams.rootPath"))
79+
)
80+
|> Option.defaultValue (Directory.GetCurrentDirectory(), "Process CWD")
81+
82+
do!
83+
windowShowMessage (
84+
sprintf "csharp-ls: will use \"%s\" (%s) as workspace root path" rootPath rootPathSource
85+
)
86+
87+
logger.LogDebug(
88+
"handleInitialize: using rootPath \"{rootPath}\" from {rootPathSource}",
89+
rootPath,
90+
rootPathSource
91+
)
92+
6693
context.Emit(RootPathChange rootPath)
6794

6895
// setup timer so actors get period ticks

0 commit comments

Comments
 (0)