cursorless-dev / cursorless

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

Cannot read properties of undefined (reading 'run') #2685

Open tankorsmash opened 3 days ago

tankorsmash commented 3 days ago

Hi there, Cursorless has been wonderful.

I'm using Cursorless to edit Python and Vue2 SFC Typescript files, on d8a602e. take line this throws an error now, "Cannot read properties of undefined (reading 'run')", which seems like it's because action.run (r.run in the compiled JS) is undefined.

I bisected from 10 commits ago to now, and it showed b3b1abf3ce2c94bc09c9d87bb288b61572ed805d as the bad commit, but that might only because that commit, take line this stopped being recognized.

2024-11-19 13:07:05.372 [error] TypeError: Cannot read properties of undefined (reading 'run')
    at c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9129
    at Array.flatMap (<anonymous>)
    at c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9116
    at Array.forEach (<anonymous>)
    at Vw (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9100)
    at qw.processPrimitiveTarget (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9014)
    at qw.processTarget (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:8031)
    at qw.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:7819)
    at iy.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:7681)
    at Kb.getTargets (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:5397)
    at Kb.runAction (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:5297)
    at Kb.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:3004)
    at async Object.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:30329)
    at async yE (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:19925)
    at async cursorless.command (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:164:86965)
    at async Y0.h (file:///c:/Users/username/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:32825) cursorless.command {"value":"pokey.cursorless","_lower":"pokey.cursorless"}
2024-11-19 13:07:05.372 [error] TypeError: Cannot read properties of undefined (reading 'run')
    at c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9129
    at Array.flatMap (<anonymous>)
    at c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9116
    at Array.forEach (<anonymous>)
    at Vw (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9100)
    at qw.processPrimitiveTarget (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:9014)
    at qw.processTarget (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:8031)
    at qw.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:7819)
    at iy.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:128:7681)
    at Kb.getTargets (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:5397)
    at Kb.runAction (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:5297)
    at Kb.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:3004)
    at async Object.run (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:30329)
    at async yE (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:140:19925)
    at async cursorless.command (c:\Users\username\.vscode\extensions\pokey.cursorless-0.28.1110\extension.cjs:164:86965)
    at async Y0.h (file:///c:/Users/username/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:32825) command-server.runCommand {"value":"pokey.command-server","_lower":"pokey.command-server"}

Modifiying the JS to check for undefined first then has cursorless warn that an action requires targets, but I'm not sure. Every line in this sample test.py file throws that error if I say 'take line this', whereas 10 commits ago, it'd happily select the entire line.

import sys

def main():
    pass

if __name__ == "__main__":
    main()

Talon version 0.4.0-519-g20c4 (519)

AndreasArvidsson commented 2 days ago

Hi! Glad that you have found Cursorless useful :)

I can't find that commit on GitHub. Have you made a fork or some changes of your own? https://github.com/cursorless-dev/cursorless/commit/b3b1abf3ce2c94bc09c9d87bb288b61572ed805d

We might be on this line: https://github.com/cursorless-dev/cursorless/blob/8cf3464c189808a2ee6e37e2f8566e233ac522fe/packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts#L263-L265

That would mean your command contained a modifier not found in the system. If you want to debug this further you could enable the cursorless debug setting in vscode: "cursorless.debug": true and then open the development console. You should see something like this when you run the command "take line this":

[Extension Host] command:
[Extension Host] {
  "version": 7,
  "spokenForm": "take line this",
  "usePrePhraseSnapshot": true,
  "action": {
    "name": "setSelection",
    "target": {
      "type": "primitive",
      "mark": {
        "type": "cursor"
      },
      "modifiers": [
        {
          "type": "containingScope",
          "scopeType": {
            "type": "line"
          }
        }
      ]
    }
  }
}

To fix this problem I would first make sure that you are on the latest Cursorless Talon and Cursorless extension versions.