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

Emulate suggestion mode in LSP completion by always soft-select #69327

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

genlu
Copy link
Member

@genlu genlu commented Aug 2, 2023

@genlu genlu requested a review from a team as a code owner August 2, 2023 05:55
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 2, 2023
return lspItem;
}

// VSCode does not have the concept of soft selection, the list is always hard selected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this. It's not just VSCode that doesn't have soft selection, VS doesn't have it either in the LSP client. Should the above block (checking lspVSClientCapability) even be present? Certainly we have this issue in VS in Razor, so is it just that nobody turns on LSP for C# files in VS, so this code is incorrect but we're just assuming it's correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS client has suggestion mode (VSInternalCompletionList.SuggestionMode), so I assumed it has similar behavior s in VS. Maybe I was wrong, will need to try it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS doesn't have it either in the LSP client.

Wat.

Copy link
Member Author

@genlu genlu Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the doc-comment for VS client's suggestion mode, which suggests there's soft-selection. But as David said, it might not work as we expected.

 //
 // Summary:
 //     Gets or sets a value indicating whether the completion list should use suggestion
 //     mode. In suggestion mode items are "soft-selected" by default.
 [DataMember(Name = "_vs_suggestionMode")]
 [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
 public bool SuggestionMode { get; set; }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah VS LSP client does have some support for soft selection with the SuggestionMode. I don't remember the extent of it, but it definitely exists.

Copy link
Contributor

@davidwengier davidwengier Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Sounds like we need to try that! Thanks

@333fred
Copy link
Member

333fred commented Aug 2, 2023

@genlu can you add a test case for typing " in an argument list? IE, Console.WriteLine($$), typing " should insert just the ", not the top of the completion list. A user was running into this today with editor.acceptSuggestionOnCommitCharacter set to true, and I think this PR will fix that.

@genlu
Copy link
Member Author

genlu commented Aug 2, 2023

@333fred that should be fixed by this PR, and we have a test here. But I will try again to be sure

@genlu genlu merged commit d58b58b into dotnet:main Aug 2, 2023
24 checks passed
@ghost ghost added this to the Next milestone Aug 2, 2023
@genlu genlu deleted the lspSuggestionMode branch August 2, 2023 23:05
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beta: Over-eager autocompletion in anonymous functions
6 participants