-
Notifications
You must be signed in to change notification settings - Fork 161
Adopt workspaceFolders instead of deprecated RootPath/RootUri (stages 1 & 2) #1427
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
Draft
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-13540650-35509448-eb6f44c4-f5be-4d00-b6e1-171db2214d17
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5cd7f90
Initial plan
Copilot fa89932
Implement stages 1 & 2: adopt workspaceFolders instead of deprecated …
Copilot 2e03272
Add comprehensive tests for workspaceFolders initialization
Copilot 1b461d4
Format code with fantomas to fix CI formatting errors
Copilot 3bec193
Fix InitTest failure by respecting AutomaticWorkspaceInit setting
Copilot 6a21e47
Fix InitTest by preferring deprecated fields when AutomaticWorkspaceI…
Copilot 4107786
Addressing PR comments
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| module FsAutoComplete.Tests.WorkspaceFolderTests | ||
|
|
||
| open Expecto | ||
| open System.IO | ||
| open Ionide.LanguageServerProtocol | ||
| open Ionide.LanguageServerProtocol.Types | ||
| open FsAutoComplete | ||
| open FsAutoComplete.Lsp | ||
| open FsAutoComplete.LspHelpers | ||
| open Helpers | ||
| open Utils.Server | ||
|
|
||
| /// Tests for workspaceFolders initialization (stages 1 & 2) | ||
| let tests createServer = | ||
| testList | ||
| "WorkspaceFolder Tests" | ||
| [ testCaseAsync "Single workspace folder is selected correctly" | ||
| <| async { | ||
| let testDir = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ServerTests") | ||
| let (server: IFSharpLspServer), _events = createServer () | ||
|
|
||
| let p: InitializeParams = | ||
| { ProcessId = Some 1 | ||
| RootPath = None | ||
| Locale = None | ||
| RootUri = None | ||
| InitializationOptions = Some(Server.serialize defaultConfigDto) | ||
| Capabilities = clientCaps | ||
| ClientInfo = Some { Name = "Test"; Version = Some "1.0" } | ||
| WorkspaceFolders = Some [| { Uri = (Path.FilePathToUri testDir); Name = "Test" } |] | ||
| Trace = None | ||
| WorkDoneToken = None } | ||
|
|
||
| match! server.Initialize p with | ||
| | Ok _ -> () | ||
| | Error e -> failtest $"Initialize failed: {e}" | ||
| } | ||
|
|
||
| testCaseAsync "Multiple workspace folders - selects first with F# code" | ||
| <| async { | ||
| let testDir = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ServerTests") | ||
| let emptyDir = Path.GetTempPath() | ||
| let (server: IFSharpLspServer), _events = createServer () | ||
|
|
||
| // First folder has no F# code, second has F# projects | ||
| let p: InitializeParams = | ||
| { ProcessId = Some 1 | ||
| RootPath = None | ||
| Locale = None | ||
| RootUri = None | ||
| InitializationOptions = Some(Server.serialize defaultConfigDto) | ||
| Capabilities = clientCaps | ||
| ClientInfo = Some { Name = "Test"; Version = Some "1.0" } | ||
| WorkspaceFolders = Some [| { Uri = (Path.FilePathToUri emptyDir); Name = "Empty" }; { Uri = (Path.FilePathToUri testDir); Name = "Test" } |] | ||
| Trace = None | ||
| WorkDoneToken = None } | ||
|
|
||
| match! server.Initialize p with | ||
| | Ok _ -> () | ||
| | Error e -> failtest $"Initialize failed: {e}" | ||
| } | ||
|
|
||
| testCaseAsync "Backward compatibility - uses RootUri when WorkspaceFolders is None" | ||
| <| async { | ||
| let testDir = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ServerTests") | ||
| let (server: IFSharpLspServer), _events = createServer () | ||
|
|
||
| let p: InitializeParams = | ||
| { ProcessId = Some 1 | ||
| RootPath = None | ||
| Locale = None | ||
| RootUri = Some(sprintf "file://%s" testDir) | ||
| InitializationOptions = Some(Server.serialize defaultConfigDto) | ||
| Capabilities = clientCaps | ||
| ClientInfo = Some { Name = "Test"; Version = Some "1.0" } | ||
| WorkspaceFolders = None | ||
| Trace = None | ||
| WorkDoneToken = None } | ||
|
|
||
| match! server.Initialize p with | ||
| | Ok _ -> () | ||
| | Error e -> failtest $"Initialize failed: {e}" | ||
| } | ||
|
|
||
| testCaseAsync "Backward compatibility - uses RootPath when both RootUri and WorkspaceFolders are None" | ||
| <| async { | ||
| let testDir = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ServerTests") | ||
| let (server: IFSharpLspServer), _events = createServer () | ||
|
|
||
| let p: InitializeParams = | ||
| { ProcessId = Some 1 | ||
| RootPath = Some testDir | ||
| Locale = None | ||
| RootUri = None | ||
| InitializationOptions = Some(Server.serialize defaultConfigDto) | ||
| Capabilities = clientCaps | ||
| ClientInfo = Some { Name = "Test"; Version = Some "1.0" } | ||
| WorkspaceFolders = None | ||
| Trace = None | ||
| WorkDoneToken = None } | ||
|
|
||
| match! server.Initialize p with | ||
| | Ok _ -> () | ||
| | Error e -> failtest $"Initialize failed: {e}" | ||
| } | ||
|
|
||
| testCaseAsync "Empty WorkspaceFolders array falls back to RootUri" | ||
| <| async { | ||
| let testDir = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "ServerTests") | ||
| let (server: IFSharpLspServer), _events = createServer () | ||
|
|
||
| let p: InitializeParams = | ||
| { ProcessId = Some 1 | ||
| RootPath = None | ||
| Locale = None | ||
| RootUri = Some(sprintf "file://%s" testDir) | ||
| InitializationOptions = Some(Server.serialize defaultConfigDto) | ||
| Capabilities = clientCaps | ||
| ClientInfo = Some { Name = "Test"; Version = Some "1.0" } | ||
| WorkspaceFolders = Some [||] | ||
| Trace = None | ||
| WorkDoneToken = None } | ||
|
|
||
| match! server.Initialize p with | ||
| | Ok _ -> () | ||
| | Error e -> failtest $"Initialize failed: {e}" | ||
| } ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to convert the array into a list? (It looks like all it does is search the collection, which could use Array.tryFind rather than list.tryFind?)