提交 7c28543d 编写于 作者: C Cyrus Najmabadi

Supply completions for negative regex categories as well.

上级 66b8559c
...@@ -271,6 +271,30 @@ class c ...@@ -271,6 +271,30 @@ class c
End Using End Using
End Function 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)> <WpfTheory, CombinatorialData, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function NotInInterpolatedString(showCompletionInArgumentLists As Boolean) As Task Public Async Function NotInInterpolatedString(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState( Using state = TestStateFactory.CreateCSharpTestState(
......
...@@ -259,19 +259,16 @@ private static void ProvideTopLevelCompletions(EmbeddedCompletionContext context ...@@ -259,19 +259,16 @@ private static void ProvideTopLevelCompletions(EmbeddedCompletionContext context
var index = tree.Text.IndexOf(previousVirtualChar); var index = tree.Text.IndexOf(previousVirtualChar);
if (index >= 2 && if (index >= 2 &&
tree.Text[index - 2] == '\\' && tree.Text[index - 2] == '\\')
tree.Text[index - 1] == 'p')
{ {
var slashChar = tree.Text[index - 1]; var escapeChar = tree.Text[index - 1];
var result = FindToken(tree.Root, slashChar); if (escapeChar == 'p' || escapeChar == 'P')
if (result == null)
{ {
var result = FindToken(tree.Root, escapeChar);
if (result == null)
return; return;
}
var (parent, _) = result.Value; if (result.Value.parent is RegexEscapeNode)
if (parent is RegexEscapeNode)
{
ProvideEscapeCategoryCompletions(context); ProvideEscapeCategoryCompletions(context);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册