roslyn: Code completion on override method doesn't apply correctly

Version Used: 4.13.0-2.24558.12

Steps to Reproduce:

  1. Use the override keyword in a class
  2. Select one of the suggested method
  3. Apply the completion

Expected Behavior: The completion should apply with the appropriate selected method.

Actual Behavior: The suggested methods are correct, but the completion is not. Instead of the selected method, a single character appears, or paranthesis, or none at all. This happens in:

I expect that it was fixed client-side in vscode for normal C# as it somehow seems to work in that scenario.

Attached one more example:

https://github.com/user-attachments/assets/e6b1faab-1a0e-460a-a4b4-0c288bd6fce2

From what I see relevant in the logs, the sent workspace/executeCommand is correct, but the server responds with a few exceptions:

[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 14,            line = 3          },          start = {            character = 14,            line = 3          }        },        rangeLength = 0,        text = "p"      }, {        range = {          ["end"] = {            character = 15,            line = 3          },          start = {            character = 15,            line = 3          }        },        rangeLength = 0,        text = "e"      }, {        range = {          ["end"] = {            character = 16,            line = 3          },          start = {            character = 16,            line = 3          }        },        rangeLength = 0,        text = "a"      }, {        range = {          ["end"] = {            character = 17,            line = 3          },          start = {            character = 17,            line = 3          }        },        rangeLength = 0,        text = "k"      }, {        range = {          ["end"] = {            character = 18,            line = 3          },          start = {            character = 18,            line = 3          }        },        rangeLength = 0,        text = "("      }, {        range = {          ["end"] = {            character = 19,            line = 3          },          start = {            character = 19,            line = 3          }        },        rangeLength = 0,        text = ")"      }, {        range = {          ["end"] = {            character = 20,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 7,        text = ""      }, {        range = {          ["end"] = {            character = 13,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 0,        text = ""      } },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs",      version = 29    }  }}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 14,            line = 3          },          start = {            character = 14,            line = 3          }        },        rangeLength = 0,        text = "p"      }, {        range = {          ["end"] = {            character = 15,            line = 3          },          start = {            character = 15,            line = 3          }        },        rangeLength = 0,        text = "e"      }, {        range = {          ["end"] = {            character = 16,            line = 3          },          start = {            character = 16,            line = 3          }        },        rangeLength = 0,        text = "a"      }, {        range = {          ["end"] = {            character = 17,            line = 3          },          start = {            character = 17,            line = 3          }        },        rangeLength = 0,        text = "k"      }, {        range = {          ["end"] = {            character = 18,            line = 3          },          start = {            character = 18,            line = 3          }        },        rangeLength = 0,        text = "("      }, {        range = {          ["end"] = {            character = 19,            line = 3          },          start = {            character = 19,            line = 3          }        },        rangeLength = 0,        text = ")"      }, {        range = {          ["end"] = {            character = 20,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 7,        text = ""      }, {        range = {          ["end"] = {            character = 13,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 0,        text = ""      } },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs",      version = 29    }  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"workspace/executeCommand"	{  arguments = { {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }, {      newText = "\r\n    public override void Speak()\r\n    {\r\n        base.Speak();\r\n    }",      range = {        ["end"] = {          character = 13,          line = 3        },        start = {          character = 49,          line = 2        }      }    }, false, 130 },  command = "roslyn.client.completionComplexEdit",  title = "CompleteComplexEditCommand"}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 31,  jsonrpc = "2.0",  method = "workspace/executeCommand",  params = {    arguments = { {        uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"      }, {        newText = "\r\n    public override void Speak()\r\n    {\r\n        base.Speak();\r\n    }",        range = {          ["end"] = {            character = 13,            line = 3          },          start = {            character = 49,            line = 2          }        }      }, false, 130 },    command = "roslyn.client.completionComplexEdit",    title = "CompleteComplexEditCommand"  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/diagnostic"	{  range = {    ["end"] = {      character = 0,      line = 5    },    start = {      character = 0,      line = 1    }  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 32,  jsonrpc = "2.0",  method = "textDocument/diagnostic",  params = {    range = {      ["end"] = {        character = 0,        line = 5      },      start = {        character = 0,        line = 1      }    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/diagnostic"	{  range = {    ["end"] = {      character = 0,      line = 5    },    start = {      character = 0,      line = 1    }  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 33,  jsonrpc = "2.0",  method = "textDocument/diagnostic",  params = {    range = {      ["end"] = {        character = 0,        line = 5      },      start = {        character = 0,        line = 1      }    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = "[LanguageServerHost] System.InvalidOperationException: This cannot be done after listening has started.\r\n   at Microsoft.Verify.FailOperation(String message)\r\n   at StreamJsonRpc.JsonRpc.ThrowIfConfigurationLocked()\r\n   at StreamJsonRpc.JsonRpc.AddLocalRpcMethod(MethodInfo handler, Object target, JsonRpcMethodAttribute methodRpcSettings)\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.SetupRequestDispatcher(AbstractHandlerProvider handlerProvider) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 136\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.get_HandlerProvider() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 94\r\n   at Microsoft.CodeAnalysis.LanguageServer.BaseService.LazyService`1.GetInstance(ILspServices lspServices) in /_/src/LanguageServer/Protocol/LspServices/BaseService.cs:line 46\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService(String typeName) in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 143\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 97\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetRequiredService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 90\r\n   at Microsoft.CodeAnalysis.LanguageServer.Handler.ExecuteWorkspaceCommandHandler.HandleRequestAsync(ExecuteCommandParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs:line 32\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 191",    type = 1  }}
[TRACE][2024-11-28 19:49:56] ...m/lsp/client.lua:1001	"notification"	"window/logMessage"	{  message = "[LanguageServerHost] System.InvalidOperationException: This cannot be done after listening has started.\r\n   at Microsoft.Verify.FailOperation(String message)\r\n   at StreamJsonRpc.JsonRpc.ThrowIfConfigurationLocked()\r\n   at StreamJsonRpc.JsonRpc.AddLocalRpcMethod(MethodInfo handler, Object target, JsonRpcMethodAttribute methodRpcSettings)\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.SetupRequestDispatcher(AbstractHandlerProvider handlerProvider) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 136\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.get_HandlerProvider() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 94\r\n   at Microsoft.CodeAnalysis.LanguageServer.BaseService.LazyService`1.GetInstance(ILspServices lspServices) in /_/src/LanguageServer/Protocol/LspServices/BaseService.cs:line 46\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService(String typeName) in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 143\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 97\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetRequiredService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 90\r\n   at Microsoft.CodeAnalysis.LanguageServer.Handler.ExecuteWorkspaceCommandHandler.HandleRequestAsync(ExecuteCommandParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs:line 32\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 191",  type = 1}
[TRACE][2024-11-28 19:49:56] ...lsp/handlers.lua:711	"default_handler"	"window/logMessage"	{  ctx = '{\n  client_id = 1,\n  method = "window/logMessage"\n}',  result = {    message = "[LanguageServerHost] System.InvalidOperationException: This cannot be done after listening has started.\r\n   at Microsoft.Verify.FailOperation(String message)\r\n   at StreamJsonRpc.JsonRpc.ThrowIfConfigurationLocked()\r\n   at StreamJsonRpc.JsonRpc.AddLocalRpcMethod(MethodInfo handler, Object target, JsonRpcMethodAttribute methodRpcSettings)\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.SetupRequestDispatcher(AbstractHandlerProvider handlerProvider) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 136\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.get_HandlerProvider() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 94\r\n   at Microsoft.CodeAnalysis.LanguageServer.BaseService.LazyService`1.GetInstance(ILspServices lspServices) in /_/src/LanguageServer/Protocol/LspServices/BaseService.cs:line 46\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService(String typeName) in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 143\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 97\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetRequiredService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 90\r\n   at Microsoft.CodeAnalysis.LanguageServer.Handler.ExecuteWorkspaceCommandHandler.HandleRequestAsync(ExecuteCommandParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs:line 32\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 191",    type = 1  }}
[ERROR][2024-11-28 19:49:56] ...lsp/handlers.lua:623	"[LanguageServerHost] System.InvalidOperationException: This cannot be done after listening has started.\r\n   at Microsoft.Verify.FailOperation(String message)\r\n   at StreamJsonRpc.JsonRpc.ThrowIfConfigurationLocked()\r\n   at StreamJsonRpc.JsonRpc.AddLocalRpcMethod(MethodInfo handler, Object target, JsonRpcMethodAttribute methodRpcSettings)\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.SetupRequestDispatcher(AbstractHandlerProvider handlerProvider) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 136\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.get_HandlerProvider() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 94\r\n   at Microsoft.CodeAnalysis.LanguageServer.BaseService.LazyService`1.GetInstance(ILspServices lspServices) in /_/src/LanguageServer/Protocol/LspServices/BaseService.cs:line 46\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService(String typeName) in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 143\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 97\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetRequiredService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 90\r\n   at Microsoft.CodeAnalysis.LanguageServer.Handler.ExecuteWorkspaceCommandHandler.HandleRequestAsync(ExecuteCommandParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs:line 32\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 191"
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  error = {    code = -32000,    data = {      code = -2146233079,      message = "This cannot be done after listening has started.",      stack = "   at Microsoft.Verify.FailOperation(String message)\r\n   at StreamJsonRpc.JsonRpc.ThrowIfConfigurationLocked()\r\n   at StreamJsonRpc.JsonRpc.AddLocalRpcMethod(MethodInfo handler, Object target, JsonRpcMethodAttribute methodRpcSettings)\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.SetupRequestDispatcher(AbstractHandlerProvider handlerProvider) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 136\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.get_HandlerProvider() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 94\r\n   at Microsoft.CodeAnalysis.LanguageServer.BaseService.LazyService`1.GetInstance(ILspServices lspServices) in /_/src/LanguageServer/Protocol/LspServices/BaseService.cs:line 46\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService(String typeName) in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 143\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 97\r\n   at Microsoft.CodeAnalysis.LanguageServer.LspServices.GetRequiredService[T]() in /_/src/LanguageServer/Protocol/LspServices/LspServices.cs:line 90\r\n   at Microsoft.CodeAnalysis.LanguageServer.Handler.ExecuteWorkspaceCommandHandler.HandleRequestAsync(ExecuteCommandParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs:line 32\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 191\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.DelegatingEntryPoint.InvokeAsync(IRequestExecutionQueue`1 queue, Object requestObject, ILspServices lspServices, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 204\r\n   at Microsoft.CommonLanguageServerProtocol.Framework.SystemTextJsonLanguageServer`1.SystemTextJsonDelegatingEntryPoint.ExecuteRequestAsync(Nullable`1 request, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/SystemTextJsonLanguageServer.cs:line 88",      type = "System.InvalidOperationException"    },    message = "This cannot be done after listening has started."  },  id = 31,  jsonrpc = "2.0"}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 13,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 0,        text = "("      }, {        range = {          ["end"] = {            character = 14,            line = 3          },          start = {            character = 14,            line = 3          }        },        rangeLength = 0,        text = ")"      } },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs",      version = 31    }  }}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 13,            line = 3          },          start = {            character = 13,            line = 3          }        },        rangeLength = 0,        text = "("      }, {        range = {          ["end"] = {            character = 14,            line = 3          },          start = {            character = 14,            line = 3          }        },        rangeLength = 0,        text = ")"      } },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs",      version = 31    }  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/completion"	{  context = {    triggerCharacter = "(",    triggerKind = 2  },  position = {    character = 14,    line = 3  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 34,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerCharacter = "(",      triggerKind = 2    },    position = {      character = 14,      line = 3    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 14,    line = 3  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 35,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 14,      line = 3    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/diagnostic"	{  range = {    ["end"] = {      character = 0,      line = 5    },    start = {      character = 0,      line = 1    }  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 36,  jsonrpc = "2.0",  method = "textDocument/diagnostic",  params = {    range = {      ["end"] = {        character = 0,        line = 5      },      start = {        character = 0,        line = 1      }    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 34,  jsonrpc = "2.0"}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 35,  jsonrpc = "2.0"}
[DEBUG][2024-11-28 19:49:56] ...m/lsp/client.lua:676	"LSP[roslyn]"	"client.request"	1	"textDocument/signatureHelp"	{  position = {    character = 14,    line = 3  },  textDocument = {    uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"  }}	<function 1>	3
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 37,  jsonrpc = "2.0",  method = "textDocument/signatureHelp",  params = {    position = {      character = 14,      line = 3    },    textDocument = {      uri = "file:///C:/Users/bida/Desktop/testtraits/Dog.cs"    }  }}
[DEBUG][2024-11-28 19:49:56] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 37,  jsonrpc = "2.0"}

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

We will look into that. But why is that impacting neovim. If it did get a normal lsp competing completions result back, it should be fine. Unless it is explicitly the “completion item resolve” call back into Roslyn that is failing.

As mentioned previously, its not the completion request, nor the completion resolve request, but the execute command request that is failing and throwing the exception

Ok. We can look into that.

That would be awesome, and is also pretty much what I was about to ask before I read that part of your comment. However, seeing as this isn’t already implemented, is there more to this solution? (E.g. structure of the codebase making it difficult). Because I’d be willing to help

I haven’t dug into this bit of code for a bit, but it may be as simple as modifying this part of the code to check if the client supports modifying the textEdit field and updating the field instead of creating a command - https://github.com/dotnet/roslyn/blob/main/src/LanguageServer/Protocol/Handler/Completion/CompletionResultFactory.cs#L611

Note that of course whatever client is being used has to allow textEdit resolution on resolve and advertise the capability.

If that’s mainly all we need I think we’d be willing to accept that contribution.

As noted above, the cost of computing the full edits upfront is expensive - too expensive to provide upfront for all completion items in the list. Adding on to the problem, VSCode does not support lazily resolving the main textEdit field via completionItem/resolve - so we cannot provide the textEdit lazily via resolve either.

Instead, we fill in the command field during completionItem/resolve with the appropriate text edit to make. This is the roslyn.client.completionComplexEdit command. Because we already know the edit we need to make (returned in the command args), this does not need to go back to the server to execute the command. Instead, the command’s edit is applied client side. You can see this implementation here - https://github.com/dotnet/vscode-csharp/blob/3afe7b55d26bd7dadf957f1e6a37c7fe00654fb9/src/lsptoolshost/server/serverCommands.ts#L77

This of course has its own issues (for example fast typing can cancel the application of the override item). But this is what we came up with that worked within the limitations of VSCode.

I’m not 100% sure why this System.InvalidOperationException: This cannot be done after listening has started. is the exception being thrown, but executing the command on the server (as shown in the logs) will not work - the server has no implementation for it. It likely needs a client side implementation similar to what we do in VSCode.

I am open to making things easier here for other clients. For example, if a client indicated in the completion capabilities that resolveSupport.properties included the textEdit field - we could potentially have the server fill in the normal completionItem.textEdit field instead of using a custom command.