Bug 89739 - [prefs] Default for formatter should be Tab characters, not spaces
Summary: [prefs] Default for formatter should be Tab characters, not spaces
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 82275 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-03-30 18:49 EST by Steve Northover CLA
Modified: 2005-04-26 14:37 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Northover CLA 2005-03-30 18:49:11 EST
Recently (maybe not?) this changed and I didn't notice it causing my source 
files to be mixed tabs and spaces.  That's really bad.  Can the default change 
back to tabs?
Comment 1 Dani Megert CLA 2005-03-31 03:30:52 EST
The default comes from J Core. 2.1.3 and older it was a tab and then it was
changed to use the built-in 'Java Conventions' profile which uses Spaces. No
idea who drove that decision ;-)

Olivier, do we plan to provide a 'real' Java Conventions profile with mixed
tabs/spaces?

Personally I'd like to use tabs as default.
Comment 2 Steve Northover CLA 2005-03-31 09:06:38 EST
Thanks Daniel.  This is a really big one for me, can it get fixed?
Comment 3 Olivier Thomann CLA 2005-03-31 09:29:04 EST
Frederic, this seems to be the way to defaults preferences are initialized.
Could you please investigate?
Comment 4 Philipe Mulet CLA 2005-03-31 10:36:13 EST
Steve - did you define your own custom formatter settings profile ?

If not, then it is a consequence of Java conventions becoming closer to official
specifications. By default, the mixed tabs and spaces is mandated, and we
recently added support for it.

Now if you are not using Java conventions, but rather your custom set (or
Eclipse 2.1 profile) then you should not be seeing this. 
Comment 5 Steve Northover CLA 2005-03-31 10:59:00 EST
All I know is that since the beginning of time, SWT chose tabs instead of 
spaces.  I don't remember doing anything special to enable this.  Everytime I 
get a new Eclipse, I did nothing and tabs where used.  Sometime recently, I 
got a new Eclipse and spaces were used.  The team has been releasing code 
until I noticed it.  Now SWT has code that is mixed, some tab and some spaces 
(I don't know how much).  When the font is changed, we will look like fools in 
the debugger.  If I have this problem, doesn't every other component have it 
too?
Comment 6 Frederic Fusier CLA 2005-03-31 11:27:40 EST
Olivier, this issue seems not to be in 3.1 M5...

However, nothing has changed in default. Creating a new workspace and looking
immediately at Code Formatter options page always (ie. in both versions) shows
'Java Conventions [built-in]' selected and Use tab character is always unselected...

Here's a small scenario to reproduce the problem:
1) create a brand new workspace
2) create a project Test and a class X.
3) Inside class X declaration, hits return and code 'int x;'
4) Then you get:
  a) with 3.1 M5
--------public class X {
--------	int x;
--------}
  b) with 3.1 M6 candidate
--------public class X {
--------    int x;
--------}

So it sounds that JDT/Core behaves diffrently since 3.1 M5.
I will investigate a little bit more during M7 about this preference issue
Comment 7 Olivier Thomann CLA 2005-03-31 11:34:09 EST
This is a different problem.
Format the code is the action to do.
Comment 8 Frederic Fusier CLA 2005-03-31 11:39:13 EST
Seems not to be a different problem.
Format the code provide same results:
  - tabs for 3.1 M5
  - spaces for 3.1 M6
Comment 9 Olivier Thomann CLA 2005-03-31 11:47:03 EST
Then we need to find out how the UI is initializing the code formatter
preferences in M5.
Comment 10 Olivier Thomann CLA 2005-03-31 12:04:47 EST
I think this is related to this inconsistency.
We should provide a new profile and the UI should initialize with this new profile.
I believe this should fix it.
I'll try locally.
Comment 11 Steve Northover CLA 2005-03-31 12:25:04 EST
I'd like this to be fixed for M6, if in fact is was introduced in M5.  This 
will stop others from getting mixed tabs and spaces in their source code.  
Thought?
Comment 12 Olivier Thomann CLA 2005-03-31 12:26:54 EST
We are working on it.
Comment 13 Steve Northover CLA 2005-03-31 12:40:54 EST
Thanks.
Comment 14 Olivier Thomann CLA 2005-03-31 13:00:20 EST
Changes in:
DefaultCodeFormatterConstants.java
DefaultCodeFormatterOptions.java
JavaCorePreferenceInitializer.java
Comment 15 Olivier Thomann CLA 2005-03-31 13:17:43 EST
*** Bug 82275 has been marked as a duplicate of this bug. ***
Comment 16 Olivier Thomann CLA 2005-03-31 14:18:56 EST
Steve, when was the last time you changed the eclipse build?
This problem is not new.
Comment 17 Steve Northover CLA 2005-03-31 15:22:25 EST
I have been away on vacation for the last 3 weeks but it could have been 
around much earlier than that.
Comment 18 Steve Northover CLA 2005-03-31 15:49:59 EST
Here is the situation.  There was a bug in the UI in 3.0 where the UI told us 
that it was using spaces but really tabs were used.  Billy confirmed this.  
Then sometime between M5 and M6, something was fixed such that M6 now uses 
spaces and matches the UI.

The problem is that changing from tabs to spaces is a big deal and leads to 
mixed formatting conventions.  I suggest that for M6 we put it back to tabs 
and resolve the issue for M7.  That way, people who are using Eclipse won't 
have the same problem that SWT has (ie. edit and release for a few days, 
notice that spaces are being used and then have files with mixed tabs and 
spaces).

Adding McQ for his opinion.
Comment 19 Mike Wilson CLA 2005-03-31 16:02:10 EST
My view is this:
  The default value should remain what it was in M5 (i.e. tabs). If the configuration gui incorrectly 
displayed the default as use spaces, it should be fixed to indicate that tabs are being used. Doing 
anything else potentially causes a huge amount of existing code to (unknowingly to the user) be littered 
with mixed whitespace. This is essentially a breaking change.

  Whether or not the change would align our code formatter better with Sun's coding conventions, we 
can not make this kind of change without making the community thoroughly aware of the situation, 
and getting their buy-in.

  Given the contentious nature of this issue, please either make Tabs be the default for M6 (and discuss 
afterwards) or escalate to the PMC.

Comment 20 Olivier Thomann CLA 2005-03-31 16:17:45 EST
We will change the Java conventions to use TAB instead of SPACE.
This will fix this immediate problem.

This will be reviewed post M6 to find a better solution.
Comment 21 Dirk Baeumer CLA 2005-03-31 17:50:13 EST
JDT/UI has to upgrade the profile version number to make sure that workspaces
touched with a misbehaved version of Eclipse will function correctly again.
Comment 22 Olivier Thomann CLA 2005-03-31 20:42:40 EST
Verified in I20050331-2000
Comment 23 Dirk Baeumer CLA 2005-04-01 04:48:21 EST
Unfortunately, the fix we put in makes Steve happen but causes trouble for
clients which explicitly choose the Java convention profile. With the fix those
user would get tabs again instead of space, which is wrong as well.

We tracked down when we have introduced the problem and it went in I20050329-1615. 

So we propose the following:

- to make sure that we don't break clients using M5 or earlier we revert our
  changes back
- we will add a new profile which is called Eclipse. This profile is equal to
  the Java Convention profile except that it uses tabs instead of spaces.

Unfortunately, we can't automatically fix up workspace which where opened using
build I20050329-1615 up to I20050331-2000. Those that have used this build and
didn't have an own comment formatter profile and therefore relied on the fact
that Java conventions is using tabs instead of spaces (as it is defined) will
have to switch to the new Eclipse profile manually.
Comment 24 Steve Northover CLA 2005-04-01 07:42:02 EST
Dirk, can you provide a URL that describes the Java Convention?  Thanks.
Comment 25 Dirk Baeumer CLA 2005-04-01 07:58:20 EST
Here it comes http://java.sun.com/docs/codeconv/.

Steve just to clarify. The new profile will give you exactly the same behaviour
you had under M5. However, there are rooms for improvements down the road if we
can agree on more specific Eclipse coding conventions.
Comment 26 Steve Northover CLA 2005-04-01 08:01:04 EST
Sounds good.
Comment 27 Martin Aeschlimann CLA 2005-04-01 08:49:50 EST
changes in jdt.ui released > 20050401
Reviewed by Dirk and Tom

Comment 28 Olivier Thomann CLA 2005-04-01 10:05:53 EST
Changes reviewed. Looks good.
Fixed and released in HEAD.
Comment 29 Olivier Thomann CLA 2005-04-01 13:08:48 EST
Verified in I20050401-1205.
Comment 30 Steve Northover CLA 2005-04-26 11:40:42 EDT
The default is spaces again in the latest builds.
Comment 31 Tom Hofmann CLA 2005-04-26 12:17:17 EDT
not reproducable with I20050426
Comment 32 Steve Northover CLA 2005-04-26 12:50:05 EDT
VI, didn't you see this too?
Comment 33 Veronika Irvine CLA 2005-04-26 13:51:00 EDT
I saw this with an existing workspace.  Tried with a brand new workspace and 
did not see the problem.
Comment 34 Steve Northover CLA 2005-04-26 14:37:20 EDT
Silly me ... closing.