Skip to content

Commit

Permalink
Force complete completion results in Completion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Mar 8, 2022
1 parent 07ebf47 commit 43ca318
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<MicrosoftTestPackageVersion>17.0.0</MicrosoftTestPackageVersion>
<MSBuildPackageVersion>17.0.0</MSBuildPackageVersion>
<NuGetPackageVersion>6.0.0</NuGetPackageVersion>
<RoslynPackageVersion>4.2.0-2.22124.7</RoslynPackageVersion>
<RoslynPackageVersion>4.2.0-3.22157.8</RoslynPackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public CompletionService(OmniSharpWorkspace workspace, FormattingOptions formatt
_omniSharpOptions = omniSharpOptions;
}

public async Task<CompletionResponse> Handle(CompletionRequest request)
public Task<CompletionResponse> Handle(CompletionRequest request)
{
return Handle(request, forceExpandedCompletionIndexCreation: false);
}

public async Task<CompletionResponse> Handle(CompletionRequest request, bool forceExpandedCompletionIndexCreation)
{
_logger.LogTrace("Completions requested");

Expand All @@ -76,7 +81,9 @@ public async Task<CompletionResponse> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public async Task<IEnumerable<AutoCompleteResponse>> 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)
Expand Down
3 changes: 2 additions & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/CompletionFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,8 @@ protected async Task<CompletionResponse> 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<CompletionResponse> FindCompletionsWithImportedAsync(string filename, string source, OmniSharpTestHost host)
Expand Down

0 comments on commit 43ca318

Please sign in to comment.