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 179522 - Indentation is wrong for bracketless statements
Summary: Indentation is wrong for bracketless statements
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Other
: P3 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-14 16:22 UTC by karmaflute
Modified: 2011-04-18 15:33 UTC (History)
1 user (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 karmaflute 2010-01-14 16:22:30 UTC
Consider this code:

...
...fin.open(fileName.c_str());
...if (fin.fail())
......return false;
| <- cursor here

Hit tab

...
...fin.open(fileName.c_str());
...if (fin.fail())
......return false;
......| <- cursor is now here at the wrong indentation
Comment 1 karmaflute 2010-01-14 17:16:56 UTC
Another example:

...for (int i = 0; i < length; i++)
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;| <- cursor here

Hit return

...for (int i = 0; i < length; i++)
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
............| <- cursor is now here

Hit return

...for (int i = 0; i < length; i++)
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
............
............| <- cursor is now here
Comment 2 karmaflute 2010-01-14 17:24:26 UTC
Another example:

...for (int i = 0; i < length; i++)
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
......
......| <- cursor is here

Begin typing

...for (int i = 0; i < length; i++)
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
......
............c| <- cursor jumps here!
Comment 3 Vitezslav Stejskal 2010-01-15 04:27:11 UTC
What language are you referring to? Java? C/C++? Other?
Comment 4 karmaflute 2010-01-15 10:42:09 UTC
I was referring to C++. But the problem exists in Java as well.

In Java, for example:

...for (int i = 0; i < length; i++) {
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;| <- cursor is here

Hit return

...for (int i = 0; i < length; i++) {
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
......| <- cursor is here (correct)

However:

...for (int i = 0; i < length; i++) {
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
| <- cursor is here

Hit tab

...for (int i = 0; i < length; i++) {
......if (!inArray(data, length, intArray[i]))
.........data[i] = intArray[i];
......else
.........duplicates++;
.........| <- cursor is here (wrong)
Comment 5 Vitezslav Stejskal 2010-01-18 07:26:38 UTC
Ok, let's deal with the C++ problem first.
Comment 6 Alexander Simon 2010-01-18 08:27:40 UTC
C/C++ problem about wrong indentation after compound statement without braces:
https://netbeans.org/bugzilla/show_bug.cgi?id=177229
https://netbeans.org/bugzilla/show_bug.cgi?id=178524
https://netbeans.org/bugzilla/show_bug.cgi?id=178867 
was fixed (will be in NB 6.8 patch1).
First test case is a common editor problem (common for java and c/c++).
Comment 7 Vitezslav Stejskal 2010-01-18 08:42:32 UTC
Thanks, moving to java.
Comment 8 karmaflute 2010-07-19 01:28:09 UTC
I have the same problem when editing PHP code in NetBeans:

...if.(!$result || !$result["coupon_code"])
......return.false;
| <- cursor here

Hit tab

...if.(!$result || !$result["coupon_code"])
......return.false;
......| <- cursor is now here at the wrong indentation
Comment 9 karmaflute 2010-09-10 02:08:55 UTC
This bug has no been addressed in 8 months. I'm moving it to PHP. Hopefully someone there will take pity and fix it for that language.

Pleeeease someone fix this. :(
Comment 10 Filip Zamboj 2010-09-15 12:30:43 UTC
batch reassigning
Comment 11 Petr Pisl 2011-04-18 15:33:23 UTC
In PHP the last case (comment #8) works in NB 7.0. Due to this bug I found out that case with object operator doesn't work.


<?php

class MyClass {

    public function compare () {
        if ($this->test() == 10)  <- ENTER

    }
}


I have fixed this as well. If you find new case, where it doesn't work correctly, please create for it new bug.