Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ internal partial class RazorCustomMessageTarget
};
}

_snippetCompletionItemProvider.AddSnippetCompletions(request.ProjectedKind, request.Context.InvokeKind, request.Context.TriggerCharacter, ref builder.AsRef());
if (request.ShouldIncludeSnippets)
{
_snippetCompletionItemProvider.AddSnippetCompletions(request.ProjectedKind, request.Context.InvokeKind, request.Context.TriggerCharacter, ref builder.AsRef());
}

completionList.Items = builder.ToArray();

completionList.Data = JsonHelpers.TryConvertFromJObject(completionList.Data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,29 @@ The end.
snippetLabels: ["snippet1", "snippet2"]);
}

[Fact]
public async Task HtmlSnippetsCompletion_NotInStartTag()
{
await VerifyCompletionListAsync(
input: """
This is a Razor document.

<div $$></div>

The end.
""",
completionContext: new RoslynVSInternalCompletionContext()
{
InvokeKind = RoslynVSInternalCompletionInvokeKind.Typing,
TriggerCharacter = " ",
TriggerKind = RoslynCompletionTriggerKind.TriggerCharacter
},
expectedItemLabels: ["style", "dir"],
unexpectedItemLabels: ["snippet1", "snippet2"],
delegatedItemLabels: ["style", "dir"],
snippetLabels: ["snippet1", "snippet2"]);
}

// Tests HTML attributes and DirectiveAttributeTransitionCompletionItemProvider
[Fact]
public async Task HtmlAndDirectiveAttributeTransitionNamesCompletion()
Expand Down Expand Up @@ -402,6 +425,7 @@ private async Task VerifyCompletionListAsync(
TestCode input,
RoslynVSInternalCompletionContext completionContext,
string[] expectedItemLabels,
string[]? unexpectedItemLabels = null,
string[]? delegatedItemLabels = null,
string[]? delegatedItemCommitCharacters = null,
string[]? snippetLabels = null,
Expand Down Expand Up @@ -469,6 +493,14 @@ private async Task VerifyCompletionListAsync(
Assert.Contains(expectedItemLabel, labelSet);
}

if (unexpectedItemLabels is not null)
{
foreach (var unexpectedItemLabel in unexpectedItemLabels)
{
Assert.DoesNotContain(unexpectedItemLabel, labelSet);
}
}

if (!commitElementsWithSpace)
{
Assert.False(result.Items.Any(item => item.CommitCharacters?.First().Contains(" ") ?? false));
Expand Down