Custom prev. section

Hi,

wanted to make a macro like this:

komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
ko.commands.doCommand('cmd_jumpToPreviousSection')
ko.commands.doCommand('cmd_home')
ko.commands.doCommand('cmd_wordRight')

but as it looks, home and right gets executed before cmd_jumpToPreviousSection
huh?

Try to ko.commands.doCommandAsync.

nope, no luck

Actually @Defman it looks like cmd_jumpToPreviousSelection is async, which would explain why home and right appear to run first. I think @careyh would know what is going on, but he is on holiday at the moment :frowning:

I thought that: async means that Komodo will wait until the command is done and then run the rest of the code; sync means that Komodo will run it with other commands in the same time… huh.

Async “ensures” that the command is executed asynchronously, whereas doCommand() does not.

jumpToPreviousSection is interfacing with CodeIntel, which essentially forces it to be async. I think in this situation the best thing you could do is use a timeout (I know…).

eg.

if (komodo.view) { komodo.view.setFocus(); }
ko.commands.doCommand('cmd_jumpToPreviousSection')
setTimeout(function() {
  ko.commands.doCommand('cmd_home')
  ko.commands.doCommand('cmd_wordRight')
}, 50);

thanks that works