| Summary: | [typing] Java Editor produces whitespace garbage | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Alexander Veit <lbloom> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Alexander Veit
Could you please add concrete examples/bug reports where you see this happening and also tell us which build. Set bug resolution from REMIND back to open once you added this information. The phenomenon can be studied in Eclipse versions from about 2.0 up to the
latest Builds.
As a rule of thumb, the higher the source file's revision number is, the more
of this ws gets into it. It spawns like rabbits :-)
A simple example:
class A
{
void f()
{
Object l_obj;| <- The caret is here. Now press <return>.
}
}
=>
class A
{
void f()
{
Object l_obj;
_______<- Eclipse has inserted whitespace for indentation (indicated by _) here
}
}
Now once again hit <return>.
The inserted whitespace will stay on the empty line forever unless you delete
it by hand or you open the file in an editor thet strips off trailing
whitespace on each line.
Here are some of my code formatter properties:
org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.newline.emptyBlock=do not
insert
org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.lineSplit=120
org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=m_
org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.newline.openingBrace=insert
org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=w
arning
org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.newline.controlStatement=ins
ert
org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.space.castexpression=do not
insert
void f()
{
Object l_obj;
_______<- Eclipse has inserted whitespace for indentation (indicated by _) here
}
}
Now once again hit <return>.
Would you expect this:
void f()
{
Object l_obj;
<no spacing>
<caret at beginning of line>
}
}
And then you manually add the Tab or it jumps autmatically to the correct
indentation when typing? The first solution is not "smart typing" and the other
one would be too noisy in the UI.
If you don't like the smart mode you can change it by pressing "Insert" key or
clicking on "Smart Insert" in the status field. You will then get the normal
I-caret and smartness will be gone i.e. no spaces will be inserted.
... Now once again hit <return>.
What I would expect is
class A
{
void f()
{
Object l_obj;
<no spacing>
<caret at the correct indentation position>
}
}
A less sophisticated solution for the problem would be to strip trailing
whitespace from the end of each line when saving the source file.
|