Aspnetcore: Attribute Completions Capture Commit Character

Created on 22 May 2020  路  6Comments  路  Source: dotnet/aspnetcore

While validating https://github.com/dotnet/aspnetcore/issues/21062 & https://github.com/dotnet/aspnetcore/issues/21485:

Discovered some completion commit issues in VSCode

  • <button @attrib| press = -> <button @attributes="=|"
  • @onkey| press : -> @onkeydown=":|"
  • Taghelper attribute <form ap-anti press -> <form asp-antiforgery=" |"
  • Taghelper attribute <form ap-ar press = -> <form asp-area="=|"

Thanks @noahbkim :)

Done area-razor.tooling bug feature-razor.vscode

All 6 comments

CC @ajaybhargavb who has dealt with similar issues in the past.

Also seen on Mac.

Possibly related: <div @onkeyp| then hitting : will result in <div @onkeypress=":".

Verified not a WTE issue. Investigating within our completion endpoints.

This issue only appears on VSCode (not VS), and is likely rooted in our completion snippet handling.

Okay, if we want to get a fix in for the attributes, this is probably the best we can do for now:
commit_char_minimum_fix

The reason being, the ="|" snippet logic doesn't actually take commit characters into account. Note, this is still an improvement over our current released version as we still complete the attribute, rather than just applying the commit char to wherever we are (ex. @onkey press : yields @onkey: in production).

For reference, our current (shipped) implementation:
commit_char_current

As far as I can tell, there's nothing in the LSP spec which allows different CompletionItem.InsertText snippets for different commit characters. However, for the commit characters : and =, we need snippet texts of :| and ="|" respectively. Right now it's indiscriminately applying the ="|" to everything.

This is based on my current understanding and I'll confirm and update.

Confirmed with @NTaylorMullen this is a known limitation of the LSP spec. We're removing snippet support for taghelper and directive attributes for now.

Being Tracked Here: https://github.com/dotnet/aspnetcore/issues/22228

Closing out this investigation issue.

Was this page helpful?
0 / 5 - 0 ratings