Bug 332818 - [formatter] Java formatter, Blank Lines tab, only 1st line indented when multiple lines is set
Summary: [formatter] Java formatter, Blank Lines tab, only 1st line indented when mult...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 01:32 EST by Jeffrey Wexler CLA
Modified: 2011-01-25 07:09 EST (History)
4 users (show)

See Also:


Attachments
Custom formatter profile (28.85 KB, text/xml)
2010-12-19 21:36 EST, Jeffrey Wexler CLA
no flags Details
Test snippet - I think this is what you wanted, right? (582 bytes, text/plain)
2010-12-19 21:37 EST, Jeffrey Wexler CLA
no flags Details
Prior to Source-Format Element: Indented blank lines in lines 33 to 37 (1.77 KB, text/x-java)
2010-12-21 00:42 EST, Jeffrey Wexler CLA
no flags Details
After Source-Format Element on lines 32 to 39. Note blank lines 34 to 37 and 39 lost their indentation (1.75 KB, text/x-java)
2010-12-21 00:44 EST, Jeffrey Wexler CLA
no flags Details
Proposed patch (3.21 KB, patch)
2010-12-23 05:38 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Wexler CLA 2010-12-17 01:32:27 EST
Build Identifier: 20100917-0705

preferences -> Java -> Code Style -> Formatter
After creating new profile based on Eclipse [built-in], edit the profile.
On Indentation tab, in Indent section, select (add check to) "Empty lines".
On Blank Lines tab, if you add more than one line for example setting "Before method declarations" to 3, then only the first line is indented but the subsequent lines (e.g., two in this case) are not indented.
I believe that all of the respective lines should be indented.

Additionally, after setting on the Blank Lines tab, "Number of empty lines to preserve" to 99, then when formatting a java document, rather than leaving the blank lines between methods as "preserved" which I take as unchanged, it removes the tab indents that I had manually added on sequential blank lines beginning with the second one.

Also, I noticed there may be some outcome reliability issue(s) related to when making the settings on the Blank Lines tab of the formatter edit dialog. At one point, when I opened the formatter edit dialog, Blank Lines tab, it displayed the first 2 lines indented and subsequent ones (e.g., the following three) as not indented; then after changing "Before declarations of the same kind" from 1 to 3 and then back to 1, only the first line was indented but not subsequent ones.


Reproducible: Always

Steps to Reproduce:
1.See details section, first paragraph.
Comment 1 Prakash Rangaraj CLA 2010-12-17 01:42:15 EST
Moving to JDT
Comment 2 Dani Megert CLA 2010-12-17 11:27:36 EST
It looks like this contains several issues. Please one issue per bug only. Also, please attach your formatter profile and a test snippet.
Comment 3 Jeffrey Wexler CLA 2010-12-19 21:36:09 EST
Created attachment 185512 [details]
Custom formatter profile
Comment 4 Jeffrey Wexler CLA 2010-12-19 21:37:03 EST
Created attachment 185513 [details]
Test snippet - I think this is what you wanted, right?
Comment 5 Jeffrey Wexler CLA 2010-12-19 21:42:04 EST
In terms of the number of issues, I am guessing that the additional info that I mentioned in the 3rd paragraph of the description section is related to this bug. If not, then I'll go ahead and separate that 3rd paragraph (beginning with "Also, I noticed") as a separate bug report.
Comment 6 Ayushman Jain CLA 2010-12-20 01:38:57 EST
(In reply to comment #4)
> Created an attachment (id=185513) [details] [diff]
> Test snippet - I think this is what you wanted, right?

We mean a code snippet or java file which could show the problem on formatting using your formatter settings.

(In reply to comment #5)
> In terms of the number of issues, I am guessing that the additional info that I
> mentioned in the 3rd paragraph of the description section is related to this
> bug. If not, then I'll go ahead and separate that 3rd paragraph (beginning with
> "Also, I noticed") as a separate bug report.

I tried but couldn't reproduce this. I always notice that irrespective of the number specified in "Before declarations of the same kind", only the first blank line is indented, and none after that.
Comment 7 Jeffrey Wexler CLA 2010-12-21 00:42:12 EST
Created attachment 185613 [details]
Prior to Source-Format Element: Indented blank lines in lines 33 to 37
Comment 8 Jeffrey Wexler CLA 2010-12-21 00:44:19 EST
Created attachment 185614 [details]
After Source-Format Element on lines 32 to 39. Note blank lines 34 to 37 and 39 lost their indentation
Comment 9 Ayushman Jain CLA 2010-12-21 07:24:51 EST
Frederic, whats the correct behaviour in this case?
Comment 10 Frederic Fusier CLA 2010-12-21 13:00:44 EST
(In reply to comment #9)
> Frederic, whats the correct behaviour in this case?

Until 3.6 (including 3.6.1) the formatter never leaves any tabs indentation on preserved empty lines. An enhancement request was opened about this (see bug 86249) but was deferred and falled as wontfix when resolved/later bugzilla state was removed.

If this behavior should be changed, then this enhancement needs to be reopened...

However, since 3.7 M1, the formatter now leaves the tabs indentation of the first empty lines. I think this is an unexpected behavior which should be fixed. We'll use this bug to track work around this last issue...
Comment 11 Frederic Fusier CLA 2010-12-22 12:16:51 EST
(In reply to comment #10)
> (In reply to comment #9)
> > Frederic, whats the correct behaviour in this case?
> 
> Until 3.6 (including 3.6.1) the formatter never leaves any tabs indentation on
> preserved empty lines. An enhancement request was opened about this (see bug
> 86249) but was deferred and falled as wontfix when resolved/later bugzilla
> state was removed.
> 
> If this behavior should be changed, then this enhancement needs to be
> reopened...
> 
> However, since 3.7 M1, the formatter now leaves the tabs indentation of the
> first empty lines. I think this is an unexpected behavior which should be
> fixed. We'll use this bug to track work around this last issue...

Ooops, I made a mistake while doing my tests with previous Eclipse versions. I forgot to check the 'Empty Lines' check-box in Indentation formatter preferences tab... Doing it, then it appears that this weird behavior seems to exist since day 1 (at least since 3.3, I didn't test with previous versions).

Hmm, this slightly change the conclusion about this bug... :-S

First, it seems that bug 86249 was finally implemented as there's the Indent Empty Lines preference in the Indentation tab... However, the bug is still as WONTFIX!?

Second, it seems that this option does not work well as described in this bug. I agree that it should always keep the existing indentation of the empty lines and add it if it does not exist (as per bug 86249 comment 0)

Third, as the formatter is the same since 3.3, it's not a regression as I initially thought...

The conclusion is that we definitely have a a bug. The different issues described in comment 0 are all the same from my point of view. As soon as the formatter will set all the empty lines indentation correctly, they should be all fixed...
Comment 12 Frederic Fusier CLA 2010-12-23 05:38:48 EST
Created attachment 185757 [details]
Proposed patch

There was a small glitch while adding empty lines when the indentation preferences was set. The column needed to be reset to 1 to have correct indentation printed in the buffer...
Comment 13 Frederic Fusier CLA 2010-12-23 05:39:15 EST
Released for 3.7M5 in HEAD stream.
Comment 14 Satyam Kandula CLA 2011-01-25 07:09:46 EST
Verified for 3.7M5 using build I20110124-1800