提交 2892bc6c 编写于 作者: I Ivan Basov

Code review feedback

上级 d4aef3f6
......@@ -269,6 +269,7 @@ private static bool IsAfterDot(ITextSnapshot snapshot, ITrackingSpan applicableT
// Ask the language to determine which of the *matched* items it wants to select.
var matchingItems = itemsInList.Where(r => r.FilterResult.MatchedFilterText)
.Select(t => t.FilterResult.CompletionItem)
.Where(r => !r.DisplayText.StartsWith("★"))
.AsImmutable();
var chosenItems = filterMethod(matchingItems, filterText);
......@@ -291,8 +292,7 @@ private static bool IsAfterDot(ITextSnapshot snapshot, ITrackingSpan applicableT
{
selectedItemIndex = itemsInList.IndexOf(i => Equals(i.FilterResult.CompletionItem, bestItem));
if (selectedItemIndex > -1 &&
bestItem != null &&
matchingItems.Where(r => !r.DisplayText.StartsWith("★")).Count() == 1 &&
matchingItems.Length == 1 &&
filterText.Length > 0)
{
uniqueItem = highlightedList[selectedItemIndex].CompletionItem;
......
......@@ -4851,6 +4851,55 @@ class C
End Using
End Function
' Implementation for the Modern completion only
<InlineData(CompletionImplementation.Modern)>
<WpfTheory, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestSendCommitIfUniqueWithIntelliCodeAndDuplicateItemsFromIntelliCode(completionImplementation As CompletionImplementation) As Task
Dim provider = New IntelliCodeMockWeirdProvider()
Using state = TestStateFactory.CreateCSharpTestState(completionImplementation,
<Document>
class C
{
void Method()
{
var s = "";
s.Len$$
}
}
</Document>, {provider})
state.SendCommitUniqueCompletionListItem()
Await state.AssertNoCompletionSession()
Assert.Contains("s.Length", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function
' Implementation for the Modern completion only
<InlineData(CompletionImplementation.Modern)>
<WpfTheory, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestSendCommitIfUniqueInInsertionSessionWithIntelliCodeAndDuplicateItemsFromIntelliCode(completionImplementation As CompletionImplementation) As Task
Dim provider = New IntelliCodeMockWeirdProvider()
Using state = TestStateFactory.CreateCSharpTestState(completionImplementation,
<Document>
class C
{
void Method()
{
var s = "";
s$$
}
}
</Document>, {provider})
state.SendTypeChars(".len")
Await state.AssertCompletionSession()
state.AssertCompletionItemsContainAll({"Length", "★ Length3", "★ Length2"})
state.SendCommitUniqueCompletionListItem()
Await state.AssertNoCompletionSession()
Assert.Contains("s.Length", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function
Private Class MultipleChangeCompletionProvider
Inherits CompletionProvider
......@@ -4903,5 +4952,23 @@ class C
Return True
End Function
End Class
' Simulates a situation where IntelliCode provides items not included into the Rolsyn original list.
' We want to ignore these items in CommitIfUnique.
' This situation should not happen. Tests with this provider were added to cover protective scenarios.
Private Class IntelliCodeMockWeirdProvider
Inherits CompletionProvider
Public Overrides Function ProvideCompletionsAsync(context As CompletionContext) As Task
context.AddItem(CompletionItem.Create(displayText:="★ Length2", filterText:="Length2"))
context.AddItem(CompletionItem.Create(displayText:="Length", filterText:="Length"))
context.AddItem(CompletionItem.Create(displayText:="★ Length3", filterText:="Length3"))
Return Task.CompletedTask
End Function
Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean
Return True
End Function
End Class
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册