Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Colon as a Commit Character #1825

Merged
merged 6 commits into from
May 5, 2020
Merged

Conversation

TanayParikh
Copy link
Contributor

@TanayParikh TanayParikh commented Apr 23, 2020

@NTaylorMullen
Copy link
Contributor

We may also want to add : as a trigger character as well so you're immediately prompted with a new completion session when you type :

@@ -18,7 +18,7 @@ internal class InitializeHandler : IRequestHandler<InitializeParams, InitializeR
{
CompletionProvider = new CompletionOptions()
{
AllCommitCharacters = new[] { " ", ".", ";", ">", "=" }, // This is necessary to workaround a bug where the commit character in CompletionItem is not respected.
AllCommitCharacters = new[] { " ", ".", ";", ">", "=", ":" }, // This is necessary to workaround a bug where the commit character in CompletionItem is not respected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajaybhargavb why does this impact our Razor language server completion endpoint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great question. When I suggested this, I didn't realize this was in our endpoint. Now that I think about it, it shouldn't have affected this. Very interesting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is actually impacting our Razor language endpoint this is a pretty awful multi-language server bug and will bite us harddd once we start including more features.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that our HtmlCSharp server is calling the Razor server manually and that is why this is respected? @TanayParikh, to test this, you can just return null in CompletionHandler and see if you still get the same behavior for directive attributes. Ideally, that should still work because CompletionHandler only takes care of HTML and CSharp completion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer getting completions.

That's a problem. We should still be getting Tag helper completions from RazorCompletionEndpoint. This could explain why adding a : here impacted that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, we have two onkeypresss.

  1. HTML onkeypress
  2. Razor Directive Attribute @onkeypress

For either to complete with a : commit char, we need to add the commit char here. Adding it to the RazorLanguageServer: https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionEndpoint.cs#L155-L160 does not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajaybhargavb
Copy link
Contributor

We may also want to add : as a trigger character as well so you're immediately prompted with a new completion session when you type :

It already is https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionEndpoint.cs#L159. Don't know why it doesn't prompt again.

@TanayParikh
Copy link
Contributor Author

We may also want to add : as a trigger character as well so you're immediately prompted with a new completion session when you type :

It already is https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionEndpoint.cs#L159. Don't know why it doesn't prompt again.

It does, it's just slow. Will repro.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Apr 23, 2020

We may also want to add : as a trigger character as well so you're immediately prompted with a new completion session when you type :

It already is https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionEndpoint.cs#L159. Don't know why it doesn't prompt again.

It does, it's just slow. Will repro.

Trigger

@NTaylorMullen / @ajaybhargavb

@NTaylorMullen
Copy link
Contributor

Ya I just checked out the branch and see it too:
eu2ND7oQ22

@ToddGrun is it expected for the HTML language server to return attribute completions after a :? Also, we currently have a TriggerCharacter for : in our HTML Language Server list of trigger characters. Is that needed?

@TanayParikh TanayParikh force-pushed the taparik/add_colon_commit_char branch from c31d128 to bc89c59 Compare April 29, 2020 22:45
@TanayParikh
Copy link
Contributor Author

OnKeyPress

Updated to support completion of directive attributes with : completion character.

@@ -153,7 +155,8 @@ public override IReadOnlyList<RazorCompletionItem> GetCompletionItems(RazorSynta
var razorCompletionItem = new RazorCompletionItem(
completion.Key,
insertText,
RazorCompletionItemKind.DirectiveAttribute);
RazorCompletionItemKind.DirectiveAttribute,
ElementCommitCharacters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify if we're still respecting pressing space or = to complete? If in doubt, check what happens in the old editor (with the LSP preview feature off). We'll need to be consistent with that experience.

Copy link
Contributor Author

@TanayParikh TanayParikh Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still respecting pressing space or = to complete?

No we aren't.

  • I can add = to ElementCommitCharacters, however the completion would be of the form bind=| (not bind="|").
  • Likewise, I can add [space] to ElementCommitCharacters, but the completion is bind | (not bind="|").

Would that be something on our end or WTE?

If in doubt, check what happens in the old editor (with the LSP preview feature off). We'll need to be consistent with that experience.

For whatever reason, I'm not getting any directive attribute completion in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke offline. We are going to try and be smart about when to add and = as commit characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to contextually support and : commit chars. = is always available.

MoreCommitChars

Copy link
Contributor Author

@TanayParikh TanayParikh May 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TanayParikh
Copy link
Contributor Author

Added support for taghelper attributes. = is always supported as a commit character & Boolean attributes will be completed with .

Copy link
Contributor

@NTaylorMullen NTaylorMullen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly had a few questions.

In the future i'd ask that we add additional features outside of the original issue in separate PRs to ensure the PRs can be easily evaluated. I typically will do everything together and then manually split the code changes to ensure things work together 😄

{
var commitCharacters = new HashSet<string>() { "=" };

// IsBooleanProperty isn't set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder if it's a deserialization issue where when we deserialize the TagHelpers they don't get that property set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a investigation issue for this: https://github.com/dotnet/aspnetcore/issues/21486

@TanayParikh
Copy link
Contributor Author

Merge fail 😆. Please ignore the notifications, fixing up.

PR Changes

Added Colon as a Commit Character

Added support for ` ` and `:`

Commit support for taghelper attributes
@TanayParikh TanayParikh force-pushed the taparik/add_colon_commit_char branch from 7787b89 to 47180e0 Compare May 5, 2020 00:02
@TanayParikh
Copy link
Contributor Author

TanayParikh commented May 5, 2020

In the future i'd ask that we add additional features outside of the original issue in separate PRs to ensure the PRs can be easily evaluated. I typically will do everything together and then manually split the code changes to ensure things work together 😄
~ @NTaylorMullen

Will keep that in mind next time, thanks! I created a separate issue to document support for contextual commit chars: https://github.com/dotnet/aspnetcore/issues/21485

}
else if (boundAttributes.Any(b => b.TypeName.StartsWith("System.Boolean")))
{
// Have to use string type because IsBooleanProperty isn't set
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@ajaybhargavb ajaybhargavb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@TanayParikh TanayParikh merged commit cc6e355 into master May 5, 2020
@TanayParikh TanayParikh deleted the taparik/add_colon_commit_char branch May 5, 2020 16:55
@@ -150,11 +150,14 @@ public override IReadOnlyList<RazorCompletionItem> GetCompletionItems(RazorSynta
insertText = insertText.Substring(1);
}

(var attributeDescriptionInfos, var commitCharacters) = completion.Value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(var attributeDescriptionInfos, var commitCharacters) = completion.Value;
var (attributeDescriptionInfos, commitCharacters) = completion.Value;

works just as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, noted 😄. Will fix this up in my next PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pranavpoints

{
return NoCommitCharacters;
}
else if (boundAttributes.Any(b => b.TypeName.StartsWith("System.Boolean")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is a StartsWith rather than an exact comparison?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants