Skip to content

Commit

Permalink
Added Directive [SPACE] Commit Character (#2043)
Browse files Browse the repository at this point in the history
* Added Directive [SPACE] Commit Character

Fixes: https://github.com/dotnet/aspnetcore/issues/22886

* Refactor
  • Loading branch information
TanayParikh authored Jun 17, 2020
1 parent 7cf2075 commit 4cd6e88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ internal bool TryConvert(RazorCompletionItem razorCompletionItem, out Completion
SortText = razorCompletionItem.DisplayText,
Documentation = descriptionInfo.Description,
Kind = CompletionItemKind.Struct,
CommitCharacters = new Container<string>(razorCompletionItem.CommitCharacters),
};

if (razorCompletionItem == DirectiveAttributeTransitionCompletionItemProvider.TransitionCompletionItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace Microsoft.CodeAnalysis.Razor.Completion
[Export(typeof(RazorCompletionItemProvider))]
internal class DirectiveCompletionItemProvider : RazorCompletionItemProvider
{
private static readonly IReadOnlyCollection<string> DirectiveCommitCharacters = new string[] { " " };

private static readonly IEnumerable<DirectiveDescriptor> DefaultDirectives = new[]
{
CSharpCodeParser.AddTagHelperDirectiveDescriptor,
Expand Down Expand Up @@ -108,7 +110,8 @@ internal static List<RazorCompletionItem> GetDirectiveCompletionItems(RazorSynta
var completionItem = new RazorCompletionItem(
completionDisplayText,
directive.Directive,
RazorCompletionItemKind.Directive);
RazorCompletionItemKind.Directive,
DirectiveCommitCharacters);
var completionDescription = new DirectiveCompletionDescription(directive.Description);
completionItem.SetDirectiveCompletionDescription(completionDescription);
completionItems.Add(completionItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Moq;
using Xunit;

namespace Microsoft.CodeAnalysis.Razor.Completion
Expand Down Expand Up @@ -289,6 +288,7 @@ private static void AssertRazorCompletionItem(string completionDisplayText, Dire
Assert.Equal(item.InsertText, directive.Directive);
var completionDescription = item.GetDirectiveCompletionDescription();
Assert.Equal(directive.Description, completionDescription.Description);
Assert.Single(item.CommitCharacters, " ");
}

private static void AssertRazorCompletionItem(DirectiveDescriptor directive, RazorCompletionItem item) =>
Expand Down

0 comments on commit 4cd6e88

Please sign in to comment.