Working with the debugger

I was a little bit bitten by the upgrade suddenly no longer running old extensions. I now wanted update the plugins I wrote and was looking for means of debugging since it apparently is not as straight forward. I’m no pro dev.

I tried to follow the debugging guide but it is not complete. You write one should just start the debug editor and start debugging. But how can I start it? Where can I open my extensions in this editor and set breakpoints?

I cannot invoke extensions with the regular shortcut. How can I then run the extensions to debug them once I managed to set the breakpoints?

Thanks a lot.

Good questions :sunny:

Where can I open my extensions ?

  • FoldingText > Application Folder
  • (then open the relevant main.js in your preferred text editor)
  • Whenever you save the main.js textfile, it will be reloaded in the SDK version of FoldingText

Set my breakpoints ?

  • Enter the one-word line debugger; in the source text wherever you want the debugger to pause execution

Invoke extensions with the regular shortcut ?

  • That will work as soon as the shortcut mapping syntax is correct,
  • but it may be that is appears not to work because the code is failing before a breakpoint.
  • Once you have clicked Inspector, and Debugger, in the SDK editor (into which you should just paste some test text) you can click on All Exceptions to see the line on which the code is failing.

One thing that I sometimes do is create a temporary keybinding (those should work in debugger) to trigger my plugin when creating/debugging it.

I think @complexpoint answered the other points, but if not please post again. Getting the debugger working is key to plugin development.

Thanks for the answers.
I had the problem that in the debugger I could not find my plugin / file so I could not open it within the debugger to set breakpoints. The “debugger;” line worked of course. But there’s another way.

In the Resource tab I searched for a certain word I know I only have in my plugin. This showed the main.js from my plugin, which I could then open and set breakpoints.

As to invoking, I found out that I can execute commands in the console. From the API I learned that there was a perfomAction method in the Editor class. I could not invoke this by typing Editor.performAction() however. I figured maybe I’m in the context of Editor anyway and used this.performAction() which worked.

So now I only need to provide the function of how I named this plugin. I looked for the Extensions.addCommand function, where I define “name” and entered it. So in the console, I called this:

this.performAction(‘my name of the command’)

And it executed it. This way I didn’t need to learn how to make key bindings :slight_smile:

So to summarize:

  • Find the plugin you’re working on in the Resource tab by searching for a word within your plugin. You can then open it and set breakpoints. This is how you find your plugin in the debugger.
  • Then, set a breakpoint somewhere.
  • To invoke your plugin, if it’s a command, in the console line where you can type your own JavaScript lines in the context of where the debugger currently is, type this.performAction(‘enter the name of your command here’). The name is the name you defined under the name property in the Extensions.addCommand line in your plugin.