未验证 提交 e3e892c9 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #47785 from CyrusNajmabadi/negativeCategory

Supply completions for negative regex categories as well.
......@@ -271,6 +271,30 @@ class c
End Using
End Function
<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestNegativeCategory(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
using System.Text.RegularExpressions;
class c
{
void goo()
{
var r = new Regex(@"\P$$");
}
}
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)
state.SendTypeChars("{")
Await state.AssertCompletionSession()
Assert.True(state.GetCompletionItems().Any(Function(i) i.DisplayText = "IsGreek"))
state.SendTab()
Await state.AssertNoCompletionSession()
End Using
End Function
<WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function NotInInterpolatedString(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
......
......@@ -258,21 +258,14 @@ private static void ProvideTopLevelCompletions(EmbeddedCompletionContext context
// we're providing the set of unicode categories that are legal there.
var index = tree.Text.IndexOf(previousVirtualChar);
if (index >= 2 &&
tree.Text[index - 2] == '\\' &&
tree.Text[index - 1] == 'p')
if (index >= 2 && tree.Text[index - 2] == '\\')
{
var slashChar = tree.Text[index - 1];
var result = FindToken(tree.Root, slashChar);
if (result == null)
var escapeChar = tree.Text[index - 1];
if (escapeChar == 'p' || escapeChar == 'P')
{
return;
}
var (parent, _) = result.Value;
if (parent is RegexEscapeNode)
{
ProvideEscapeCategoryCompletions(context);
var token = FindToken(tree.Root, escapeChar);
if (token?.parent is RegexEscapeNode)
ProvideEscapeCategoryCompletions(context);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册