Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tankorsmash opened this issue Nov 19, 2024 · 1 comment
Open

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

tankorsmash opened this issue Nov 19, 2024 · 1 comment

Comments

@tankorsmash
Copy link

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
Copy link
Member

AndreasArvidsson commented Nov 20, 2024

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?
b3b1abf

We might be on this line:

modifierStages.forEach((stage) => {
targets = targets.flatMap((target) => stage.run(target));
});

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants