Skip to content

[LSP] Explicitly define the completion items to resolve#60393

Merged
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:lsp_completion_edits
Mar 26, 2022
Merged

[LSP] Explicitly define the completion items to resolve#60393
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:lsp_completion_edits

Conversation

@dibarbet
Copy link
Copy Markdown
Member

Response to https://devdiv.visualstudio.com/DevDiv/_git/VSLanguageServerClient/pullrequest/385546

Instead of relying on the implicit contract of no insert text + text edit (which is not necessarily applicable with item defaults), we specify a property to VS which tells them to resolve on commit.

@dibarbet dibarbet added Area-IDE LSP issues related to the roslyn language server protocol implementation labels Mar 25, 2022
@dibarbet dibarbet requested review from a team as code owners March 25, 2022 20:14
LSP.Range? defaultRange,
CancellationToken cancellationToken)
{
if (supportsVSExtensions)
Copy link
Copy Markdown
Member Author

@dibarbet dibarbet Mar 25, 2022

Choose a reason for hiding this comment

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

this method was kind of useless, so I just merged it with the local CreateCompletionItemAsync and do the check there

@dibarbet dibarbet enabled auto-merge (squash) March 25, 2022 21:06
@dibarbet dibarbet merged commit 696fe63 into dotnet:main Mar 26, 2022
@ghost ghost added this to the Next milestone Mar 26, 2022
Preselect = ShouldItemBePreselected(item),
};
var completionItem = supportsVSExtensions ? new LSP.VSInternalCompletionItem() : new LSP.CompletionItem();
completionItem.Label = completeDisplayText;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wish there was a C# construct to do this as one (for non-structs, operating on the same object).

// Complex text edits (e.g. override and partial method completions) are always populated in the
// resolve handler, so we leave both TextEdit and InsertText unpopulated in these cases.
if (item.IsComplexTextEdit)
if (item.IsComplexTextEdit && completionItem is LSP.VSInternalCompletionItem vsItem)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are ComplexTextEdit's only supported in VS? I would have thought LSP.VSInternalCompletionItem should be it's own check but perhaps I don't understand the scenario.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

complex text edits exist outside of VS, but the capability to resolve on commit is VS only. So it doesn't make sense to do this block outside of VS

@dibarbet dibarbet deleted the lsp_completion_edits branch March 28, 2022 22:09
@allisonchou allisonchou modified the milestones: Next, 17.2.P3 Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE LSP issues related to the roslyn language server protocol implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants