OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.72k stars 417 forks source link

LSP rootUri is ignored in favor of cwd (regression?) #2613

Open krobelus opened 1 month ago

krobelus commented 1 month ago

Commit 30db3e09 (Updated host to use provided solution file., 2021-02-28) from https://github.com/OmniSharp/omnisharp-roslyn/pull/2099 seems to have regressed rootUri handling (cc @david-driscoll).

Before that commit, initializeParams.RootUri was always used if non-null. After that commit, application.ApplicationRoot was always used if non-null, potentially overriding a non-null initializeParams.RootUri.

Specifically, if there are two projects

someproject.sln
somesubproject/somesubproject.sln

and if OmniSharp is started with somesubproject/ as working directory, then application.ApplicationRoot will be somesubproject/, even if initializeParams.RootUri sent by the LSP requests to use the parent directory.

My guess is that the reason for this commit was to enable a user override with the omnisharp -s. That's fine but I don't think the override should happen when starting OmniSharp without -s.

It is wrong in this case because OmniSharp uses only the current working directory to determine application.ApplicationRoot; but the LSP client also uses the current file, which may be outside the working directory.

Originally reported at https://github.com/kakoune-lsp/kakoune-lsp/pull/746