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

Turning off a dictionary does not seem to work #1215

Closed
4 tasks done
alexbuckgit opened this issue May 10, 2021 · 3 comments · Fixed by #1229
Closed
4 tasks done

Turning off a dictionary does not seem to work #1215

alexbuckgit opened this issue May 10, 2021 · 3 comments · Fixed by #1229
Labels

Comments

@alexbuckgit
Copy link

alexbuckgit commented May 10, 2021

Info

Kind of Issue

  • runtime - command-line tools

Which Tool or library

  • cspell -- the command-line spelling tool

Which Version

Version: 5.4.0

Issue with supporting library?

  • No

OS:

  • Windows

version:

Windows 10

Bug Description

Describe the bug

Multiple acronyms that I want flagged as unknown are defined in an available dictionary. If I exclude that dictionary from the available dictionaries in configuration using "dictionaries": ["!softwareTerms"], those terms still aren't flagged. I also tried using "dictionaries": ["!software-terms"].

The attached test.md file contains four acronyms: HIPAA, RBAC, HIPPA, and RABC. The last two are spelled incorrectly for test purposes. The test.md file also contains lowercase versions of each acronym.

When running cspell trace for each acronyms, HIPPA and RBAC trace to the softwareTerms dictionary, and the incorrect spellings don't appear in any dictionary. After removing that dictionary, the four acronyms and the lowercase versions should be all be flagged as unknown words.

To Reproduce

Steps to reproduce the behavior:

  1. Create the cspell.json and test.md files shown below in a local directory.
  2. Run: cspell test.md -c cspell.json

Expected behavior

All four acronyms and the lowercase variations should all be flagged as unknown words.

cspell.json

{
    "version": "0.1",
    "language": "en",
    "dictionaries": [ "!softwareTerms" ],
    "enabled": true,
    "words": [],
    "ignoreWords": [
    ],
    "flagWords": [],
    "ignoreRegExpList": [
    ]
}

test.md

This file contains HIPAA, HIPAA, RABC, and RBAC as words.  
Lowercase versions of hipaa, hippa, rabc, and rbac also.
@alexbuckgit alexbuckgit changed the title Invalid words not flagged when dictionary containing them is removed Invalid words not flagged when dictionary containing them is excluded May 10, 2021
@Jason3S
Copy link
Collaborator

Jason3S commented May 10, 2021

I agree that this is confusing. I think the behavior should be changed to be more intuitive.

There are two workarounds:

Workaround 1 - Include then exclude the dictionary name.

"dictionaries": [ "softwareTerms", "!softwareTerms" ],

Workaround 2 - Use languageSettings

{
    // delete "dictionaries": [ "!softwareTerms" ],
    // ...
    "languageSettings": [
        {
            // * to match all files.
            "languageId": "*",
            "dictionaries": [
                "!softwareTerms"
            ]
        }
    ],
    // ...
}

What is happening (tldr)

It is a ordering issue due to how the dictionary list is built. Dictionaries are applied in order.

  1. All dictionaries declared at the top level are added to the list.
  2. All file overrides are applied.
  3. All new dictionaries declared in languageSettings that match the file are added next.

Because softwareTerms is enabled in languageSettings (see cspell-dicts/software-terms) the effective order becomes:

["!softwareTerms", "softwareTerms"]

Which results in:

["softwareTerms"]

@Jason3S Jason3S changed the title Invalid words not flagged when dictionary containing them is excluded Turning off a dictionary does not seem to work May 10, 2021
@alexbuckgit
Copy link
Author

Cool, I'll use the workaround for now. Thanks!

Jason3S added a commit that referenced this issue May 11, 2021
Jason3S added a commit that referenced this issue May 11, 2021
* fix: Add Sample for turning off dictionaries
* ci: Only cspell-action on main branch
* fix: fix typo in readme
* fix: correct how dictionaries are disabled.

fix: #1215
@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants