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 146116 - code formattter regress for if statement
Summary: code formattter regress for if statement
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: Sun All
: P2 blocker (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-04 02:39 UTC by Chihin Ko
Modified: 2008-09-25 08:51 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot show problem of this IZ (138.61 KB, image/jpeg)
2008-09-04 03:06 UTC, Chihin Ko
Details
jif file that show this problem (61.05 KB, image/gif)
2008-09-10 01:26 UTC, Chihin Ko
Details
image file shows problem still exist (73.62 KB, image/gif)
2008-09-23 21:36 UTC, Chihin Ko
Details
file withtabs in it (230 bytes, text/plain)
2008-09-24 20:32 UTC, ivan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chihin Ko 2008-09-04 02:39:45 UTC
In C++ source window, the indentations within "if" "else" block are all mess up, e.g.

         if (...) {
             statements;
         } else {
             statements;
         }


became :

         if (...) {
         statements;
         } else {
         statements;
         }
Comment 1 Chihin Ko 2008-09-04 03:06:48 UTC
Created attachment 69002 [details]
screenshot show problem of this IZ
Comment 2 Alexander Simon 2008-09-04 07:15:27 UTC
Please, provide c/c++ formatting settings and NB version
Comment 3 Chihin Ko 2008-09-09 18:58:34 UTC
I got nb6.5 from Thomas' download for ceres SSIDE, and here is the version info that I got from IDE help,
I guess it is 20080902 build.

Product Version: Sun Studio (Build 200809021401, Sun Studio 20080610)
Java: 1.5.0_07; Java HotSpot(TM) Client VM 1.5.0_07-b03
System: SunOS version 5.10 running on x86; ISO646-US; en (sunstudio)
Userdir: /net/benjamin2/export/ws/jeanko/dinstall/ideuserdir
Comment 4 Chihin Ko 2008-09-09 19:08:46 UTC
As for c/c++ format settings, I did not do anything with it, everything is defaul.
Comment 5 Alexander Simon 2008-09-09 20:00:29 UTC
I need an steps to reproduce bug.
And, please, attach right screen shot, because attachment does not contain picture.
Comment 6 ivan 2008-09-09 20:25:27 UTC
To reproduce, edit a file with cat and put tabs into it.

It looks like the default tab expansion has switched from 8 to 4 
between NB6.1 and NB6.5

In nb65 go to Tools->Options->Editor->Formatting.
I see TabSize is set to 4. It should be set to 8.

This lookslike a change in NB because if you choose AllLanguages
TabSize is also 4.

And if you go to NB 6.1 that same TabSize used to is 8.

This probably should be reassigned to nb editor.

Comment 7 Chihin Ko 2008-09-10 01:26:14 UTC
Created attachment 69479 [details]
jif file that show this problem
Comment 8 Alexander Simon 2008-09-10 08:56:29 UTC
fixed, change set:
http://hg.netbeans.org/main/rev/945196efd334
Comment 9 Quality Engineering 2008-09-10 17:25:15 UTC
Integrated into 'main-golden', will be available in build *200809101401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/945196efd334
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed IZ#146116:code formattter regress for if statement
Comment 10 Chihin Ko 2008-09-23 21:36:20 UTC
Created attachment 70362 [details]
image file shows problem still exist
Comment 11 Chihin Ko 2008-09-23 21:37:47 UTC
Probem seems still exist :

Product Version: Sun Studio (Build 20080917154240, Sun Studio 20080918)
Java: 1.5.0_07; Java HotSpot(TM) Client VM 1.5.0_07-b03
System: SunOS version 5.10 running on x86; ISO646-US; en (sunstudio)
Userdir: /home/jeanko/.nide65/intel-S2
Comment 12 Alexander Simon 2008-09-24 08:07:46 UTC
Please,
- attach problem file.
- describe steps to reproduce bug.
Because I have only guess about tab size. I.e file was created in other ¨tab size¨.
In this case it is not bug.
Comment 13 Alexander Simon 2008-09-24 11:47:02 UTC
fix initial tab size:
- use tab size = 8 for c/c++ files instead NB default tab size = 4
Before checking bug, please, clear user dir.
Change set:
http://hg.netbeans.org/main/rev/2f6df693e450
Comment 14 Quality Engineering 2008-09-24 17:29:13 UTC
Integrated into 'main-golden', will be available in build *200809241401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2f6df693e450
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed IZ#146116:code formattter regress for if statement
- use own tab size as default
Comment 15 ivan 2008-09-24 19:55:40 UTC
I'm a bit concerned about this deviation from the NB default.
NB chose to go from 8 to 4 for some reason.
We should really try and find why NB did that.

There is nothing about C/C++ specifically that mandates a tab size 
of one kind or another. 
Comment 16 ivan 2008-09-24 20:32:39 UTC
Created attachment 70515 [details]
file withtabs in it
Comment 17 ivan 2008-09-24 20:46:00 UTC
I just added an attachment.
It is a file created with vi with tabstop=8 and shiftwidth=4.
(shiftwidth == indent)
If you use ":set list" in vi this is what you will see:

$
#include <stdio.h>$
$
main(int argc, char *argv[])$
{$
    for (int cx = 0; cx < argc; cx++) {$
^Iif (argv[cx][0] == '-') {$
^I    printf("Saw option '%s'\n", argv[cx]);$
^I} else {$
^I    printf("Saw argument '%s'\n", argv[cx]);$
^I}$
    }$
}$

$ denotes end-of-line. The ^I are tabs. Note how vi will "collapse" 2 indents into one tab.

I then blew away my userdir and FileOpen'ed it under NB.
NB settings are as follows:
    IndentSize 4
    Expand Tabs to Spaces yes
    Tab Size 8

With these settings the file is presented incorretly with the if/print/else/print lines
appearing aligned the same as the for line.

I found out that if I disable "Expand Tabs to Spaces" that things work correctly.
So it seems that something in "Expand Tabs to Spaces" doesn't work right ... 
I also found out that this is very sensitive to ordering of things ... setting the
options, vs opening a file, whether the Document underlying the open file is cached etc.





Comment 18 Alexander Simon 2008-09-25 08:50:35 UTC
It is exactly what I fixed Wed Sep 24 10:47:02 +0000 2008