PreviousNextTracker indexSee it online !

(88/231) 2943948 - Macro Recording Bug

Recorded macros don't always execute steps in the correct order. For my test case, I have the view split into two text areas. The left text area has my test file, and the right one is blank. Each line in the left text area has a colon somewhere in the middle, and I want to copy all text appearing before that colon to the right-hand text area.

Test file:

This sentence has : a colon in it.
So does : this one.
Only this text : will be copied over.

I placed the cursor at the start of the first line, began recording a temporary macro, and executed the keystrokes necessary to copy over one line's worth of pre-colon text. Here is my resulting macro:

start = textArea.getCaretPosition();line = textArea.getCaretLine();end = textArea.getLineEndOffset(line) + 1;text = buffer.getText(start, end - start);match = text.indexOf(':', 1);if(match != -1) {if(':' != '\n') ++match;, start + match - 1);}

After clearing the right-hand text area, putting the cursor back in front of the first line, and executing the macro, the right side is blank (with the cursor), and the left side looks like this:

This sentence has
: a colon in it.
So does : this one.
Only this text : will be copied over.

Technically, everything is getting executed, but it's getting executed in the wrong order.

Submitted kog13 - 2010-02-01 - 17:42:01z Assigned nobody
Priority 5 Category macros
Status Open Group normal bug
Resolution None Visibility No