Skip to content
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

Fix #1204: replace all rootPath usages with workspaceFolders #1600

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Components/Debugger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module Debugger =
}

let setProgramPath project (cfg : LaunchJsonVersion2.RequestLaunch) =
let relativeOutPath = node.path.relative(workspace.rootPath.Value, project.Output).Replace("\\", "/")
let relativeOutPath = node.path.relative(workspace.workspaceFolders.Value.[0].uri.path, project.Output).Replace("\\", "/")
let programPath = sprintf "${workspaceRoot}/%s" relativeOutPath

// WORKAROUND the project.Output is the obj assembly, instead of bin assembly
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Diagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Error: %s

let writeToFile (text : string) =
promise {
let path = node.path.join(workspace.rootPath.Value, "Diagnostic info")
let path = node.path.join(workspace.workspaceFolders.Value.[0].uri.path, "Diagnostic info")
let newFile = vscode.Uri.parse ("untitled:" + path)
let! document = newFile |> workspace.openTextDocument

Expand Down
6 changes: 3 additions & 3 deletions src/Components/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ module Fsi =
let dir = node.path.dirname file
file, dir
| None ->
let dir = workspace.rootPath.Value
let dir = workspace.workspaceFolders.Value.[0].uri.path
node.path.join(dir, "tmp.fsx"), dir

match lastCd with
Expand Down Expand Up @@ -477,7 +477,7 @@ module Fsi =
promise {
match ctn with
| Some c ->
let path = node.path.join(workspace.rootPath.Value, "references.fsx")
let path = node.path.join(workspace.workspaceFolders.Value.[0].uri.path, "references.fsx")
let! td = vscode.Uri.parse ("untitled:" + path) |> workspace.openTextDocument
let! te = window.showTextDocument(td, ViewColumn.Three)
let! _ = te.edit (fun e ->
Expand All @@ -501,7 +501,7 @@ module Fsi =
yield! project.Files |> Seq.map (sprintf "#load @\"%s\"")
|]
promise {
let path = node.path.join(workspace.rootPath.Value, "references.fsx")
let path = node.path.join(workspace.workspaceFolders.Value.[0].uri.path, "references.fsx")
let! td = vscode.Uri.parse ("untitled:" + path) |> workspace.openTextDocument
let! te = window.showTextDocument(td, ViewColumn.Three)
let! _ = te.edit (fun e ->
Expand Down
6 changes: 3 additions & 3 deletions src/Components/SolutionExplorer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ module SolutionExplorer =
res
) |> ResizeArray

let cwd = workspace.rootPath
let cwd = workspace.workspaceFolders |> Option.map (fun x -> x.[0])
match cwd with
| Some cwd ->
let! template = window.showQuickPick ( n |> U2.Case1)
Expand Down Expand Up @@ -577,10 +577,10 @@ module SolutionExplorer =
let pname =
if projName.IsSome then projName.Value + ".fsproj" else
if output.IsSome then output.Value + ".fsproj" else
(path.dirname workspace.rootPath.Value) + ".fsproj"
cwd.name + ".fsproj"

let proj =
path.join(workspace.rootPath.Value, dir, name, pname)
path.join(cwd.uri.path, dir, name, pname)
let args = ["sln"; slnName; "add"; proj]
Project.execWithDotnet MSBuild.outputChannel (ResizeArray args) |> ignore
| _ ->
Expand Down
8 changes: 4 additions & 4 deletions src/Core/LanguageService.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ionide.VSCode.FSharp
namespace Ionide.VSCode.FSharp

open System
open Fable.Core
Expand Down Expand Up @@ -73,7 +73,7 @@ module LanguageService =

let private handleUntitled (fn : string) = if fn.EndsWith ".fs" || fn.EndsWith ".fsi" || fn.EndsWith ".fsx" then fn else (fn + ".fsx")

/// runs `dotnet --version` in the current rootPath to determine the resolved sdk version from the global.json file.
/// runs `dotnet --version` in the first workspaceFolder to determine the resolved sdk version from the global.json file.
let runtimeVersion() = promise {
let! dotnet = Environment.dotnet
match dotnet with
Expand Down Expand Up @@ -673,8 +673,8 @@ Consider:

let discoverDotnetArgs () = promise {
let! (rollForwardArgs, necessaryEnvVariables) = promise {
let! sdkVersionAtRootPath = runtimeVersion()
match sdkVersionAtRootPath with
let! sdkVersionAtWorkspaceFolder = runtimeVersion()
match sdkVersionAtWorkspaceFolder with
| Error e ->
printfn $"FSAC (NETCORE): {e}"
return [], []
Expand Down
33 changes: 17 additions & 16 deletions src/Core/Project.fs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module Project =
lst

let isIgnored (path: string) =
let relativePath = node.path.relative (workspace.rootPath.Value, path)
let relativePath = node.path.relative (workspace.workspaceFolders.Value.[0].uri.path, path)

let isSubDir p =
let relativeToDir = node.path.relative(p, relativePath)
Expand Down Expand Up @@ -148,9 +148,9 @@ module Project =
| _ -> []
)

match workspace.rootPath with
match workspace.workspaceFolders |> Option.map (fun x -> x.[0]) with
| None -> []
| Some rootPath -> findProjs rootPath
| Some cwd -> findProjs cwd.uri.path

let getAll () =
let rec findProjs dir =
Expand All @@ -168,9 +168,9 @@ module Project =
| _ -> []
)

match workspace.rootPath with
match workspace.workspaceFolders |> Option.map (fun x -> x.[0]) with
| None -> []
| Some rootPath -> rootPath |> findProjs
| Some cwd -> findProjs cwd.uri.path

let private clearLoadedProjects () =
loadedProjects <- emptyProjectsMap
Expand Down Expand Up @@ -282,9 +282,9 @@ module Project =
| _ -> []
)

match workspace.rootPath with
match workspace.workspaceFolders |> Option.map (fun x -> x.[0]) with
| None -> []
| Some rootPath -> findProjs rootPath
| Some cwd -> findProjs cwd.uri.path

let clearCache () =
let cached = getCaches ()
Expand All @@ -308,7 +308,7 @@ module Project =
extensionWorkspaceState <- Some context.workspaceState

let private parse (value: string) =
let fullPath = path.resolve(workspace.rootPath.Value, value)
let fullPath = path.resolve(workspace.workspaceFolders.Value.[0].uri.path, value)
if value.ToLowerInvariant().EndsWith(".sln") then
ConfiguredWorkspace.Solution fullPath
else
Expand Down Expand Up @@ -367,7 +367,7 @@ module Project =
let configuredPath = getWorkspacePath value
if isConfiguredInWorkspace () then
let relativePath =
let raw = path.relative(workspace.rootPath.Value, configuredPath)
let raw = path.relative(workspace.workspaceFolders.Value.[0].uri.path, configuredPath)
if not (path.isAbsolute raw) && not (raw.StartsWith "..") then
"./" + raw
else
Expand Down Expand Up @@ -425,7 +425,7 @@ module Project =
item.description <- Some (sprintf "Directory with %i projects" dir.Fsprojs.Length)
item
| WorkspacePeekFound.Solution sln ->
let relative = path.relative (workspace.rootPath.Value, sln.Path)
let relative = path.relative (workspace.workspaceFolders.Value.[0].uri.path, sln.Path)
let item = createEmpty<QuickPickItem>
item.label <- sprintf "%s%s" check relative
item.description <- Some (sprintf "Solution with %i projects" (countProjectsInSln sln))
Expand Down Expand Up @@ -503,24 +503,25 @@ module Project =
promise {
let fsprojs = findAll ()
let wdir =
{ WorkspacePeekFoundDirectory.Directory = workspace.rootPath.Value
{ WorkspacePeekFoundDirectory.Directory = workspace.workspaceFolders.Value.[0].uri.path
Fsprojs = fsprojs |> Array.ofList }
return WorkspacePeekFound.Directory wdir
}

let private workspacePeek () =
promise {
if None = workspace.rootPath then return []
else
let! ws = LanguageService.workspacePeek workspace.rootPath.Value deepLevel (excluded |> List.ofArray)
match workspace.workspaceFolders |> Option.map (fun x -> x.[0]) with
| None -> return []
| Some cwd ->
let! ws = LanguageService.workspacePeek cwd.uri.path deepLevel (excluded |> List.ofArray)
return
ws.Found
|> Array.sortBy (fun x ->
match x with
| WorkspacePeekFound.Solution sln -> countProjectsInSln sln
| WorkspacePeekFound.Directory _ -> -1)
|> Array.rev
|> List.ofArray
|> Array.rev
|> List.ofArray
}

let private getWorkspace () =
Expand Down