yzhang-gh / vscode-dic-completion

Dictionary completion
https://marketplace.visualstudio.com/items?itemName=yzhang.dictionary-completion
MIT License
52 stars 13 forks source link

cspell settings from project level not included #13

Closed jakobhviid closed 5 years ago

jakobhviid commented 5 years ago

Hi.

From my testing, it seems that when i add words to the dictionary of codespell to the project level (.vsode/settings.json), they are not included in the completion suggestions. However, they are completed as expected if they are put into the global settings.json file.

I think this should be simple to fix, and it currently restricts us from adding autocomplete words to the rest of the team using the git repo.

Thanks again for a great extension.

yzhang-gh commented 5 years ago

Thanks. It should be fixed in the dev build.

jakobhviid commented 5 years ago

Hi, i think you mean the link here, if so, it still does not work on a Mac it seems. (I do not have access to a PC right now)

The global one works perfectly still.

Thanks for your quick response.

yzhang-gh commented 5 years ago

Hi, i think you mean the link here

You are right.

it still does not work on a Mac it seems

Are you using multi-folder workspace? And a quick check, do you have the new words fidelity and salient in the completions?

jakobhviid commented 5 years ago

No, i am not using a multi-folder workspace. I do not have the two words in the suggestions.

I installed it by first removing the extension, restarting vscode, and then installing the vsix manually.

Am i missing something?

yzhang-gh commented 5 years ago

So you also don't get the new words, right? didn't see you already said that Your installation steps should be fine. (Actually, you can directly install the .vsix and reload/restart vscode.) Could you install it again? (download a new .vsix)

jakobhviid commented 5 years ago

I reinstalled the extension but no luck. I then rebooted the machine, and reinstalled the extension again, and i can now see the two words above. you mentioned, but it still does not import the words from the project settings file:

{
    "cSpell.words": [
        "Controlium",
        "rgaard",
        "DEAPspace",
        ...
    ]
}
jakobhviid commented 5 years ago

If you can provide instructions, i will gladly help provide logs, or anything else you need.

yzhang-gh commented 5 years ago

Thanks.

Could you find the file [UserHome]/.vscode/extensions/yzhang.dictionary-completion-0.8.1/out/src/completion.js and check line 63-64 which should be

const activeDoc = vscode.window.activeTextEditor.document;
cSpellWords = vscode.workspace.getConfiguration('cSpell', activeDoc.uri).get('userWords', []);

If it is, then there might be some unexpected problems. I am only able to look into it during this weekend.

jakobhviid commented 5 years ago

Hi. The code at 63-67 is as follows:

    let cSpellWords = [];
    if (vscode.workspace.getConfiguration('cSpell')) {
        const activeDoc = vscode.window.activeTextEditor.document;
        cSpellWords = vscode.workspace.getConfiguration('cSpell', activeDoc.uri).get('userWords', []);
    }

I dont have any experience with creating extensions, but based on the documentation here it kind of seems as if the problem is related to the vscode api, and not your code.

I will try and investigate further when i have access to a PC again and try again with a simpler project.

Please let me know if you have any ideas or solved it in the meantime.

jakobhviid commented 5 years ago

Ok, something to debug from. I used a colleagues computer (windows 10) and got the following results:

This seems extremely unreliable for some reason. Any ideas?

jakobhviid commented 5 years ago

Ok, i think i might have an idea of what is going on. When i went back to the Mac nothing worked again (from the project settings file), so i tried to replicate the experiment above. My explanation goes like this. In the global settings file, the settings seem to be written to separate variables.

Here is the global file:

"cSpell.userWords": [
    "spatiotemporal",
...
    "subfield",
    "subfields"
  ],

Here is the [ProjectFolder]/.vscode/settings.json file:

{
    "cSpell.words": [
        "quertyfolder",
        "qwertylocal",
        "qwertyui"
    ]
}

So, one is called "cSpell.userWords", while the other is called "cSpell.words". Simply put, the settings would never be read. For some reason cspell create two separate variables. I have no idea how that translated into the results from the previous post, but i think that getting both variables and creating one array from the two should solve the problem. (maybe sanitize for duplicates)

Keep in mind i have not read your code, so you might already be aware of this.

yzhang-gh commented 5 years ago

Pushed a change to import both userWords and words.

The global setting will be overridden by the local one with the same name. I guess that is why cSpell introduced two settings.

jakobhviid commented 5 years ago

I tested it. It works perfectly as intended now. Thank you for your work and your patience.

I will tell my colleagues a fix is on the way.

yzhang-gh commented 5 years ago

Shipped