Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 63520

Summary: [typing] Smart cursor positioning fails on indentation by spaces
Product: [Eclipse Project] JDT Reporter: Pawe&#322; Sakowski <pawel>
Component: TextAssignee: Tom Hofmann <eclipse>
Status: RESOLVED DUPLICATE QA Contact:
Severity: trivial    
Priority: P3 CC: daniel_megert
Version: 3.0   
Target Milestone: 3.0   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Pawe&#322; Sakowski CLA 2004-05-22 08:22:56 EDT
My Java Editor settings:

Displayed tab width: 4
Insert spaces for tabs: checked

Take the following Java file:

package foo;

class Test {
    void method() {
}

When I position the cursor after the method's opening brace and press Enter, two
new lines are added:
- 8 spaces
- 4 spaces, "}"

Which is right. However, the cursor gets positioned after the 5th space, not the
8th one.
Comment 1 Dani Megert CLA 2004-05-24 03:43:03 EDT
Tom, please comment
Comment 2 Tom Hofmann CLA 2004-05-24 12:36:42 EDT
reproducable, should fix for 3.0
Comment 3 Tom Hofmann CLA 2004-05-24 12:47:44 EDT
the reason is once more the preference split for indentation between the
formatter and the editor:

If you set the formatter preference to *not* use the Tab character for
indentation (Java->Code Style->Code Formatter, edit your profile), everything
works as expected.

Currently, the JavaAutoIndentStrategy tries to insert 4 spaces (the indentation
of the previous line) plus one Tab (the indentation unit according to the
formatter). However, the tab is converted to spaces by the editor. The new caret
offset is still set to 5 since the auto-indenter does not know about the conversion.
Comment 4 Tom Hofmann CLA 2004-05-28 04:06:22 EDT

*** This bug has been marked as a duplicate of 19036 ***