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 186429

Summary: Autoindent on paste
Product: java Reporter: ssteiner <ssteiner>
Component: EditorAssignee: Dusan Balek <dbalek>
Status: RESOLVED DUPLICATE    
Severity: normal CC: dtrebbien, smig
Priority: P3 Keywords: USABILITY
Version: 6.x   
Hardware: PC   
OS: Windows 7 x64   
Issue Type: ENHANCEMENT Exception Reporter:

Description ssteiner 2010-05-20 12:03:21 UTC
I'd like Netbeans to automatically ident a copied and pasted piece of code in function of where it is being pasted.

Take this method

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
        }
    }

Now after the line

value = getValue(value);

you need to run another check on value... so you copy the following piece of code

if (value != null)
        {
            // do something here, then return
        }

and you paste it to the line after

value = getValue(value);

The result looks like this:

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
            if (value != null)
        {
            // do something here, then return
        }
        }
    }

And it should look like

public void test(byte value)
    {
        Object value = getValue(value);
        if (value != null)
        {
            // do something here, then return
        }
        else
        {
            // do some preparation
            value = getValue(value);
            if (value != null)
            {
                // do something here, then return
            }
        }
    }

Other IDEs (e.g. Visual Studio) automatically adapt the identation so that the entire bit of code matches up (so in order to do this, upon pasting, the "uppermost" bit of code should line up with the the default identation of the line where the code is being pasted. In the example, the pasted if is idented by two levels.. and the line where it is being pasted is idented by three levels.. meaning the whole bit of code needs an additional level of identation to line up.
Comment 1 smig 2013-12-01 00:21:14 UTC

*** This bug has been marked as a duplicate of bug 111536 ***