Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 471015 - [formatter] Tabs only policy: tab size affects logical indentation level
Summary: [formatter] Tabs only policy: tab size affects logical indentation level
Status: CLOSED DUPLICATE of bug 467229
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: 4.5.1   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 471014 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-25 10:46 EDT by Ryan McNally CLA
Modified: 2015-08-21 03:03 EDT (History)
3 users (show)

See Also:


Attachments
Formatter example at tab size = 2 (536 bytes, text/plain)
2015-06-25 10:46 EDT, Ryan McNally CLA
no flags Details
Formatter example at tab size = 1 (530 bytes, text/plain)
2015-06-25 10:47 EDT, Ryan McNally CLA
no flags Details
Formatter example at tab size = 3 (548 bytes, text/plain)
2015-06-25 10:47 EDT, Ryan McNally CLA
no flags Details
Formatter example at tab size = 4 (551 bytes, text/plain)
2015-06-25 10:48 EDT, Ryan McNally CLA
no flags Details
Formatter example at tab size = 5 (574 bytes, text/plain)
2015-06-25 10:48 EDT, Ryan McNally CLA
no flags Details
Formatter example at tab size = 6 (580 bytes, text/plain)
2015-06-25 10:48 EDT, Ryan McNally CLA
no flags Details
Wrong indentation in interface (168 bytes, text/plain)
2015-06-28 09:02 EDT, Tobias Stensbeck CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan McNally CLA 2015-06-25 10:46:25 EDT
As of 4.5.0, the "Tab size" parameter in the Java formatter options affects the indentation level, rather than just the number of characters between tab stops, when Tab policy is "Tabs only"

The attached files are copy/pasted from the "Indentation" tab for the formatter options, with all "Indent" checkboxes ticked.

Up to size 4 it appears as if the tab size is being used as a maximum indentation level. Size 5 adds an additional tab character to the start of all lines. Size 6 and up seem to progress as expected, i.e.: the tab stops get farther apart, but no new tabs characters are added.

My expectation would be that the tab size parameter does not affect the number of tab characters that are used to indent, but instead controls how much horizontal space each tab character take up.
Comment 1 Ryan McNally CLA 2015-06-25 10:46:59 EDT
Created attachment 254708 [details]
Formatter example at tab size = 2
Comment 2 Ryan McNally CLA 2015-06-25 10:47:16 EDT
Created attachment 254709 [details]
Formatter example at tab size = 1
Comment 3 Ryan McNally CLA 2015-06-25 10:47:38 EDT
Created attachment 254710 [details]
Formatter example at tab size = 3
Comment 4 Ryan McNally CLA 2015-06-25 10:48:00 EDT
Created attachment 254711 [details]
Formatter example at tab size = 4
Comment 5 Ryan McNally CLA 2015-06-25 10:48:27 EDT
Created attachment 254712 [details]
Formatter example at tab size = 5
Comment 6 Ryan McNally CLA 2015-06-25 10:48:46 EDT
Created attachment 254713 [details]
Formatter example at tab size = 6
Comment 7 Ryan McNally CLA 2015-06-25 10:51:26 EDT
Ha! Just noticed that size 6 does in fact add another tab character to lines inside the switch case.
Comment 8 Jay Arthanareeswaran CLA 2015-06-25 11:14:55 EDT
*** Bug 471014 has been marked as a duplicate of this bug. ***
Comment 9 Manoj N Palat CLA 2015-06-25 19:27:34 EDT
Mateusz: Can you please take a look?
Comment 10 Mateusz Matela CLA 2015-06-27 19:10:36 EDT
Looks like a duplicate of bug 467229.
Ryan, does the workaround mentioned there work for you?
Comment 11 Tobias Stensbeck CLA 2015-06-28 09:02:04 EDT
Created attachment 254780 [details]
Wrong indentation in interface

Setting tab size and indentation size to the same value while in 'spaces only' mode and then switching back seems to fix the issues pointed out by Ryan.

However, the formatter does not work for me in interfaces, indenting every method except the first one level to much. Comments are indented correctly, though.

This file has been formatted using 'tabs only' policy and indentation size and tab size set to 4 while the 'spaces only' policy was activated. The same problem appeared while setting both values to 2 as well.
Comment 12 Mateusz Matela CLA 2015-06-28 15:33:09 EDT
(In reply to Tobias Stensbeck from comment #11)
> This file has been formatted using 'tabs only' policy and indentation size
> and tab size set to 4 while the 'spaces only' policy was activated. The same
> problem appeared while setting both values to 2 as well.

Interesting, but I cannot reproduce this effect. This seems to be unrelated to this bug though (because not all the lines are affected the same way), so please start a new bug and provide full steps to reproduce (or attach your formatter configuration, if this is enough).
Comment 13 Ryan McNally CLA 2015-06-29 04:31:21 EDT
(In reply to Mateusz Matela from comment #10)
> Looks like a duplicate of bug 467229.
> Ryan, does the workaround mentioned there work for you?

Yep, that workaround fixes the issue for me.

Cheers!
Comment 14 Tobias Stensbeck CLA 2015-06-29 15:31:29 EDT
(In reply to Mateusz Matela from comment #12)
> Interesting, but I cannot reproduce this effect. This seems to be unrelated
> to this bug though (because not all the lines are affected the same way), so
> please start a new bug and provide full steps to reproduce (or attach your
> formatter configuration, if this is enough).

Indeed it seems to be a different bug. I think it has something to do with the line wrapping policy. I started a new bug here:

Bug 471364
Comment 15 Mateusz Matela CLA 2015-06-29 17:26:50 EDT

*** This bug has been marked as a duplicate of bug 467229 ***
Comment 16 Sasikanth Bharadwaj CLA 2015-08-21 03:03:21 EDT
Verified for 4.5.1 using M20150819-1000 build