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

Bug 319532

Summary: [preference][typing] Allow to disable smart auto-indent on return
Product: [Eclipse Project] JDT Reporter: Dani Megert <daniel_megert>
Component: TextAssignee: Rajesh <rthakkar>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: aclark.xyz, deepakazad, markus.kell.r
Version: 3.4   
Target Milestone: 3.7 M2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fix
daniel_megert: review-
Fix
none
Fix
daniel_megert: review-
Fix daniel_megert: iplog+, daniel_megert: review+

Description Dani Megert CLA 2010-07-12 07:01:06 EDT
We should allow to disable smart auto-indent when hitting return. The alignment to the above line (first indent) should still happen.

See bug 250594.
Comment 1 Alex Clark CLA 2010-08-23 12:08:51 EDT
Forwarding from an email to Dani Megert:

From what I gathered from the BugZilla, you had pretty much agreed to
implement some kind of equivalent to having the "Smart Insert Mode"
being off by default... and then changed your mind. I have been
looking around in Helios 3.6, and there doesn't seem to be anything
different.

Is there any reason for this? I mean, considering that eclipse has
about 10,000 configurable options, and the feature that I (and
many others) want is already a menu option, a single extra bit of
information to make it default to the desired state seems pretty
reasonable.

If there's nothing that could be done about it, is there any chance
that you could recommend a way to make a personalised copy of Eclipse
where the feature is compiled out? I haven't looked in the Eclipse
source code, but one might imagine that there could be a line
something like 'addMenuItem("Smart Insert Mode",true)'. Would that
approach be realistic, or is it much more complex?

Thanks,
Alex.
Comment 2 Dani Megert CLA 2010-08-24 08:02:55 EDT
>From what I gathered from the BugZilla, you had pretty much agreed to
>implement some kind of equivalent to having the "Smart Insert Mode"
>being off by default...
No, I did not. The agreement was to not do this (that's why the bug is closed as WONTFIX) but instead a new preference that allows to disable auto-indent on return (this bug here). You agreed to that in bug 250594 comment 6.

We could provide this for 3.7 if that helps.

>If there's nothing that could be done about it, is there any chance
>that you could recommend a way to make a personalised copy of Eclipse
>where the feature is compiled out? 
You don't need to make a copy. You could write a small plug-in that adds a part listener and each time an editor is opened you check whether it's an ITextEditorExtension3. If so, you call ITextEditorExtension3.setInsertMode(ITextEditorExtension3INSERT) on it.
Comment 3 Rajesh CLA 2010-08-27 02:22:34 EDT
Created attachment 177587 [details]
Fix

Adds a preference to the Typing page to enable/disable smart indent on New Line. If disabled, it still indents to previous line. I think it might also make sense to add a note to the Indentation page under Formatter to indicate that many of those preferences depend on this Typing page preference.
Comment 4 Dani Megert CLA 2010-08-30 06:23:19 EDT
Comment on attachment 177587 [details]
Fix

This patch is not good: it doesn't compile on my machine.
Comment 5 Rajesh CLA 2010-09-02 01:26:29 EDT
Created attachment 178016 [details]
Fix

Sorry about the compile issue - working on multiple patches in some common set of files got me all confused :)
Comment 6 Rajesh CLA 2010-09-02 02:44:10 EDT
Created attachment 178018 [details]
Fix

Did some optimization.
Comment 7 Dani Megert CLA 2010-09-02 09:31:52 EDT
The patch breaks auto-indent out of the box.

Also, I don't like to introduce a new group for just one option. I suggest we put it into one of the existing groups by renaming the group. Suggestions?
Comment 8 Rajesh CLA 2010-09-02 12:09:42 EDT
(In reply to comment #7)
> The patch breaks auto-indent out of the box.
I guess you mean that the default setting for this preference should be true?

> 
> Also, I don't like to introduce a new group for just one option. I suggest we
> put it into one of the existing groups by renaming the group. Suggestions?
We could rename 'Tabulators' to 'Smart Indent' and have 2 preferences - 'On new line' and 'Tab key adjusts indentation of current line'.
Comment 9 Dani Megert CLA 2010-09-03 02:21:40 EDT
>I guess you mean that the default setting for this preference should be true?
I simply mean that auto-indent no longer works for me ;-). Any reason you chose the default that way?

>We could rename 'Tabulators' to 'Smart Indent' and have 2 preferences - 'On new
>line' and 'Tab key adjusts indentation of current line'.
Sounds good, except that I would rename it to 'Indentation':
[Indentation]
[ ] Enter key adjust the indentation of the next line
[ ] existing pref
Comment 10 Rajesh CLA 2010-09-03 03:41:10 EDT
Created attachment 178124 [details]
Fix

(In reply to comment #9)
> >I guess you mean that the default setting for this preference should be true?
> I simply mean that auto-indent no longer works for me ;-). Any reason you chose
> the default that way?
I had basically missed choosing the default at all.
Comment 11 Dani Megert CLA 2010-09-03 05:24:58 EDT
Patch is good. Adjusted wording of preference a bit.
Committed to HEAD.
Available in builds >= N20100903-2000.
Comment 12 Dani Megert CLA 2010-09-14 08:52:38 EDT
Filed bug 325242 to update the documentation for the 'Typing preference page'.