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

Python modules should be ignored #247

Closed LordWolfenstein closed 2 years ago

LordWolfenstein commented 2 years ago

A lot of module are not actual words. When you import a module, or a function or class from a module, it should be ignored in the rest of the file.

image

LordWolfenstein commented 2 years ago

One more example image

EWSoftware commented 2 years ago

It looks as if it's being treated as a plain text file. If I open a .py file in VS 2017, 2019, or 2022 it spell checks the file as expected and skips the actual code elements. Are you using some other package for Python files?

LordWolfenstein commented 2 years ago

It is a large Django project. That is all. Problem exists for brand new projects for both Django and plain console. image

EWSoftware commented 2 years ago

I'm not familiar with Python or Django. Is there an example you can provide?

LordWolfenstein commented 2 years ago

You just install Python web projects with the Visual Studio Django installer. Then you can create a blank Django project in the launcher. Though I have the same problem with Python Console applications in VS 2022. image

EWSoftware commented 2 years ago

Sorry, like I said, I'm not familiar with it. I don't have any Python project templates available. Is that a workload in the Visual Studio Installer or something that's in the marketplace or elsewhere?

LordWolfenstein commented 2 years ago

You just add it in the installer image

EWSoftware commented 2 years ago

When that workload is installed, the classifier changes and general code elements, variables, etc. are classified as text as opposed to being unclassified and ignored when it's not installed. I'll add a case to ignore it for that classifier. For the time being, you can work around it by explicitly excluding the text classification using the Ignored Classifications options in the configuration file which essential does the same thing.

Open the configuration file (global or solution/project), go to that category, open a Python file with this issue and let it flag the spelling errors, go back to the configuration file editor, click the Refresh Content Types button, select Python in the dropdown, and check the "text" option in the list to exclude it from being spell checked. Save the configuration and once you close and reopen the Python file, it should ignore those elements.

I'm not sure if that will prevent it from spell checking things that are legitimately text elements within the Python files but given the way the Python classifier works, unfortunately it's all or nothing.

LordWolfenstein commented 2 years ago

Hold on a second! Are you telling me installing Django templates changes how Visual Studio treats code? In that case you should file a bug report to Microsoft.

EWSoftware commented 2 years ago

It does change but I think its because if there's nothing specific for a language it uses something more generic.