Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
Expand Down Expand Up @@ -317,6 +318,14 @@ public static async Task<VSInternalCompletionItem> FormatCSharpCompletionItemAsy
// rather than the one LSP knows about.
if (resolvedCompletionItem.Command is { CommandIdentifier: Constants.CompleteComplexEditCommand, Arguments: var args })
{
// In LSP case, command parameters will be JsonElement objects and will need to be deserialized first
if (args is [JsonElement textDocumentIdentifierData, JsonElement complexEditData, _, _])
{
args[0] = textDocumentIdentifierData.Deserialize<TextDocumentIdentifier>() ?? args[0];
args[1] = complexEditData.Deserialize<TextEdit>() ?? args[1];
}

// In cohosting case, command parameters will be of the correct types (or deserialized by now in LSP case)
if (args is [TextDocumentIdentifier, TextEdit complexEdit, _, int nextCursorPosition])
{
var formattedTextEdit = await FormatTextEditsAsync([complexEdit], documentContext, options, formattingService, cancellationToken).ConfigureAwait(false);
Expand Down