提交 332998ee 编写于 作者: R Ravi Chande 提交者: GitHub

Merge pull request #18786 from rchande/fix18785

Check for prefix match before hard selecting when backspacing
......@@ -373,8 +373,15 @@ private bool IsAfterDot(Model model, ITextSnapshot textSnapshot, Dictionary<Text
if (bestFilterResult != null)
{
// Only hard select this result if it's a prefix match
// We need to do this so that
// * deleting and retyping a dot in a member access does not change the
// text that originally appeared before the dot
// * deleting through a word from the end keeps that word selected
// This also preserves the behavior the VB had through Dev12.
var hardSelect = bestFilterResult.Value.CompletionItem.FilterText.StartsWith(model.FilterText, StringComparison.CurrentCultureIgnoreCase);
return model.WithSelectedItem(bestFilterResult.Value.CompletionItem)
.WithHardSelection(true)
.WithHardSelection(hardSelect)
.WithIsUnique(matchCount == 1);
}
else
......
......@@ -2873,6 +2873,27 @@ End Class
End Using
End Function
<WorkItem(18785, "https://github.com/dotnet/roslyn/issues/18785")>
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function BackspaceSoftSelectionIfNotPrefixMatch() As Task
Using state = TestState.CreateVisualBasicTestState(
<Document><![CDATA[
Class C
Sub Do()
Dim x = new System.Collections.Generic.List(Of String)()
x.$$Add("stuff")
End Sub
End Class
]]></Document>)
state.SendBackspace()
Await state.AssertSelectedCompletionItem("x", isSoftSelected:=True)
state.SendTypeChars(".")
Await state.WaitForAsynchronousOperationsAsync()
Assert.Contains("x.Add", state.GetLineTextFromCaretPosition())
End Using
End Function
<ExportLanguageService(GetType(ISnippetInfoService), LanguageNames.VisualBasic), System.Composition.Shared>
Friend Class MockSnippetInfoService
Implements ISnippetInfoService
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册