Community
Participate
Working Groups
PHP Development Tools (PDT) SDK Feature 3.0.0.v20110516-1100-77--84_23JBVgSVXO7XGJz0VLa9O org.eclipse.php.sdk.feature.group Eclipse.org Cut and paste is yielding unusual results, namely, the paste operation seems to be running some sort of formatting over the pasted text to adjust the indenting. As simple example is to copy-paste a standard Docblock, eg: /** * Method to translate a text string with inputs to the output buffer. * * @param string The language string to translate. * @return integer The length of the translated string. * @since 1.0 */ The result is: /** * Method to translate a text string with inputs to the output buffer. * * @param string The language string to translate. * @return integer The length of the translated string. * @since 1.0 */ Note, the stars are aligned with the slash on the first line, not the first star on the first line. That's a simple example, it gets even worse with PHP code.
hi, we auto format the php code/comment when user paste it,and we have fixed the above issue in the latest code(head). Hope you try our nightly build to see if it is ok for you!
Another example: function x() { if ($x == 1) { $x = 1; } } becomes: function x() { if ($x == 1) { $x = 1; } } Do you think this will be fixed in an official release any time soon? I'm hesitant to start working off the nightly builds.
(In reply to comment #2) > Another example: > > function x() { > if ($x == 1) { > $x = 1; > } > } > > becomes: > > function x() { > if ($x == 1) { > $x = 1; > } > } > > Do you think this will be fixed in an official release any time soon? I'm > hesitant to start working off the nightly builds. hi, When I paste: function x() { if ($x == 1) { $x = 1; } } I get(I set "Tab policy" to "tab" ): function x() { if ($x == 1) { $x = 1; } } if I set "Tab policy" to "spaces" and "Indentation size" to "3",I get: function x() { if ($x == 1) { $x = 1; } }
In the Indigo release version or the nightly build? I'm using the release.
so I think you use an old version of pdt,you can try pdt's newest nightly build:https://hudson.eclipse.org/hudson/job/cbi-pdt-3.0-indigo/166/artifact/build/N201107150957/pdt-Update-N201107150957.zip
Is there any way to disable this paste formatting feature? This really sucks... i've installed the nightly build but it still is formatting wrongly
(In reply to comment #6) > Is there any way to disable this paste formatting feature? This really sucks... > i've installed the nightly build but it still is formatting wrongly hi, This is called smart paste,but I could not find where to disable it in UI:( I will try to add it later
I confirm the bug... Is it something easy to fix, because it also totally breaks content of multiline string for example, adding/removing (as it wishes) tabs on each line.
Please fix it! Or just allow us switch this "smart" paste off!
Zhao, This has a big impact on efficiency, please fix these issues and provide a stable release as soon as possible. Here is another simple example: $x = array( 'one' => array( 1 => 2 ), 'more' => 'here' ); Results in: $x = array( 'one' => array( 1 => 2 ), 'more' => 'here' ); *Also*, if you do something like this: $x = $y->z( 'abc' ); Put your cursor in front of the 'abc' and hit tab, and it'll insert a tab instead of 4 spaces (as configured). I have the following preferences: /instance/org.eclipse.ui.editors/spacesForTabs=true /instance/org.eclipse.php.core/org.eclipse.php.core.phpForamtterUseTabs=false /instance/org.eclipse.php.core/org.eclipse.php.core.phpForamtterIndentationSize=4 This is Eclipse Version: 3.7.1 and PDT 3.0.0.v20110516.
Please create a fix for this issue. I have always had problems with the way Eclipse does indentation when pasting code. My usual problem is the one mentioned here (I think): https://bugs.eclipse.org/bugs/show_bug.cgi?id=279358 - This is easy and quick to fix (but still a bit annoying). But this new problem is seriously annoying and takes long time to fix (e.g. if you paste a function with 100 lines of code or more).
(In reply to comment #11) > Please create a fix for this issue. I have always had problems with the way > Eclipse does indentation when pasting code. My usual problem is the one > mentioned here (I think): https://bugs.eclipse.org/bugs/show_bug.cgi?id=279358 > - This is easy and quick to fix (but still a bit annoying). > > But this new problem is seriously annoying and takes long time to fix (e.g. if > you paste a function with 100 lines of code or more). BTW I'm using Version: 3.7.1 Build id: M20110909-1335. PHP Development Tools (PDT) All-In-One SDK 3.0.0.v20110516-1100-77--7C91A5Ad77OH_pV_hSBYHKz0
A similar issue seems to be that if I copy paste multiple lines the line ending is modified. In my case a carriage return (\r) is added to the line end, even if the configuration says use only new line (\n). The strange thing is, that if I replace existing code - this means any visible char, the indent and the line ending are properly maintained. But if I simply paste onto a new line everything is messed up. Thus I ended up to write always a dot, and replace it on paste... Tested with the latest indigo nightly (build #300).
The latest nightly build (https://hudson.eclipse.org/hudson/job/cbi-pdt-3.0-indigo/327) seems to fix some of the copy / paste issues. Many thanks @zzhongwei!!
This is still happening in Juno (4.2.0). Very annoying.
I am yet to see a feature in any software project that has the word "smart" in it and doesn't annoy some of its users, "smart paste" is no exception. Please fix this or/and allow us to disable this so called "smart paste". thanks.
Try this, it worked for me. open workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs add "smartPaste=false" at the end save & restart eclipse
Agreed; this behavior is annoying and slows me down more than any other UI bug I've experienced. Tony Vermeiren, taking that measure does not change the behavior in my case. Reproducing this bug is as simple as copy/pasting any array. For example: Copying this code return array( 'success' => TRUE, 'data' => $r, ); and pasting it yields return array( 'success' => TRUE, 'data' => $r, ); Version: Juno Service Release 1 Build id: 20121004-1855
I just tried all code samples in this bug and see that they're formatted properly when pasted to PHP editor. I tried with nightly build from http://download.eclipse.org/tools/pdt/updates/nightly (In reply to comment #18) > Copying this code > > return array( > 'success' => TRUE, > 'data' => $r, > ); > > and pasting it yields > > return array( > 'success' => TRUE, > 'data' => $r, > ); this is correct default behavior of PHP formatter. Default setting is indent with tabs using size 2 (=insert 2 tabs). Please adjust it to what is your preference. I'm marking it as FIXED. Please comment if you disagree. Thanks!
Jacek, thank you! You are absolutely right; changing the "Default indentation for array initializers" from 2 to 1 caused Eclipse to behave "as expected". I wonder why the default is 2; maybe this value is aimed more at users who prefer spaces over tabs. In any event, thank you for setting the record straight!
For those that have trouble finding the preferences, in PDT see: PHP > Code Style > Formatter > Default indentation for array initializers
I find myself returning to this report some months later; I was trying to remember how to disable this most annoying "feature" in a new Eclipse installation. It took me a while to fully realize that there are two separate behaviors here that contribute to my frustration around default PHP code formatting in Eclipse: Smart Paste and Default indentation for array initializers being set to 2 (instead of 1). The comment from Tony Vermeiren 2012-10-05 07:18:31 EDT does indeed work for disabling Smart Paste; thank you, Tony. And "b d", thanks for pointing-out the array initializers setting within the GUI; that was most helpful.
OK, I'm glad this smartPaste thing can be turned off, but can this really be considered "fixed" if there's no GUI for it? You can't expect users to go digging into bug reports for such a basic problem. This is still happening in Eclipse 4.4.1 with PDT 3.3.1.
(In reply to Jacob Weber from comment #23) > OK, I'm glad this smartPaste thing can be turned off, but can this really be > considered "fixed" if there's no GUI for it? You can't expect users to go > digging into bug reports for such a basic problem. This is still happening > in Eclipse 4.4.1 with PDT 3.3.1. What you mean by "no GUI for it" ? GUI to disable/enable: Preferences -> PHP -> Editor -> Typing -> Adjust indentation GUI to define indentation: Preferences -> PHP -> Code Style -> Formatter -> Edit -> Indentation If indentation is invalid, should be reported as new bug.
Sorry, didn't realize that "Adjust indentation" was the same thing as smartPaste.
Yes - "Adjust Indentation' is in the section titled 'When pasting'. I'm closing this bug as it's been set as Fixed for more than 2 years and I could not reproduce any of the above given examples. If someone disagree or have issues please reopen with a concrete description or open a new bug.