提交 5202dfc8 编写于 作者: R Ravi Chande

Always show snippets should not exclude non-snippet items

上级 97218fca
......@@ -2615,6 +2615,34 @@ End Class
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestSnippetsNotExclusiveWhenAlwaysShowing() As Task
Dim snippetProvider As CompletionProvider =
New VisualStudio.LanguageServices.VisualBasic.Snippets.
SnippetCompletionProvider(editorAdaptersFactoryService:=Nothing)
Using state = TestState.CreateVisualBasicTestState(
<Document><![CDATA[
Class C
Public Sub Foo()
Dim x as Integer = 3
Dim t = $$
End Sub
End Class
}]]></Document>,
extraCompletionProviders:={snippetProvider},
extraExportedTypes:={GetType(MockSnippetInfoService)}.ToList())
state.Workspace.Options = state.Workspace.Options.WithChangedOption(CompletionOptions.SnippetsBehavior,
LanguageNames.VisualBasic,
SnippetsRule.AlwaysInclude)
state.SendInvokeCompletionList()
await state.WaitForAsynchronousOperationsAsync()
Assert.True(state.CompletionItemsContainsAll({"x", "Shortcut"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function TestBuiltInTypesKeywordInTupleLiteral() As Task
Using state = TestState.CreateVisualBasicTestState(
......
......@@ -52,10 +52,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Snippets
Dim syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService)()
Dim isPossibleTupleContext = syntaxFacts.IsPossibleTupleContext(syntaxTree, position, cancellationToken)
context.IsExclusive = True
context.IsExclusive = ShouldBeExclusive(context.Options)
context.AddItems(CreateCompletionItems(snippets, isPossibleTupleContext))
End Function
Private Function ShouldBeExclusive(options As OptionSet) As Boolean
Return not options.GetOption(CompletionOptions.SnippetsBehavior, LanguageNames.VisualBasic) = SnippetsRule.AlwaysInclude
End Function
Private Shared ReadOnly s_commitChars As Char() = {" "c, ";"c, "("c, ")"c, "["c, "]"c, "{"c, "}"c, "."c, ","c, ":"c, "+"c, "-"c, "*"c, "/"c, "\"c, "^"c, "<"c, ">"c, "'"c, "="c}
Private Shared ReadOnly s_rules As CompletionItemRules = CompletionItemRules.Create(
commitCharacterRules:=ImmutableArray.Create(CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, s_commitChars)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册