-
Notifications
You must be signed in to change notification settings - Fork 196
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
Conversation
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returned null
from https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/CompletionHandler.cs#L63
No longer getting completions.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised. Our projection provider shouldn't be invoking anything in our Razor language server: https://github.com/dotnet/aspnetcore-tooling/blob/b0e378c1626ea7c43d29cc4cbe32ccf3f0d50bcd/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DefaultLSPProjectionProvider.cs#L70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, we have two onkeypress
s.
- HTML
onkeypress
- 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue to track this: https://github.com/dotnet/aspnetcore/issues/21346
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. |
|
Ya I just checked out the branch and see it too: @ToddGrun is it expected for the HTML language server to return attribute completions after a |
c31d128
to
bc89c59
Compare
@@ -153,7 +155,8 @@ public override IReadOnlyList<RazorCompletionItem> GetCompletionItems(RazorSynta | |||
var razorCompletionItem = new RazorCompletionItem( | |||
completion.Key, | |||
insertText, | |||
RazorCompletionItemKind.DirectiveAttribute); | |||
RazorCompletionItemKind.DirectiveAttribute, | |||
ElementCommitCharacters); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
=
toElementCommitCharacters
, however the completion would be of the formbind=|
(notbind="|"
). - Likewise, I can add
[space]
toElementCommitCharacters
, but the completion isbind |
(notbind="|"
).
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @attributes=|
is missing the quotes (@attributes="|"
) because we don't have snippet support enabled:
https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/DefaultTagHelperCompletionService.cs#L225
...odeAnalysis.Razor.Workspaces.Test/Completion/DirectiveAttributeCompletionItemProviderTest.cs
Outdated
Show resolved
Hide resolved
Added support for taghelper attributes. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure, but it would explain why we were doing this: https://github.com/dotnet/aspnetcore-tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/DefaultTagHelperCompletionService.cs#L231
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
...rc/Microsoft.AspNetCore.Razor.LanguageServer/Completion/DefaultTagHelperCompletionService.cs
Outdated
Show resolved
Hide resolved
...rc/Microsoft.AspNetCore.Razor.LanguageServer/Completion/DefaultTagHelperCompletionService.cs
Outdated
Show resolved
Hide resolved
...crosoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
Outdated
Show resolved
Hide resolved
...crosoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
Outdated
Show resolved
Hide resolved
...crosoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
Outdated
Show resolved
Hide resolved
...crosoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
Outdated
Show resolved
Hide resolved
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
7787b89
to
47180e0
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
@@ -150,11 +150,14 @@ public override IReadOnlyList<RazorCompletionItem> GetCompletionItems(RazorSynta | |||
insertText = insertText.Substring(1); | |||
} | |||
|
|||
(var attributeDescriptionInfos, var commitCharacters) = completion.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(var attributeDescriptionInfos, var commitCharacters) = completion.Value; | |
var (attributeDescriptionInfos, commitCharacters) = completion.Value; |
works just as well
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To allow for System.Boolean?
nullable bool https://github.com/dotnet/aspnetcore/blob/master/src/Mvc/Mvc.TagHelpers/src/FormTagHelper.cs#L96
Before
After
Thanks @ajaybhargavb
Fixes: https://github.com/dotnet/aspnetcore/issues/21066
Fixes: https://github.com/dotnet/aspnetcore/issues/21485