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.
After updating to 8.0.1 version (and still in 8.0.2) Netbeans started indenting in a wrong way when using code completion. Here is an example: ---- CODE ---- <?php class Foo{ public function DoSomething(){ echo "Hello world!"; } } $foo = new Foo(); $foo->| --- END OF CODE --- I placed a pipe char in the position where I press ctrl+space to open code completion suggestions. From the suggestion panel, I choose the DoSomething method and I press enter. A this point method is completed correctly but the line is indented 4 spaces on the right. The wrong result is shown below: ---- CODE ---- <?php class Foo{ public function DoSomething(){ echo "Hello world!"; } } $foo = new Foo(); $foo->DoSomething() --- END OF CODE --- As you can see there are 4 spaces at the beginning of last line. If I press shift+alt+f to start autoformatting everything becomes formatted in the right way. After some tests it seems that Netbeans applies "Continuation indentation" value. I have 4 spaces for continuation indentation. If I put Continuation indentation = 0 in editor settings this problem disappears but it's a wrong behavior. I want 4 spaces for continuation indentation and the example above is not a "continuation" situation. The expected result is: ---- CODE ---- <?php class Foo{ public function DoSomething(){ echo "Hello world!"; } } $foo = new Foo(); $foo->DoSomething() --- END OF CODE --- Netbeans version 8.0 worked has expected. OS: windows 2003 server Netbeans versions: 8.0.1 and 8.0.2 Indentation settings: Number of Spaces per Indent = 2 Tab Size = 2 Right Margin = 80 Initial Indentation = 0 Continuation Indentation = 4 Array Declaration Indentation = 2
On more piece of information: if I do more autocompletes on the same row, code indentation increases in the same way. 1 autocomplete = 4 spaces of indentation 2 autocompletes on the same row = 8 spaces of indentation and so on.
I installed a fresh Netbeans 8.0.2 on a Virtual Machine and problem was not there. So I tried to compare settings of this new installation with my settings (using kdiff3) and edited config files manually to try different solutions. At the end I found that removing these lines from config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml resolved the problem. Lines I remove are these <entry javaType="java.lang.String" name="code-template-on-expand-action" xml:space="preserve"> <value><![CDATA[INDENT]]></value> </entry> I don't know at which options in Netbeans config panel they are related. I hope this helps.
FraBastiano saved my life. I had exactly the same issue and this fix is working. Just to note that the file org-netbeans-modules-editor-settings-CustomPreferences.xml on my Ubuntu instalation is located in my user's home directory /.netbeans/8.0.2/config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
I cannot reproduce this issue in the current dev build. Great to hear that you were able to find the cause and that you let us know it so other users can benefit from it as well. Thank you. Product Version: NetBeans IDE Dev (Build 20160610-49331e2a0591) Java: 1.8.0_91; Java HotSpot(TM) 64-Bit Server VM 25.91-b14 Runtime: Java(TM) SE Runtime Environment 1.8.0_91-b14 System: Linux version 4.2.0-38-generic running on amd64; UTF-8; cs_CZ (nb)
I can confirm this is happening on: Product Version: NetBeans IDE 8.2 (Build 201609300101) Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13 Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13 System: Linux version 4.4.0-45-generic running on amd64; UTF-8; en_AU (nb)
Ok I found a cause; If you go to Tools -> Options -> Editor -> Code Templates Down the bottom is the option: "On Template Expansion" If you set that to "Reindent Text" it causes this behaviour.