Escape Quote Placed Automatically in String? Why ?

Hello
Newest PHPStorm 10 does some bad UI .

When trying to copy strings, escape characters are placed automatically on quotes. Why ??
Please help disable this behaviour.

It was not like this in earlier phpstorm versions.
I placed screenshots to better understsand

Screen Shot 2015-11-04 at 6.12.15 PM.png

Screen Shot 2015-11-04 at 6.12.34 PM.png

21 comments
Comment actions Permalink

Hi there,

It was not like this in earlier phpstorm versions.

It's a new functionality introduced in v10. It is still work in progress so bugs (situations where it works wrong) are possible.

Considering how this feature supposed to work, in your particlar case it actually rather a correct behavior -- you are copying text from outside of the string literal but inserting it inside the string, hence the escaping.

Other than that: I may only suggest to submit bug report to the Issue Tracker.

Please help disable this behaviour.

Please use "Paste Simple" instead of ordinary "Paste".

NOTE: You may change default shortcut to something more shorter/convenient or even swap these paste commands around in "Settings/Preferences | Keymap"

0
Comment actions Permalink

In this case yes, but it's just a demo.

What if I need to replace the track-name ( which is a more common case )  ?

This must have an option to be disabled!

1
Comment actions Permalink

I second this. For me I believe it should be disabled by default.

Not sure why something copied from my own code without escaped quotes would add in escaped quotes when it's not needed. Causing extra work.

4
Comment actions Permalink

I'm glad you brouth this up, it's been slowing me down ever since I upgraded to ver10.  Please please disable this as it's always incorect usage after escaping and I have to go in and remove all of them after each paste.  time consuming and introduces possible bugs in my code.

2
Comment actions Permalink

I need to disable this option, it generates an incorrect code, especially when I do a drag & drop ...
Please tell me how to have a normal paste if you have a solution ...

0
Comment actions Permalink

Please try Ctrl+Alt+Shift+V

1
Comment actions Permalink

Thank you for your quick reply, but I had already read the previous posts :)
The drag & drop + CTRL uses a normal paste, not a keyboard shortcut.
It automatically escapes the characters dropped, is not it ?

0
Comment actions Permalink

Too bad Jet Brains doesn't make more keys to type in to copy and paste.. I mean Ctrl-v is just to simple.. Glad they made it Ctrl+Alt+Shift+V we're programmers we love remembering pointless extra keystrokes.. heck, make it even more challenging on future releases.. I have 10 fingers, you all should make us type at least 10 keys simultaneously just to teach us a lesson not to want to paste existing code to new areas..

0
Comment actions Permalink

never mind. Thank you that even

0
Comment actions Permalink

You can customize this in File | Settings | Keymap, i.e. assign "Paste simple" on Ctrl-V combination.

1
Comment actions Permalink

Always not. a concrete example.
The following code:
$A = 'ex 1';
$B = 'ex 2';
$C = 'ex 3';
$D = ...
If I want transform variables into a simple array :
1) Place the cursor between "$" and "A"
2) type «['»and select this typing
3) Simultaneous with the CTRL key, drag and drop it on the second row, then the third, etc.
Personally, I get :
$['A = 'ex 1';
$[\'B = 'ex 2';
$[\\'C = 'ex 3';
$[\\'D = ...

But in this case, I need a simple drag &  drop text. It's possible ?

0
Comment actions Permalink

@JUSTAMENTE LAURENT

In your particular case it looks like it would be easier to use Multiple Carets instead to make editing in few places simultaneously.

0
Comment actions Permalink

Thank you for your reply.
I was hoping an option to disable the automatic escape special characters for simple paste and/or drag & drop...
Never mind.

0
Comment actions Permalink

A scenario where this cannot be fixed by the simple-paste method is Live Templates. I have a live template that contains quotes which are escaped as soon as the template is inserted but I don't want that behavior. Can I stop it happening?

Example, replace text with gettext function call:

echo '<p>Hello World!</p>';

Live template: ' . _("Hello World!") . '

Result: echo '<p>\' . _("Hello World!") . \'</p>';

0
Comment actions Permalink

Websupport, What is the context set for this live template? I can't reproduce that in PHP. Please record a screencast that will include both the live template and how you invoke it.

0
Comment actions Permalink

@Eugene Morozov - thanks for your help, (I'm "Websupport" using a new account).

Have you tried the exact code above? It only occurs when applying the live template inside HTML in PHP. It works fine when just in HTML or in a PHP string without HTML tags. The template is stored in the "user" group and applied to HTML and PHP.

0
Comment actions Permalink

Incidentally, I have a workaround that involves removing the quote at the start of the template and typing a quote directly before I invoke the template:

"_qq[tab]

This stops the escaping from occurring.

 

0
Comment actions Permalink

Looks like this is related only to single quotes.

If we use template like

" . _("$TEXT$") . "

it expands fine in the same conditions.

Submitted https://youtrack.jetbrains.com/issue/WI-42972 - please vote for it with thumb up button.

0
Comment actions Permalink

@Vladimir Luchansky- I see it with both single and double quotes. As shown in my previous screenshot...

0
Comment actions Permalink

Please feel free to add it as in a comment to https://youtrack.jetbrains.com/issue/WI-42972

 

0

Please sign in to leave a comment.