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 187127 - wrong indentation in code templates
Summary: wrong indentation in code templates
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.0
Hardware: PC Windows 7
: P2 normal with 10 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
: 188135 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-03 11:11 UTC by honzamarek
Modified: 2011-06-02 14:17 UTC (History)
3 users (show)

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 honzamarek 2010-06-03 11:11:01 UTC
When using code templates with indented blocks (e. g. fnc tab or if tab), tabs are replaced by one space. This happens only if options/editor/formatting/expand tabs to spaces is not checked.

Example:
fnc + tab

Expected result:
function functionName($param) {
[tab]
}

Actual result:
function functionName($param) {
[space]
}

If I use code template (e.g. if) in parent block (e.g. fnc), parent block is badly reformated too.

Please fix it before NB 6.9 final if possible.
Comment 1 Filip Zamboj 2010-06-03 15:07:50 UTC
(In reply to comment #0)
> When using code templates with indented blocks (e. g. fnc tab or if tab), tabs
> are replaced by one space. This happens only if
> options/editor/formatting/expand tabs to spaces is not checked.
i do have spaces (in length of tab) instead of tab if 'expand tab to spaces' is enabled or not. I am not really sure this is a bug, it looks like intention. Petr?
Comment 2 kristianwiborg 2010-07-12 13:57:36 UTC
I have the same problem. I have made a detailed description with screen shots here: 
http://forums.netbeans.org/viewtopic.php?t=28951 

"expand tabs to spaces" is not enabled in my setup.
Comment 3 s.seletskiy 2010-07-28 06:26:27 UTC
*** Bug 188135 has been marked as a duplicate of this bug. ***
Comment 4 vascopj 2010-09-24 14:32:43 UTC
Hi

I have the same issues on Netbeans 6.9 Mac OSX
I also have it on my PC in 6.9 or 6.10

Could you please look into it as the templates are one of the main reasons for using Netbeans.

Downgraded to 6.8 on my PC where the templates still work.

Thanks
Sean
Comment 5 Marian Mirilovic 2011-02-23 09:55:57 UTC
> 10 votes means P2
Comment 6 Petr Pisl 2011-02-23 13:46:59 UTC
The last comment is from 09/2010 and I have fixed some issues with spaces and tabs in code templates last year. I can not reproduce anymore in development build. 

Marking as fixed, please reopen if you find a case where it doesn't work.
Comment 7 sindr0me 2011-02-26 13:51:59 UTC
Still not working.
Comment 8 Petr Pisl 2011-02-28 11:27:16 UTC
In which build it doesn't work for you?
Comment 9 sindr0me 2011-03-01 17:54:59 UTC
Product Version: NetBeans IDE 6.9.1 (Build 201011082200)
Java: 1.6.0_20; Java HotSpot(TM) Client VM 16.3-b01
System: Windows XP version 5.1 running on x86; Cp1250; pl_PL (nb)
Comment 10 Petr Pisl 2011-03-10 13:20:26 UTC
It's fixed in NetBeans 7.0 code. I can not reproduce there. If you can reproduce in a NB 7.0 build, please reopen.
Comment 11 sindr0me 2011-03-21 15:46:49 UTC
In 7.0 there will be no Ruby on Rails support, so 7.0 is not an option for me (I use NB for PHP, RoR and Java). Could you please fix this in 6.9.1 ?
Comment 12 Petr Pisl 2011-03-22 17:10:06 UTC
I'm afraid that there is no plan for another patch for NB 6.9.
Comment 13 Petr Pisl 2011-03-25 11:15:24 UTC
I need to mark it as fixed, because the Target Milestone was 7.0 and there is already fixed.
Comment 14 newfurniturey 2011-05-16 04:06:32 UTC
I'm using PHP in NetBeans 7.0 (Build 201104080000); only PHP is currently activated.

When 'Expand Tabs to Spaces' is unchecked in Tools->Options->Editor->Formatting, tabs are still expanded to spaces. The default value is '4', and there are 4 spaces. If I select 'PHP' under the Language drop-down, 'Override Global Options' is unchecked, so it should not be overriding anything.

The only time the option correctly works is when "Number of Spaces per Indent" is set to '8', in that case, a [Tab] is correctly inserted (and is the length of eight spaces).

I have this same build installed on another machine that has both Java and PHP enabled and this issue does not occur, so it may be limited to only PHP.

Please fix!
Comment 15 Petr Pisl 2011-05-23 15:05:04 UTC
This is misunderstanding. The option "Number of Spaces per Indent" is really saying how many space should be used for one indentation level. But also there is option "Tab Size", which is how many spaces represent the tabulator size. By default the Tab Size property is set to 8 doe to some historic reasons. See issue #153609 or #144067.

So if you want to use tabulator character for indentation level, you should set as well the Tab Size property to 4.
Comment 16 newfurniturey 2011-05-29 17:23:40 UTC
Petr, that's not what I meant - regardless of what the 'Tab Size' is (it is set at 4 at the moment, and setting it to 8 or 6 or 5 or whatever doesn't make a difference).

The issue is that when 'Expand Tabs to Spaces' is unchecked, which should mean that a [Tab] inserts a [Tab] and not "spaces", it still inserts "spaces". Only when the 'Number of Spaces per Indent' is set to 8 does it properly insert a [Tab] - but at all other settings it inserts "spaces".

After enabling Java in the IDE the issue no longer exists; therefore I suggest to test it on a fresh install and only enabling PHP.
Comment 17 Petr Pisl 2011-05-30 12:12:06 UTC
So if I understand correctly, you have unchecked "Expand Tabs to Spaces" and "Number of Spaces per Indent" set up to 4 and "Tab Size" to 4. And with this setting NB still use spaces not '\t', i'm right? 

I can not reproduce this and I use only the php build. Could you attach an example file?
Comment 18 Petr Pisl 2011-06-02 14:17:59 UTC
I have played it again. I have unchecked Expand to Spaces, Number Of Spaces per Indent was 4, Tab size 8. Both Java editor and PHP editor behaves in the same way:

When I press Tab key at the begin of the line, the 4 spaces are added. When I pres Tab for the second time another for spaces are added, but the 8 spaces are converted to the /t char. 

I'm closing this issue as fixed, until we will not clarify what is wrong. I'm sorry I probably just missed something, but for me it looks ok. Please clarify your settings and behavior. Strange to me sounds that it's different for PHP and Java editor.