Details
-
Type:
New Feature
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.1Release
-
Fix Version/s: 2.0.2Release
-
Component/s: Editor
-
Labels:None
-
Environment:Mac OS 10.6.3
-
Patch Submitted:Yes
-
Number of attachments :
Description
The Eclipse Java editor has a feature (and setting) "When pasting, adjust indentation", which seems to be turned on by default. Because the Groovy editor does not support this feature, our developers always encountered inexplicable problems when pasting Groovy code, and reasoned that pasting in Groovy is broken. Since this is a very handy feature, it would be great if the Groovy editor supported this feature as well if turned on in the Java settings.
Example:
def doit() {
def x = 10
def y = 20
}
Select the two lines with variable definitions starting from column 1, then cut. Move the cursor after {, hit return, and paste. In the Java editor, the two lines will be indented as before. In the Groovy editor, the result is this:
def doit() {
def x = 10
def y = 20
}
Hi Peter,
Thanks for submitting this. I'm aware of the problem. But it is good to know what issues people care about.
Right now when you paste text into the Groovy editor it simply pastes your text "as is".
Unfortunately it is not as easy as just turning on smart paste features. The smart paste features inherited
from JDT just don't work right when you paste in Groovy code. So I've turned this off completely. I figured
that it is better to just paste the text "as is" than to have rather impredictable incorrect "magic" adjustment
to indentation. Paste may not magically adjust indentation now, but at least, in some sense it is predictable
since it pastes exactly the text that was copied (including spaces).
Properly implementing smart paste as it works in Java will be tricky. But I hope to do it eventually.
In the mean time, perhaps there are some simple things that could be done that are less sophisticated but may help.
For example, we could try to preserve indentation of pasted text minus leading white space, relative to the paste point
(rather than preserve text as is, what we do now).
I think this would not be as hard to implement as full on autoindentation on paste, would be fairly predictable,
and would put the code in the right place if the following conditions are met:
I could experiment with that a little if you think this might help alleviate the complaints of your developers.