This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 240336 - Macro recording doesn't works properly
Summary: Macro recording doesn't works properly
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Macros (show other bugs)
Version: 8.0
Hardware: PC Windows 7 x64
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-12 12:21 UTC by -Silver-
Modified: 2015-04-07 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description -Silver- 2014-01-12 12:21:14 UTC
Steps to reproduce the issue:
1. Create a new java file as follow:

package netcattests;

public class NetCatTests {
    public void method() {
    }  
}

2. Put the caret at the end of the line: public void method() {
3. Start to record macro from the editor button
4. Write some code, at the end the file should appear like this:
package netcattests;

public class NetCatTests {
    public void method() {
        System.out.println("Hello world");
    for(int i=0;i<10;i++){
        System.out.println(i);
    }
this is a comment    
    }  
}
5. Go to line "this is a comment" and hit CTRL+SHIFT+C to comment it
6. Hit SHIFT+ALT+F to format the file
7. At the end the file should appear like this 
package netcattests;

public class NetCatTests {

    public void method() {
        System.out.println("Hello world");
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
        }
//this is a comment    
    }
}
8. Press "Stop macro recording" editor button and save the macro as "test"
9. Add as shortcut "F12"
10. Restore the file like the original one
package netcattests;

public class NetCatTests {
    public void method() {
    }  
}

11. Put the caret at the end of the line public void method(){ and press F12 to run the macro
12. The result is wrong.

NOTE: In this example I have NOT used code templates recording the macro. In any case it seems that the use of code template is not correctly recorded (expanded) I don't know if it is a normal behavior or another bug but I think that a code template expansion should be recorded by the macro.
Comment 1 -Silver- 2014-01-12 12:46:38 UTC
I investigate a bit and seems that the problem is due to the fact that the macro doesn't record the code completion. This make impossible to record macros in multiple situations. Suppose as simple example that you want to make a macro that write the string:

System.out.println("Hello world");

You can not use the code template "sout" because the macro doesn't expand it.
But also if you use the "traditional" mode writing the string by hand when you arrive to write till

System.out.println("

the editor, automatically, without your explicit request, complete the line with

");

The macro doesn't record this completion
Comment 2 Svata Dedic 2014-01-13 07:53:07 UTC
Agree, better connection not only to CC could be useful; currently actions that accept input and then modify the text are not integrated well. It's more accepted for actions that e.g. display a GUI rather for code completion, that is more lightweight.
Comment 3 Svata Dedic 2015-04-07 09:13:55 UTC
Dusane: any thoughts on the integration with TypingHooks ?