PreviousNextTracker indexSee it online !

(54/211) 3385 - 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:

Macros.getMacro("Text/Next_Char").invoke(view);
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;textArea.select(start, start + match - 1);}
Registers.copy(textArea,'$');
view.nextTextArea();
Registers.paste(textArea,'$',false);
textArea.insertEnterAndIndent();
view.prevTextArea();
textArea.goToNextLine(false);
textArea.goToStartOfLine(false);

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:01 Assigned
Priority 5 Labels macros
Status open Group normal bug
Resolution None

Comments

2011-11-20 01:06:17
ezust

- **assigned_to**: ezust --> nobody