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

Supply completions for negative regex categories as well.

上级 66b8559c
......@@ -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(
......
......@@ -259,20 +259,17 @@ private static void ProvideTopLevelCompletions(EmbeddedCompletionContext context
var index = tree.Text.IndexOf(previousVirtualChar);
if (index >= 2 &&
tree.Text[index - 2] == '\\' &&
tree.Text[index - 1] == 'p')
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 result = FindToken(tree.Root, escapeChar);
if (result == null)
return;
var (parent, _) = result.Value;
if (parent is RegexEscapeNode)
{
ProvideEscapeCategoryCompletions(context);
if (result.Value.parent is RegexEscapeNode)
ProvideEscapeCategoryCompletions(context);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册