提交 00a1134a 编写于 作者: D David Barbet

Remove snippets from completion list until they are supported

上级 7ddc52b1
......@@ -43,6 +43,8 @@ public CompletionHandler(ILspSolutionProvider solutionProvider) : base(solutionP
var position = await document.GetPositionFromLinePositionAsync(ProtocolConversions.PositionToLinePosition(request.Position), cancellationToken).ConfigureAwait(false);
// Filter out snippets as they are not supported in the LSP client
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1139740
// Filter out unimported types for now as there are two issues with providing them:
// 1. LSP client does not currently provide a way to provide detail text on the completion item to show the namespace.
// https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1076759
......@@ -51,6 +53,7 @@ public CompletionHandler(ILspSolutionProvider solutionProvider) : base(solutionP
// 3. LSP client should support completion filters / expanders
var documentOptions = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var completionOptions = documentOptions
.WithChangedOption(CompletionOptions.SnippetsBehavior, SnippetsRule.NeverInclude)
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, false)
.WithChangedOption(CompletionServiceOptions.IsExpandedCompletion, false);
......
......@@ -60,6 +60,27 @@ void M()
Assert.False(results.Any(item => "Console" == item.Label));
}
[Fact]
public async Task TestGetCompletionsDoesNotIncludeSnippetsAsync()
{
var markup =
@"class A
{
{|caret:|}
}";
using var workspace = CreateTestWorkspace(markup, out var locations);
var solution = workspace.CurrentSolution;
solution = solution.WithOptions(solution.Options
.WithChangedOption(CompletionOptions.SnippetsBehavior, LanguageNames.CSharp, SnippetsRule.AlwaysInclude));
var expected = CreateCompletionItem("A", LSP.CompletionItemKind.Class, new string[] { "Class", "Internal" }, CreateCompletionParams(locations["caret"].Single()));
var clientCapabilities = new LSP.VSClientCapabilities { SupportsVisualStudioExtensions = true };
var results = await RunGetCompletionsAsync(solution, locations["caret"].Single(), clientCapabilities);
Assert.False(results.Any(item => "ctor" == item.Label));
}
private static async Task<LSP.CompletionItem[]> RunGetCompletionsAsync(Solution solution, LSP.Location caret, LSP.ClientCapabilities clientCapabilities = null)
=> await GetLanguageServer(solution).ExecuteRequestAsync<LSP.CompletionParams, LSP.CompletionItem[]>(LSP.Methods.TextDocumentCompletionName,
CreateCompletionParams(caret), clientCapabilities, null, CancellationToken.None);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册