1

Background

I am working on an extension (vscode-color-blocks) that uses RegExp match indices (new in ES2022). This means I am using a regex string with the d flag to get indices (relational positions) of each capture group in my regex (source):

export const colorBlockRegex = new RegExp(regexString, 'd');

This means that a successful regex match object will have a .indices attribute that I can then use (source):

const match = colorBlockRegex.exec(comment.content);
if (!match) continue;
console.log(match.indices);

Problem

All of this works fine when I am using the extension on it's own and even together with some other extensions. But VSCode behaves like this new regex feature is not available once I install an extension named Todo Tree. At that point my extension crashes and I get the following error:

stack trace: SyntaxError: Invalid flags: d
    at _ (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:114:74341)
    at Array.<anonymous> (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:114:3580)
    at Object.parse (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:114:71938)
    at Object.parse (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:1:12529)
    at Object.parse (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:114:415)
    at i (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:52:165)
    at Array.get [as indices] (...\.vscode\extensions\gruntfuggly.todo-tree-0.0.215\dist\extension.js:52:2895)
    at DecorationRangeHandler.addNewDecorationRanges (...\vscode-color-blocks\dist\extension.js:1735:95)

The stack trace is a little confusing as it steps from gruntfuggly.todo-tree-0.0.215 into my extension vscode-color-blocks.

Otherwise there must be something wrong with how these two extensions are running on different versions on Javascript?

Zoom
  • 400
  • 1
  • 5
  • 20
  • 1
    Is there a conflict in function names, maybe? Do you have `_` as a function somewhere? – vanowm May 05 '22 at 11:39
  • @vanowm good idea, but I don't have any function named `_` specifically. Neither does todo-tree seem to have any function named `addNewDecorationRanges` or similar. Even then, the two extension should not be able to access each others' objects/classes/functions should they? – Zoom May 05 '22 at 11:45
  • what happens at `todotree::extension.js:52:2895` – rioV8 May 05 '22 at 14:50
  • @rioV8 it is an obfuscated file too big to paste into Pastebin, but I copied the relevant block: https://pastebin.com/mMbyc5Ht `todotree::extension.js:52:2895` is the position between `=` and `i` in the code `if(void 0===u){const{measurementRegExp:o,groupInfos:l}=i(e);` near the end. – Zoom May 05 '22 at 14:59
  • Todo Tree seems to have a polyfill for what I, maybe naively, am trying to to use from the vanilla vscode JS library https://github.com/Gruntfuggly/todo-tree/blob/2a7f7318903f5ae268e782ac82b27d2258ddc59c/package.json#L1170. They must be clashing with each other somehow but I wonder why or how? – Zoom May 05 '22 at 15:11

0 Answers0