streetsidesoftware / vscode-spell-checker

A simple source code spell checker for code
https://streetsidesoftware.github.io/vscode-spell-checker/
Other
1.43k stars 128 forks source link

Restrict spell checking by object type #793

Open HayDegha0917 opened 3 years ago

HayDegha0917 commented 3 years ago

I would like to filter the types of objects (variables, constants, function names, etc.) that the spell checker checks because variable and function names are often abbreviated. The way it works now, the spell checker complains about all of those, creating a huge list of flagged objects.

This obscures those cases where spell checking really matters, like messages and comments.

The ability to filter by object type would make the extension much more useful. As it is now, I will most likely turn it off because the cost of combing through unimportant messages outweighs the benefit of catching spelling errors in stuff that affects usability.

Jason3S commented 3 years ago

To some degree this is already possible. The spell checker does not understand the parts of the code, but it does allow controlling which sections of a file get check using a regular expression.

For some languages a RegExp is already defined.

Example:

{
    "languageSettings": [
        {
            "languageId": "javascript",
            "includeRegExpList": [
                      "CStyleComment",
                      "string"
             ]
        }
    ]
}
HayDegha0917 commented 3 years ago

Thanks for the tip. It helps a bit, though the pre-defined regular expressions are not foolproof. For example, the "string" pattern does not omit variables in template strings. And, in some cases, declared variables are still spell checked. Using a language tokenizer would really work better.