EWSoftware / VSSpellChecker

A Visual Studio spell checker editor extension that checks the spelling of comments, strings, and plain text as you type. Supports configuration and various languages.
Other
377 stars 65 forks source link

Spell Check as you type not working for TypeScript files #264

Closed krjone01 closed 1 year ago

krjone01 commented 1 year ago

While there is a configuration in Classifications.config for typescript files, I am not having any luck getting spell check as you type to work for TypeScript files (extension ts).

Followed the instructions for getting a debug copy of the plug-in working. It appears that the type being returned for the VisualStudio 2022 editor is "TypeScript". I am not seeing a ContentType attribute for that, so I suspect that is part of the problem.

krjone01 commented 1 year ago

After digging through the code some more, it appears that the "Apply the above options to all C-Style languages as applicable" option needs to be turned on for it to create a tagger that starts working for type script. That appears to take care of comments and double-quoted string. However, single-quoted strings are not being checked. I suspect that back-ticked interpolation strings are not going to be checked either since there is no concept of that in C.

EWSoftware commented 1 year ago

In the event of no specific content type handler, it will usually fall back to the general tagger, CommentTextTagger, that's dependent on the classifications to determine what gets checked. Can you provide a sample project that demonstrates the issue? I don't use TypeScript and just creating files with an appropriate extension doesn't always trigger the problem as it can be dependent on the project type as well.

krjone01 commented 1 year ago

Of course I went to create a test case on my laptop, visual studio 2022 community, windows 11 home, and it worked perfectly. I created a .net 6 command line c# project and added a typescript file to it. This is without any changes to the default configuration for the extension.

image

It must be specific to the project or version I am using at work. Will have to do more research on how that is different.

krjone01 commented 1 year ago

Did some debugging today on the problem instance of Visual Studio. Set a break point in CommentTextTagger.GetTags method. Checked the value of the name variable set by

name = classificationSpan.ClassificationType.Classification.ToLowerInvariant()

The only name I am seeing for the TypeScript code is "unecessary code" which does not make sense. The highlighting in the editor looks correct. Comments are green and text strings are brownish.

EWSoftware commented 1 year ago

For some reason, the classifier for TypeScript files is not returning any classifications for the text blocks other than the "unnecessary code" classification for variables. For all other text blocks, it's not returning any classifications so they are being skipped. Without them the spell checker can't do anything. I think all that can be done here is to enable the "Apply to all C-style languages" option and don't ignore "/ /" style comments if you want them checked.