Skip to content

infra: Do not fail when neither worspace folders nor workspace root is provided #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Marksman/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ let extractWorkspaceFolders (par: InitializeParams) : Map<string, PathUri> =
|> Array.map (fun { Name = name; Uri = uri } -> name, PathUri.fromString uri)
|> Map.ofArray
| _ ->
let rootPath =
par.RootUri
|> Option.orElse par.RootPath
|> Option.defaultWith (fun () -> failwith $"No folders configured in workspace: {par}")
let rootPath = par.RootUri |> Option.orElse par.RootPath

let rootUri = PathUri.fromString rootPath
match rootPath with
| None ->
// No folders are configured. The client can still add folders later using a notification.
Map.empty
| Some rootPath ->
let rootUri = PathUri.fromString rootPath

let rootName = Path.GetFileName(rootUri.LocalPath)
let rootName = Path.GetFileName(rootUri.LocalPath)

Map.ofList [ rootName, rootUri ]
Map.ofList [ rootName, rootUri ]

let readWorkspace (roots: Map<string, PathUri>) : list<Folder> =
seq {
Expand Down