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 245572 - On Template Expansion "Reindent Text" breaks indentation on code completion and template expansion
Summary: On Template Expansion "Reindent Text" breaks indentation on code completion a...
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-10 21:48 UTC by ArmEagle
Modified: 2016-05-26 05:45 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ArmEagle 2014-07-10 21:48:08 UTC
When having "Reindent Text" selected for "Tools->Options->Editor->Code Templates" "On Template Expansion" indentation in PHP breaks on code completion and template expansion.

Steps:
- Start a new PHP project
- Edit the index.php, write (only) : 
<?php
class cl {
	public function foo() {}
	public function bar() {
		$this->fo
	}
}

- code complete 'foo'
Result:
	public function bar() {
				$this->foo()
	}
with the code completed line having too many indentation.

Expected:
correct indentation.

Someting similar happens when code-completing multi-line code templates.
Steps:
- Edit the index.php, write (only) :
<?php
class cl {
	public function foo() {}
	public function bar() {
		swi
	}
}

- template-expand that 'swi'

Result:
- All lines but the first are not indented.
Expected:
- Correct indentation based on indentation of the first line/context.

This does not happen when using "Reformat Text". But I don't want to have to configure the formatting completely just to use code templates, or have normal code completion.
I also think this didn't used to be the case in the 7.* version I used to use.

A forum post I found that seems to have the exact same issue: https://netbeans.org/projects/www/lists/netcat/archive/2012-05/message/122
Comment 1 Inara 2015-05-11 00:27:17 UTC
We're experiencing this exact same issue. "Reindent Text" seems to only impact the indentation of the second line of the template, ignoring any lines beyond that.

The expected behavior would be that all of the lines from the template have an equal number of indenting characters added to them based on where the cursor is when the template is expanded.
Comment 2 Tomas Mysik 2016-05-25 09:26:17 UTC
It works for me properly in the current dev build. Could anyone please verify it?

Thanks.

Product Version: NetBeans IDE Dev (Build 20160525-db11206858f0)
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.4.0-22-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 3 ArmEagle 2016-05-25 20:43:56 UTC
I just downloaded the development version of today (201605250002). Can confirm both cases expand just fine.

Will try running the development version at work for a while also.

Thank to whomever.
Comment 4 Tomas Mysik 2016-05-26 05:45:18 UTC
Thanks for letting us know!