From 43ca31876ec9266f83854b29d4a14245f0e5f3bc Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Mon, 7 Mar 2022 18:46:21 -0800 Subject: [PATCH] Force complete completion results in Completion tests --- build/Packages.props | 2 +- .../Services/Completion/CompletionService.cs | 11 +++++++++-- .../Services/Intellisense/IntellisenseService.cs | 4 +++- .../OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/build/Packages.props b/build/Packages.props index 1329e39342..0b65ea624a 100644 --- a/build/Packages.props +++ b/build/Packages.props @@ -7,7 +7,7 @@ 17.0.0 17.0.0 6.0.0 - 4.2.0-2.22124.7 + 4.2.0-3.22157.8 2.4.1 diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs index 1c449f4556..fab7d0fb5a 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Completion/CompletionService.cs @@ -52,7 +52,12 @@ public CompletionService(OmniSharpWorkspace workspace, FormattingOptions formatt _omniSharpOptions = omniSharpOptions; } - public async Task Handle(CompletionRequest request) + public Task Handle(CompletionRequest request) + { + return Handle(request, forceExpandedCompletionIndexCreation: false); + } + + public async Task Handle(CompletionRequest request, bool forceExpandedCompletionIndexCreation) { _logger.LogTrace("Completions requested"); @@ -76,7 +81,9 @@ public async Task Handle(CompletionRequest request) _ => CompletionTrigger.Invoke, }; - var options = new OmniSharpCompletionOptions(ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion); + var options = new OmniSharpCompletionOptions( + ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion, + ForceExpandedCompletionIndexCreation: forceExpandedCompletionIndexCreation); if (request.CompletionTrigger == CompletionTriggerKind.TriggerCharacter && !await OmniSharpCompletionService.ShouldTriggerCompletionAsync(completionService, document, position, trigger, roles: null, options, CancellationToken.None)) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Intellisense/IntellisenseService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Intellisense/IntellisenseService.cs index 29141125a4..14cfc80e01 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Intellisense/IntellisenseService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Intellisense/IntellisenseService.cs @@ -48,7 +48,9 @@ public async Task> Handle(AutoCompleteRequest var sourceText = await document.GetTextAsync(); var position = sourceText.GetTextPosition(request); var service = CompletionService.GetService(document); - var options = new OmniSharpCompletionOptions(ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion); + var options = new OmniSharpCompletionOptions( + ShowItemsFromUnimportedNamespaces: _omniSharpOptions.RoslynExtensionsOptions.EnableImportCompletion, + ForceExpandedCompletionIndexCreation: false); var completionList = await OmniSharpCompletionService.GetCompletionsAsync(service, document, position, trigger: default, roles: null, options, CancellationToken.None); if (completionList != null) diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs index b54d71d03a..4fd50d16cc 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs @@ -2278,7 +2278,8 @@ protected async Task FindCompletionsAsync(string filename, s var requestHandler = GetCompletionService(testHost); - return await requestHandler.Handle(request); + // Force the completion handler to return a complete set of results. + return await requestHandler.Handle(request, forceExpandedCompletionIndexCreation: true); } private async Task FindCompletionsWithImportedAsync(string filename, string source, OmniSharpTestHost host)