<p dir="auto">I'm working on an extension and have a <code class="notranslate">CompletionItemProvider</code>. It works good when writing code. But it's annoying when it pops up suggestions inside of strings and comments.<br>
I don't want the suggestions to appear in that cases.</p>
<p dir="auto">I had a look at other extensions on how they solve this problem. The TypeScript plugin has got these lines:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function TypeScriptCompletionItemProvider(client) {
    this.triggerCharacters = ['.'];
    this.excludeTokens = ['string', 'comment', 'numeric'];
    this.sortBy = [{ type: 'reference', partSeparator: '/' }];
    this.client = client;
    this.config = configuration_1.defaultConfiguration;
}"><pre class="notranslate"><code class="notranslate">function TypeScriptCompletionItemProvider(client) {
    this.triggerCharacters = ['.'];
    this.excludeTokens = ['string', 'comment', 'numeric'];
    this.sortBy = [{ type: 'reference', partSeparator: '/' }];
    this.client = client;
    this.config = configuration_1.defaultConfiguration;
}
</code></pre></div>
<p dir="auto">I tried to define the <code class="notranslate">excludeTokens</code> in the same way but it doesn't work. How can I prevent the <code class="notranslate">CompletionItemProvider</code> from being executed in strings and comments?</p>
<p dir="auto">I'm trying to fix <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="118952199" data-permission-text="Title is private" data-url="https://github.com/microsoft/vscode-go/issues/103" data-hovercard-type="issue" data-hovercard-url="/microsoft/vscode-go/issues/103/hovercard" href="https://github.com/microsoft/vscode-go/issues/103">microsoft/vscode-go#103</a>, but as far as I can tell this isn't possible currently without tokenizing the whole file again in my extension and manually checking whether I'm in a comment to suprress providing results.</p>
<p dir="auto">It would be nice if the <code class="notranslate">CompletionItemProvider</code> provided a setting to suppress it's results when in certain tokens/scopes.</p>
<p dir="auto">The implementation of the <a href="https://github.com/Microsoft/vscode/blob/497788c0bcd20859f736d585b49c208af8dd518f/extensions/typescript/src/features/completionItemProvider.ts#L62">TypeScript completion provider</a> has an <code class="notranslate">excludeTokens</code> which seems to play this role but I can't get that to work in my own extension.</p>