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

Suggestion: Support Comment Tagger in web-related files: razor, cshtml, js, css #328

Closed
fitdev opened this issue Jun 4, 2024 · 20 comments
Closed
Assignees
Labels
Highlight Syntax highlight

Comments

@fitdev
Copy link

fitdev commented Jun 4, 2024

It would be really nice if Comment Tagger would also work in .razor, .cshtml, and perhaps even .css, .less, .scss, and .js files as well. Ideally anywhere VS is able to provide an API that such a run of text is a comment, it should work.

Also, I noticed recently that in .csproj files Comment Tagger no longer works.

@fitdev fitdev changed the title Support Comment Tagger in web-related files: razor, cshtml, js, css Suggestion: Support Comment Tagger in web-related files: razor, cshtml, js, css Jun 4, 2024
@wmjordan
Copy link
Owner

wmjordan commented Jun 5, 2024

It was designed to support that. Is it broken again?

@wmjordan wmjordan added the Highlight Syntax highlight label Jun 5, 2024
@fitdev
Copy link
Author

fitdev commented Jun 5, 2024

*.cs:
Screenshot_20240605_092516
Works correctly!

*.csproj:
Screenshot_20240605_092445
Light gray is VS's default color for xml comments I set.

*.razor:
Screenshot_20240605_092359
Again, green here is the default color in VS for razor comments.

Though I am using VS 17.9 P2 (was planning to update later this month), but I doubted if it has anything to do with me using VS version that is a few months older than the latest preview. I try not to update unnecessarily these days to avoid even more issues with VS in later previews.

If VS version may be the problem here and all these highlights are supposed to work (did not think that to be the case for razor files), then perhaps this issue may be put on hold until I upgrade to the latest VS preview this or next week. Then I can test and see if this issue is in the latest VS version as well. That way you will not need to needlessly spend time investigating it.

@wmjordan
Copy link
Owner

wmjordan commented Jun 5, 2024

.csproj: VS team has changed the classification of XML comments. The comment tags are now XML Delimiter, no longer part of XML comment. I will take a look into it.

.razor: Please do the following steps and post the results here.

  1. Open the Codist option, enable the SmartBar.
  2. Enable the Add "Show Active Window Properties" command to File Menu option and the Add "Show Syntax Classification Info" command to Smart Bar option in the Extension Development section.
  3. Open a razor file.
  4. Click into that file document window.
  5. Execute the "Show Active Window Properties" command from the File menu.
  6. Copy the indented lines under the TextBuffer.ContentType: in the window and paste them here.
  7. Close that dialog window.
  8. Select a comment in the razor file, and click the rightmost button on the Smart Bar. --note: the comment should be short, otherwise the button won't show up.
  9. Copy the content of the popup Syntax Classification Info window and paste them here.

@wmjordan wmjordan self-assigned this Jun 5, 2024
@fitdev
Copy link
Author

fitdev commented Jun 5, 2024

Thank you for looking into this!

Screenshot_20240605_153121

TextBuffer.ContentType:
 Razor
  code-languageserver-preview
   code-languageserver-base
    languageserver-base
     any
    code
     text
   code-languageserver-textmate-color
   code-languageserver-textmate-structure
   code-languageserver-textmate-brace
   code-languageserver-textmate-indentation
   code-textmate-commentselection

Selected "FIX: Duration title (name - change word)" within the @* and *@

Classifications for selected content:
[5186..5226) HTML Comment;Semantic - comment;Syntactic - (TRANSIENT): FIX: Duration title (name - change word)

Classification tags:
[5186..5226) HTML Comment
[5185..5186) RazorDirective
[5186..5226) comment
[5226..5227) RazorDirective
[5185..5186) RazorDirective
[5186..5226) comment
[5226..5227) RazorDirective

Also, noticed that regular C# comment tags do not work either in razor files:

Screenshot_20240605_152824

Classifications for selected content:
[8..37) comment;Semantic - comment;Syntactic - (TRANSIENT): FIX: Display all visible edns

Classification tags:
[6..37) comment
[6..37) comment
[6..37) comment

@wmjordan
Copy link
Owner

wmjordan commented Jun 5, 2024

I just looked into the csproj stuff. It might be caused by another code fix.

@wmjordan wmjordan mentioned this issue Jun 5, 2024
35 tasks
@wmjordan
Copy link
Owner

wmjordan commented Jun 5, 2024

Please try the new beta.

@fitdev
Copy link
Author

fitdev commented Jun 5, 2024

You are so fast!
Yes, I can confirm, the latest beta restored .csproj user comment tag highlighting! Great work!

@wmjordan
Copy link
Owner

wmjordan commented Jun 6, 2024

Good, how about the other file types?

@fitdev
Copy link
Author

fitdev commented Jun 6, 2024

Still the same - .razor does not work - neither //NOTE: ... within @{ ... } blocks, nor razor-specific ones like @*NOTE: ... *@.
Not sure if other file types like json, js, css, or less are supposed to work at all, but they do not get highlighted either.

@fitdev
Copy link
Author

fitdev commented Jun 6, 2024

Also just noticed that latest beta seems to have broken rendering of Symbol names in SuperQuickInfos, i.e. <see cref="SymbolName"/> appears as blank `` text. I have "Show containing type for " enabled.

wmjordan added a commit that referenced this issue Jun 7, 2024
@wmjordan
Copy link
Owner

wmjordan commented Jun 7, 2024

The new beta supports less and json now.
Please try your luck with the .razor type.

@fitdev
Copy link
Author

fitdev commented Jun 7, 2024

Thank you so much for the new beta!
Razor now works great! Thank you so much! This was the big one for me!

However regular C# code sections do not work at all in .razor files:

@{
  var foo = 23;
 //NOTE: This is not highlighted at all
}

The output for the // style comment in the razor file within the @{ } section:

Classifications for selected content:
[1281..1317) comment;Semantic - comment;Syntactic - (TRANSIENT): NOTE: This is not highlighted at all

Classification tags:
[1279..1317) comment
[1279..1317) comment
[1279..1317) comment

And although this is totally out of scope, it would be nice if some day Codist would properly highlight C# within razor and cshtml files. Now it is totally lacking - just vanilla VS. Even super quick infos are not available in razor-based C# code. So if one day you can figure out a way to do this, this would be a very big boost to all those doing some razor/Blazor dev.

JavaScript also works great!

What would be nice is this:

  • .less: It would be nice to also support the // style comments also allowed by less. Right now only /* */ syntax works.
  • .scss: This is another very popular css-preprocessor, would be nice if both // and /* */ would be supported.

@wmjordan
Copy link
Owner

wmjordan commented Jun 7, 2024

The razor thing requires quite some hard work.
I don't program web stuff thus I have not installed the VS workload.

The less file type is working fine here.
image

Please use the Active Window Properties command and let me see what's the content type at your site.

And please do so to the scss files too.

@fitdev
Copy link
Author

fitdev commented Jun 7, 2024

*.less:

Strangely, for me // does not work, while /* */ works.

LESS
  css.extensions
    css
      projection
        any
      text
      code

*.scss:
Right now neither // nor /* */ work.

SCSS
  css.extensions
    css
      projection
        any
      text
      code

@fitdev
Copy link
Author

fitdev commented Jun 7, 2024

The razor thing requires quite some hard work

That's understandable. But does this apply even to Super Quick Info? I miss the ability to click on various elements there to quickly navigate to them.

@wmjordan
Copy link
Owner

wmjordan commented Jun 7, 2024

*.less:

Strangely, for me // does not work, while /* */ works.

Please use the button on the Smart Bar to get syntax classification results and post it here.

@wmjordan
Copy link
Owner

wmjordan commented Jun 7, 2024

The razor thing requires quite some hard work

That's understandable. But does this apply even to Super Quick Info? I miss the ability to click on various elements there to quickly navigate to them.

Maybe.

@fitdev
Copy link
Author

fitdev commented Jun 7, 2024

//NOTE: foo (Selected "NOTE: foo", does NOT work):

Classifications for selected content:
[180..189) CSS Comment: NOTE: foo

Classification tags:
[178..189) CSS Comment

/*NOTE: foo*/ (Selected "NOTE: foo", works):

Classifications for selected content:
[193..202) CSS Comment: NOTE: foo

Classification tags:
[191..193) CSS Comment
[193..202) CSS Comment
[202..204) CSS Comment

@wmjordan
Copy link
Owner

wmjordan commented Jun 7, 2024

Please try your luck with the new beta.

@fitdev
Copy link
Author

fitdev commented Jun 7, 2024

You are amazing! Works great! Thanks for all your incredible work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Highlight Syntax highlight
Projects
None yet
Development

No branches or pull requests

2 participants