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 190122

Summary: Indentation works wrongly in function ('}' has wrong position)
Product: editor Reporter: soldatov <soldatov>
Component: Formatting & IndentationAssignee: issues@editor <issues>
Status: RESOLVED FIXED    
Severity: normal CC: alexvsimon
Priority: P1 Keywords: REGRESSION
Version: 7.0   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: screenshot
Logging output of pressing Enter
Correct treatment in older version
Correct treatment in older version #2 (previous was shifted by having an extra newline)

Description soldatov 2010-09-03 06:57:55 UTC
Created attachment 101844 [details]
screenshot

Type such code in empty C file:
int f() {
  if (1) {

===>
Expected code in editor:
int f() {
  if (1) {
    
  }
}

Real:
int f() {
    if (1) {
        
        
}
    
}
Comment 1 Alexander Simon 2010-09-03 11:35:34 UTC
Please evaluate because bug is regression after editor last commits
Comment 2 Vladimir Voskresensky 2010-09-07 11:58:50 UTC
Editor team, please, evaluate, editing is just broken without any single change on C++ side
Comment 3 Miloslav Metelka 2010-09-08 11:44:17 UTC
Apologies for the regression, it's probably related to issue #189638.
When running with 
-J-Dorg.netbeans.editor.BaseDocument.level=FINE
-J-Dnetbeans.debug.editor.document.stack=true
and having a simple main.cpp
int a() {
    if (true) {|
}
and pressing Enter
the output shows that there is a reindentation called:
       ...
       at org.netbeans.modules.cnd.editor.indent.CppIndentTask.reindent(CppIndentTask.java:88)
       ...

but the '}' stays unindented. Attaching output.
Comment 4 Miloslav Metelka 2010-09-08 11:45:35 UTC
Created attachment 101930 [details]
Logging output of pressing Enter
Comment 5 Miloslav Metelka 2010-09-08 14:15:08 UTC
Created attachment 101938 [details]
Correct treatment in older version
Comment 6 Miloslav Metelka 2010-09-08 14:46:45 UTC
Created attachment 101946 [details]
Correct treatment in older version #2 (previous was shifted by having an extra newline)
Comment 7 Miloslav Metelka 2010-09-09 12:37:42 UTC
There was a change in CCKit:378 instead of original

                        Indent indent = Indent.get(doc);
                        indent.reindent(end + 1);

there's

                        Indent.get(doc).indentNewLine(end);

from

176554:de609369a4a6 - vstejskal Oct 15, 2008
#120357: updating module dependencies and removing unneccessary use of the old formatting API; full IDE is buildable and runs somehow

I have fixed the problem for now by restoring the original code:
http://hg.netbeans.org/jet-main/rev/28d079929358
Comment 8 Vladimir Voskresensky 2010-09-09 13:52:07 UTC
Hi Mila, thanks for investigation
> 
> from
> 
> 176554:de609369a4a6 - vstejskal Oct 15, 2008
> #120357: updating module dependencies and removing unneccessary use of the old
> formatting API; full IDE is buildable and runs somehow
Just a question, how could change made in 2008 affects what we have now? :-)
Comment 9 Miloslav Metelka 2010-09-09 15:30:03 UTC
Oops, you're right I've just seen the description but I've overlooked the commit date. I'll search more and possibly use another fix.
Comment 10 Miloslav Metelka 2010-09-09 15:37:45 UTC
No, sorry, I was confused I think the code was really integrated on 2010/08/31:

Integrated into 'main-golden', will be available in build *201008310001* on
http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/de609369a4a6
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #120357: updating module dependencies and removing unneccessary use of the
old formatting API; full IDE is buildable and runs somehow

The wrong date is imho a "feature" of Mercurial (Vita probably started a branch at that time).
Comment 11 Quality Engineering 2010-09-10 03:15:28 UTC
Integrated into 'main-golden', will be available in build *201009100000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/28d079929358
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #190122 - Indentation works wrongly in function ('}' has wrong position).
Comment 12 Alexander Simon 2010-09-10 06:30:57 UTC
Thanks.