Expanding Code Action Sample Diagnostic File #65
-
I wanted to adapt the diagnostic file from the code-action-sample from VS code to have multiple words instead of simply “emoji” (https://github.com/microsoft/vscode-extension-samples/blob/main/code-actions-sample/src/diagnostics.ts). I tried to make EMOJI an array and then iterate through each word in the array but it did not work. Does anyone have tips on how to approach this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @VaniSachdev , That samples handles the If you want multiple words, you could simply create an if (EMOJIS.some(item => lineOfText.text.includes(item))) { It will kind of work, but it has the same flaw as the original sample itself, because it is not looking for a word that matches the emoji, but a piece of text. For instance, if you type I see two alternatives.
Hope this helps |
Beta Was this translation helpful? Give feedback.
Hi @VaniSachdev ,
That samples handles the
EMOJI
constant in places. At first, inrefreshDiagnostics
, looking of its presence in the current line. After that increateDiagnostic
to find out it location.If you want multiple words, you could simply create an
EMOJIS
array and updaterefreshDiagnostics
to something like this:It will kind of work, but it has the same flaw as the original sample itself, because it is not looking for a word that matches the emoji, but a piece of text. For instance, if you type
memoji
oremoji
in the original sample, both will be recognized, butmemoji
shouldn't, right?I see two alternatives.