Bug 3348 - DCR: Code formatter enhancement (1GIYHQR)
Summary: DCR: Code formatter enhancement (1GIYHQR)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:53 EDT by Erich Gamma CLA
Modified: 2002-01-16 07:35 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2001-10-10 22:53:38 EDT
EG (24.08.2001 11:26:37)
	from EC:
> > - When I set the Code Formatter to not use tab representation it still
> > sometimes inserts tabs. Is this a known problem?
> no, can you provide us with more details, so that we can track this as a
> problem report.
>


[in another ide] opening the Java file I am
editing and  using CTRL-SHIFT-8 to display blanks and tabs (a nice feature):
I will use '-' for a blank below and '=' for a tab. Here is the scenario.

I start with:
--protected void finalize() throws Throwable {
----FinalizeAddin();
--}

Now I put the cursor right after the opening brace {, hit enter and
start typing "//test" followd by a CTRL-S to save the file. I get:

--protected void finalize() throws Throwable {
--#//test
----FinalizeAddin();
--}

The CodeFormatter has no checkmarks except for
'Insert a newline inside an empty block' shouldn't matter.
The amount of spaces representing a tab is set to 2 and 'maximum line
length' is 80.

Since 'Indentation is represented by tab' is unchecked I would
expect to see:
--protected void finalize() throws Throwable {
----//test
----FinalizeAddin();
--}

NOTES:
Comment 1 Olivier Thomann CLA 2001-10-29 17:15:35 EST
The code formatter is not involved in this extra tab added at the beginning of 
the line when a carriage return is pressed. This looks like a feature of the 
Java Editor.
I don't see what I can change in the code formatter to change this behavior. If 
you format the source that contains tabs and spaces, the tabs are converted to 
the right number of spaces.
Suggest to move to JUI.
Comment 2 Olivier Thomann CLA 2001-10-30 14:07:27 EST
Moved to JUI. The problem seems to come from a feature in the Java editor.
Comment 3 Erich Gamma CLA 2001-10-30 15:57:58 EST
The tab is indented by the auto indent mechanism.
The Java editor doesn't support using white spaces instead of tabs.
We should remove the code formatter feature to use white space for tabs until 
the editor honors it. Otherwise it is too confusing to users.
This is a change to the formatter preference page.
Comment 4 Martin Aeschlimann CLA 2001-10-31 02:57:40 EST
it's simple to change the JavaAutoIndentStrategy to honor the formatter 
settings.
What should I change?
Comment 5 Erich Gamma CLA 2001-10-31 03:24:01 EST
Fixing auto indent to honor the formatting option is good and we should fix it 
as you suggest.

However, what do we do with leading tabs manually inserted by the user?

The formatter will change them to blanks as well and the user
would expect the same when this formattig option is set. 
Comment 6 Martin Aeschlimann CLA 2001-10-31 03:29:48 EST
The auto indenter just copies the previous indent and avoids to do any counting 
of indention. I would leave it like that.
Comment 7 Erich Gamma CLA 2001-10-31 03:51:18 EST
I agree that the auto indenter strategy should not change. It is doing the 
right thing.

However, a user can still create indents manually by inserting tabs. The code 
formatter will treat them as leading tabs and replace them with spaces.

What I wonder is whether this formatter options implies that tabs should be 
replace with spaces.
Comment 8 Martin Aeschlimann CLA 2001-10-31 11:49:27 EST
changed the JavaAutoIndentStrategy
fix > 110025
Comment 9 Andre Weinand CLA 2002-01-16 07:35:47 EST
Verified: User-created tabs are left as tabs. Additional indents are added as 
spaces if 'Indentation is represented by tab' is unchecked.