Janne252 / vscode-fontawesome-auto-complete

Auto-complete & preview Font Awesome icons in any language.
https://marketplace.visualstudio.com/items?itemName=Janne252.fontawesome-autocomplete
GNU General Public License v3.0
15 stars 2 forks source link

triggerCharacters #2

Closed lonix1 closed 6 years ago

lonix1 commented 6 years ago

I changed it to: "fontAwesomeAutocomplete.triggerCharacters": ["fa"]

But it still triggers on f.

Janne252 commented 6 years ago

Hey, it appears that the trigger characters provided to registerCompletionItemProvider actually don't prevent the autocompletion, but rather limit the use of other completion item sources:

Here is an example where the trigger character is set to f: Since the word "favorite" starts with an f, Font Awesome autocomplete takes over the process and no further sources of completion items are loaded. Note the lack of "favorite" in the completion items. fontawesome-completion-issue-02

However when the trigger character no longer is an f, but instead an empty array [], other sources of completion items are loaded as well: fontawesome-completion-issue-01

It also seems that providing more than one character is ignored, resulting in the same as an empty array (as above). fontawesome-completion-issue-03

Answer to this specific issue: Based on this, triggerCharacters is a bit confusing. It is not used to prevent an unwanted completion item provider but rather to select the "master" one. I think will have to open an issue on vscode repo to confirm the logic and behavior of triggerCharacters.

Personally I've been wondering why in some cases the list of completion items is incomplete (for example no class members in TypeScript). Apparently a matching triggerCharacters causes other sources of completion items to be ignored, as demonstrated above. This often results in polluting the list of completion items with Font Awesome names because this very extension overrides other sources of completion items if the triggerCharacters matches the current context.

For now I think it is best not to set triggerCharacters at all. By doing that you will at least get ALL the completion items you would normally get, and not just the Font Awesome names. Unfortunately the extension default is f.

lonix1 commented 6 years ago

@Janne252 Thanks. I'll upvote your vscode issue if you make one. And thanks for this extension.

Janne252 commented 5 years ago

@lonix1 The extension is now based on a trigger word which defaults to fa-. The completion item list should no longer contain all Font Awesome icons by default; Only when the trigger word is present.