cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.13k stars 78 forks source link

Exception raised when trying to run `change pair` in a markdown file #2470

Closed jaresty closed 1 month ago

jaresty commented 2 months ago

I got an exception when I tried to run change pair in a markdown file today. My cursor was in the middle of some backticks. I saw this in the logs:

 SyntaxError: Invalid flags: ds
    at k (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:74341)
    at Array.d (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:3580)
    at Object.parse (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:71938)
    at r.parse (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:1:12754)
    at Object.parse (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:415)
    at l (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:165)
    at Array.get [as indices] (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:2895)
    at iD.run (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:100520)
    at predicate (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:98074)
    at /Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:104145
    at Array.every (<anonymous>)
    at /Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:104136
    at Array.filter (<anonymous>)
    at t.matches (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:104089)
    at wy.generateScopeCandidates (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:34153)
    at generateScopeCandidates.next (<anonymous>)
    at wy.generateScopes (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:133:28877)
    at generateScopes.next (<anonymous>)
    at pP (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:120:6146)
    at u9 (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:148:26958)
    at M2.getScopeSupport (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:148:26705)
    at r (/Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:148:28102)
    at /Users/tkma6d4/.vscode/extensions/pokey.cursorless-0.28.1158/extension.cjs:148:28269
    at Array.map (<anonymous>)
jaresty commented 2 months ago

Seems to be happening because of a bad interaction between cursorless and the extension 'gruntfuggly.todo-tree'. When I uninstalled the extension the exception went away. I haven't opened an issue with them yet.

AndreasArvidsson commented 1 month ago

This appears to be because we are using the regex flag d that was introduced in ECMAScript 2022. https://github.com/cursorless-dev/cursorless/blob/4387672bf4d4f4db239e5d1901e56ad2c0e00d96/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts#L139

I don't know why gruntfuggly.todo-tree is affected by this, but this line at Array.get [as indices] (/Users/tkma6d4/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:2895) might indicate that they are actually modifying something on the regex prototype.

Edit: I should have looked for issues first :D gruntfuggly.todo-tree is globally replacing the regex implementation. I would definitely not recommend this extension. https://github.com/Gruntfuggly/todo-tree/issues/853

Also there's nothing we from the Cursorless side can do about this. I would just recommend closing this issue and following the development on the gruntfuggly.todo-tree repository.