Paste hell - how to stop Idea from inserting \n in strings?

Hi folks,

I'm trying to figure out how to stop Idea from inserting \n in strings which span multiple lines. Breaking up the string with "" + "" is fine, but inserting "\n" + "" is just wrong as now its breaking up stuff that is supposed to be on the same line.

37 comments
Comment actions Permalink

I think the current behaviour is pretty correct. If you press <![CDATA[]]> inside a string the string is separated without inserting a newline. But if you paste a string which contains already newlines then these newlines are also inserted. This may be wrong in some cases, but most of the time it's exactly what I want.

0
Comment actions Permalink

It annoys me a lot that Idea now escapes escape character on paste - the
result is that I can't paste any string with escape characters in it. I wish
this mode was optional


"Gregory Pierce" <no_mail@jetbrains.com> wrote in message
news:22529380.1064344219016.JavaMail.itn@is.intellij.net...

Hi folks,

>

I'm trying to figure out how to stop Idea from inserting \n in strings

which span multiple lines. Breaking up the string with "" + "" is fine, but
inserting "\n" + "" is just wrong as now its breaking up stuff that is
supposed to be on the same line.


0
Comment actions Permalink

Martin Fuhrer wrote:

I think the current behaviour is pretty correct.


I agree ... knowing IDEA's behaviour - problems can be easily avoided.

0
Comment actions Permalink


Alex Roytman wrote:

It annoys me a lot that Idea now escapes escape character on paste - the
result is that I can't paste any string with escape characters in it. I wish
this mode was optional


Same here. My suggestion is basically to put the escaping into a seperate
undo step so that I can undo it independently from the paste. I think that
would work fairly well in most cases.

I've mentioned this in these SCRs that deal with string paste problems but didn't
file a 'real' one for it yet.
http://www.intellij.net/tracker/idea/viewSCR?publicId=16849
http://www.intellij.net/tracker/idea/viewSCR?publicId=11689

Sascha


0
Comment actions Permalink

Sascha Weinreuter wrote:

Alex Roytman wrote:

>>It annoys me a lot that Idea now escapes escape character on paste - the
>>result is that I can't paste any string with escape characters in it. I wish
>>this mode was optional


Same here. My suggestion is basically to put the escaping into a seperate
undo step so that I can undo it independently from the paste. I think that
would work fairly well in most cases.


That is essentially what M$ Word does when it automatically changes something.
For instance, with some commonly mistyped words it will autocorrect for you.
Sometimes the word is mispelled on purpose (i.e. documenting common mistakes in
another document). Entering the undo command (Ctrl-Z) will undo the autocorrect
the first time, and a second time will undo the typing.


I've mentioned this in these SCRs that deal with string paste problems but didn't
file a 'real' one for it yet.
http://www.intellij.net/tracker/idea/viewSCR?publicId=16849
http://www.intellij.net/tracker/idea/viewSCR?publicId=11689

Sascha


0
Comment actions Permalink

No, the behavior is wrong. There were no special characters in the original string - there shouldn't be any in the final string unless I ask for them. There mere fact that I have to go behind Idea and remove them suggests that this behavior at best needs to be an option that can be removed in the Options.

Idea in the past has never gotten in the way of getting work done until now.

0
Comment actions Permalink

I would be more inclined to suggest that it paste the text as normal since that is what every application EXCEPT Idea does and add an intention for strings that span multiple lines such that you can have it break the string as "" + "" or "\n" + "".

The strings I'm dealing with in particular are very long URLs that simply won't fit on one line going into an HTML generator. I cannot express in words how painful it has been to debug when Idea keeps inserting characters into the URLs that I need to post!

0
Comment actions Permalink


Gregory Pierce wrote:

I would be more inclined to suggest that it paste the text as normal since that is what
every application EXCEPT Idea does and add an intention for strings that span multiple
lines such that you can have it break the string as "" + "" or "\n" + "".

The strings I'm dealing with in particular are very long URLs that simply won't fit on one
line going into an HTML generator. I cannot express in words how painful it has been to
debug when Idea keeps inserting characters into the URLs that I need to post!


Well, I agree that for some users the - let's call it "Smart Paste" - should be
optional because it is non-standard behavior. On the other hand, IDEA
already introduced some non-standard concepts that work pretty well,
so I think it there's no real need to make everything optional as long as it
doesn't interfere with what a user intends to do.

For me I'd say that in the majority of cases (at least for me) the escaping is
what I'd expect (if it works right). In all other cases it is a real pain though
and the ability to undo IDEA's smart action would suffice for me.

The intention to break strings that contain newline sequences is independent
from that because it would be useful for any kind of strings, not just pasted
ones.

Sascha


0
Comment actions Permalink

Well, it seems I have the things completely messed in my head.
We can do "Smart Paste" undoable but this is not what Gregory wants!

Let see a sample case:
Content in the clipboard:
<![CDATA[ Link line1 Link line2 Link line3 ]]>

Pasting into System.out.println("|");

where | denotes caret position.

Smart version:
<![CDATA[ System.out.println("Link line1\n" + "Link line2\n" + "Link line3\n" + "" ]]>


Normal version:
<![CDATA[ System.out.println("Link line1 Link line2 Link line3 " ]]>

Which is syntactically incorrect all highlighted in red and needs IMO much
more manual modification than just removing unneded \n's

Please note the intention behind "smart" paste is simple as 1, 2, 3: If
pasted into System.out.print("|") one will print out exactly the same
content as have been pasted!

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:bksem0$b1a$1@is.intellij.net...
>

Gregory Pierce wrote:

I would be more inclined to suggest that it paste the text as normal

since that is what

every application EXCEPT Idea does and add an intention for strings that

span multiple

lines such that you can have it break the string as "" + "" or "\n" +

"".
>

The strings I'm dealing with in particular are very long URLs that

simply won't fit on one

line going into an HTML generator. I cannot express in words how painful

it has been to

debug when Idea keeps inserting characters into the URLs that I need to

post!
>

Well, I agree that for some users the - let's call it "Smart Paste" -

should be

optional because it is non-standard behavior. On the other hand, IDEA
already introduced some non-standard concepts that work pretty well,
so I think it there's no real need to make everything optional as long as

it

doesn't interfere with what a user intends to do.

>

For me I'd say that in the majority of cases (at least for me) the

escaping is

what I'd expect (if it works right). In all other cases it is a real pain

though

and the ability to undo IDEA's smart action would suffice for me.

>

The intention to break strings that contain newline sequences is

independent

from that because it would be useful for any kind of strings, not just

pasted

ones.

>

Sascha

>
>


0
Comment actions Permalink


Maxim Shafirov (JetBrains) wrote:

Well, it seems I have the things completely messed in my head.
We can do "Smart Paste" undoable but this is not what Gregory wants!


Oops, yes you're right. But this is IMHO a second aspect of Smart Paste that
converts hard newlines into \n sequences and is independent from the auto-
escaping.

My primary concern was that dealing with already escaped strings is pretty
painful right now and would directly benefit from a seperate undo. I even think
Smart Paste involves three steps:

1. Paste
2. Convert newlines from clipboard into \n
3. Escape protected characters

Step 3 should be undoable and 1+2 together because that exactly resembles the
contents of the clipboard.

Does this sound reasonable or am I dead wrong :) ?


Sascha


0
Comment actions Permalink

1. Seems you've missed surrounding each new pasted line with '" " +'
pattern in your 1, 2, 3 list.
2. Am I right you're suggesting completely ignore newline characters in
clipboard when pasting? This way it gonna be a single long line with no idea
for intention on where to break it or insert \n chars. Let's be a bit more
formal in this discussion.
Well, as far as I understand there are cases when current IDEA's behaviour
is oversmart and annoying and it actually doing something it shouldn't do in
user's opinion.

So would you please provide some samples of such undesired behavior so we
can decide what actually needed in this case and probably find a common
denominator of all cases or some sequence of undoable actions that will
cover all the cases.

Sascha, Gregory?

P.S.: "c:\new" case has been fixed. That wasn't an intention. Just a bug.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:bksjbo$u27$1@is.intellij.net...
>

Maxim Shafirov (JetBrains) wrote:

Well, it seems I have the things completely messed in my head.
We can do "Smart Paste" undoable but this is not what Gregory wants!

>

Oops, yes you're right. But this is IMHO a second aspect of Smart Paste

that

converts hard newlines into \n sequences and is independent from the auto-
escaping.

>

My primary concern was that dealing with already escaped strings is

pretty

painful right now and would directly benefit from a seperate undo. I even

think

Smart Paste involves three steps:

>

1. Paste
2. Convert newlines from clipboard into \n
3. Escape protected characters

>

Step 3 should be undoable and 1+2 together because that exactly resembles

the

contents of the clipboard.

>

Does this sound reasonable or am I dead wrong :) ?

>
>

Sascha

>
>


0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

So would you please provide some samples of such undesired behavior so we
can decide what actually needed in this case and probably find a common
denominator of all cases or some sequence of undoable actions that will
cover all the cases.


Say I have the following code:

<![CDATA[
CAT.debug("AgentInfo properties:\n" + sb2.toString());
throw new ShutdownException("No plugins loaded");
]]>


And I want to move the debug message into the exception message. This is
a contrived example but it's similar to something I've done before where
I was bitten by IDEA's overly smart behaviour.

If I select the text marked by [[]]:

<![CDATA[
CAT.debug("[[AgentInfo properties:\n" + sb2.toString()]]);
throw new ShutdownException("No plugins loaded");
]]>


And select the closing quote of the exception message:

<![CDATA[
CAT.debug("AgentInfo properties:\n" + sb2.toString());
throw new ShutdownException("No plugins loaded[["]]);
]]>


and then Paste, I get the following result:

<![CDATA[
CAT.debug("AgentInfo properties:\n" + sb2.toString());
throw new ShutdownException("No plugins loadedAgentInfo properties:\\n" +
"\" + sb2.toString());
]]>


Note the erroneous escaping of the \n and an extra "\" coming from nowhere.

If however I make the first selection like so:

<![CDATA[
CAT.debug("[[AgentInfo properties:\n" + sb2.toString());]]
throw new ShutdownException("No plugins loaded");
]]>


And make the second selection like so:

<![CDATA[
CAT.debug("AgentInfo properties:\n" + sb2.toString());
throw new ShutdownException("No plugins loaded[[");]]
]]>


When I paste, I get the expected results:

<![CDATA[
CAT.debug("AgentInfo properties:\n" + sb2.toString());
throw new ShutdownException("No plugins loadedAgentInfo properties:\n" + 
sb2.toString());
]]>


Now you might say this is a contrived example, and I would agree with
you, but IDEA's behaviour is still wrong in the first case.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink
<![CDATA[
System.out.println( PageBrowser.browseURL( "http://subscriberdev1/hockey/nhl/scoreboards/nhl_minisco\n" +
"reboard.jsp?FILEDATE=10/9/2002&si_home_team_id=11&sportID=NHL&home_team_id=11&visitingTeam_displayName=Ranger\n" +
"s&visitingTeam_savesPlayer=Jean-Sebastien%20Giguere&JMS_IBM_PutDate=20030923&SPORT=NHL&sport=NHL&PERIOD=3&hom\n" +
"eTeam_saves=24&visitingTeam_goalsAllowed=2.8&code=boxscore&VST_HI_GOALS_AST=25---&STATUS=FINA&homeTeam_leadin\n" +
"gPointsGoals=2&HOME_TEAM_ID=11&JMS_IBM_PutTime=17253784&VSTR_PERIOD2=0&HOME_PERIOD1=0&homeTeam_threeLetterNam\n" +
"e=CAR&JMSXDeliveryCount=1&HOME_HI_GOALS_AST=11-Jeff%20Friesen-2-0-^M&month=9&day=10&VSTR_TEAM_ID=25&VSTR_PERI\n" +
"OD1=0&homeTeam_displayName=Hurricanes&si_vstr_team_id=25&messageType=NHL.boxscore&visitingTeam_losses=0&vstr_\n" +
"team_id=25&JMSXUserID=mqm&FILENAME=NHLBOX2002100907.TXT&HOME_PERIOD2=2&visitingTeam_ties=0&visitingTeam_overt\n" +
"imeLosses=0&source=STATS&VSTR_PERIOD3=0&homeTeam_powerPlayPercentage=14.4&homeTeam_losses=1&homeTeam.runs=3&c\n" +
"ontestID=2002100907&VST_HI_SAVES=25-Jean-Sebastien%20Giguere-22-^M&isAOL=true&visitingTeam.runs=0&JMS_IBM_Put\n" +
"ApplType=26&homeTeam_divisionID=5&visitingTeam_saves=22&substage=1&homeTeam_leadingPointsPlayer=Jeff%20Friese\n" +
"n&HOME_HI_SAVES=11-Martin%20Brodeur-24-&homeTeam_ties=0&MSGTOPIC=CNNSI/NHL/STPERSISTER/STATS/BOXSCORE/25/11&v\n" +
"isitingTeam_goalsPerGame=2.8&visitingTeam_threeLetterName=NYR&si_contestid=2002100907&JMS_IBM_MsgType=8&homeT\n" +
"eam.score=3&homeTeam_savesPlayer=Martin%20Brodeur&SOURCE=STATS&JMS_IBM_Format=MQSTR&period=3&visitingTeam.sco\n" +
"re=0&GAME_DATE=09-10-2002%2000:00&homeTeam_leadingPointsAssists=0&SI_VSTR_TEAM_ID=25&homeTeam_score=3&status=\n" +
"FINA&visitingTeam_powerPlayPercentage=16.3&TIMEREMAIN=0:00&homeTeam_wins=0&SI_CONTESTID=2002100907&HOME_PERIO\n" +
"D3=1&payloadClass=class%20java.util.HashMap&homeTeam_overtimeLosses=0&year=2002&visitingTeam_wins=1&visitingT\n" +
"eam_score=0&homeTeam_goalsAllowed=2.9&SI_HOME_TEAM_ID=11&CODE=boxscore&homeTeam_goalsPerGame=2.1&VSTR_SCORE=0\n" +
"&visitingTeam_divisionID=2&HOME_SCORE=3&JMSXAppID=BROKERDEV1&stage=1&CONTESTID=2002100907\n" ));]]>



I can't get into why, but those \n's cause this particular service to fail something horrible. But since I cannot rewrite that piece of code since I don't own it - I need to get Idea to not put the \n's in there if at all possible.

0
Comment actions Permalink

But as far as I understand the original thing being pasted is just wrong! It
contains newline characters where they can't be like in the middle of the
identifiers! What can I say - "garbage in - garbage out"...

Once again I can't do more that switching ALL smarts off in this case. This
way you'll get the same many lines but without leading " and trailing " +
and espaces in the middle of the query if they happen. I'm affraid this will
require much more manual editing than just removing \n's. Alternatively you
may remove newlines from the clipboard somewhere in the text editor and
repaste proper value.

Am I wrong?

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Gregory Pierce" <no_mail@jetbrains.com> wrote in message
news:26161869.1064428573205.JavaMail.itn@is.intellij.net...

<![CDATA[
> System.out.println( PageBrowser.browseURL(
"http://subscriberdev1/hockey/nhl/scoreboards/nhl_minisco\n" +
>
"reboard.jsp?FILEDATE=10/9/2002&si_home_team_id=11&sportID=NHL&home_team_id=
11&visitingTeam_displayName=Ranger\n" +
>
"s&visitingTeam_savesPlayer=Jean-Sebastien%20Giguere&JMS_IBM_PutDate=2003092
3&SPORT=NHL&sport=NHL&PERIOD=3&hom\n" +
>
"eTeam_saves=24&visitingTeam_goalsAllowed=2.8&code=boxscore&VST_HI_GOALS_AST
=25---&STATUS=FINA&homeTeam_leadin\n" +
>
"gPointsGoals=2&HOME_TEAM_ID=11&JMS_IBM_PutTime=17253784&VSTR_PERIOD2=0&HOME
_PERIOD1=0&homeTeam_threeLetterNam\n" +
>
"e=CAR&JMSXDeliveryCount=1&HOME_HI_GOALS_AST=11-Jeff%20Friesen-2-0-^M&month=
9&day=10&VSTR_TEAM_ID=25&VSTR_PERI\n" +
>
"OD1=0&homeTeam_displayName=Hurricanes&si_vstr_team_id=25&messageType=NHL.bo
xscore&visitingTeam_losses=0&vstr_\n" +
>
"team_id=25&JMSXUserID=mqm&FILENAME=NHLBOX2002100907.TXT&HOME_PERIOD2=2&visi
tingTeam_ties=0&visitingTeam_overt\n" +
>
"imeLosses=0&source=STATS&VSTR_PERIOD3=0&homeTeam_powerPlayPercentage=14.4&h
omeTeam_losses=1&homeTeam.runs=3&c\n" +
>
"ontestID=2002100907&VST_HI_SAVES=25-Jean-Sebastien%20Giguere-22-^M&isAOL=tr
ue&visitingTeam.runs=0&JMS_IBM_Put\n" +
>
"ApplType=26&homeTeam_divisionID=5&visitingTeam_saves=22&substage=1&homeTeam
_leadingPointsPlayer=Jeff%20Friese\n" +
>
"n&HOME_HI_SAVES=11-Martin%20Brodeur-24-&homeTeam_ties=0&MSGTOPIC=CNNSI/NHL/
STPERSISTER/STATS/BOXSCORE/25/11&v\n" +
>
"isitingTeam_goalsPerGame=2.8&visitingTeam_threeLetterName=NYR&si_contestid=
2002100907&JMS_IBM_MsgType=8&homeT\n" +
>
"eam.score=3&homeTeam_savesPlayer=Martin%20Brodeur&SOURCE=STATS&JMS_IBM_Form
at=MQSTR&period=3&visitingTeam.sco\n" +
>
"re=0&GAME_DATE=09-10-2002%2000:00&homeTeam_leadingPointsAssists=0&SI_VSTR_T
EAM_ID=25&homeTeam_score=3&status=\n" +
>
"FINA&visitingTeam_powerPlayPercentage=16.3&TIMEREMAIN=0:00&homeTeam_wins=0&
SI_CONTESTID=2002100907&HOME_PERIO\n" +
>
"D3=1&payloadClass=class%20java.util.HashMap&homeTeam_overtimeLosses=0&year=
2002&visitingTeam_wins=1&visitingT\n" +
>
"eam_score=0&homeTeam_goalsAllowed=2.9&SI_HOME_TEAM_ID=11&CODE=boxscore&home
Team_goalsPerGame=2.1&VSTR_SCORE=0\n" +
>
"&visitingTeam_divisionID=2&HOME_SCORE=3&JMSXAppID=BROKERDEV1&stage=1&CONTES
TID=2002100907\n" ));]]>

>
>

I can't get into why, but those \n's cause this particular service to fail

something horrible. But since I cannot rewrite that piece of code since I
don't own it - I need to get Idea to not put the \n's in there if at all
possible.


0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

What can I say - "garbage in - garbage out"...
Am I wrong?


No.
The URL with newlines is just simply NOT the URL
that should be used. Also, that wouldn't work
is pasted into M$ explorer. Are we going to ask
Mr. Gates to fix it?

Sorry, I'm fed up of this discussion.

r.

0
Comment actions Permalink

Richard Nemec wrote:

Maxim Shafirov (JetBrains) wrote:

>> What can I say - "garbage in - garbage out"...
>> Am I wrong?


No.
The URL with newlines is just simply NOT the URL
that should be used. Also, that wouldn't work
is pasted into M$ explorer. Are we going to ask
Mr. Gates to fix it?



I believe part of the problem has to do with the fact that some other tool
auto-wraps the URL, or the copy-paste functionality does it. No sure exactly.

However, what the user seems to want is a "special" paste mode (perhaps "paste
special..."?) to strip out newlines for any string pasted in.

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

Once again I can't do more that switching ALL smarts off in this case.


I think it would be helpful would be to have two separate paste actions: one
for the Smart Paste and another for the regular Dumb Paste. Personally I
don't think I'd use the Dumb Paste very often, but this thread shows there
are definitely times when it would come in handy.

Vil.
--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

Disclaimer

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.

0
Comment actions Permalink

I think one issue here is one of 'source'. If the CUT is from completely
within a string (things are already escaped), the paste needs to know that
so that it doesn't re-escape things that are already escaped. This could
possibly be done within IDEA, but there's nothing IDEA can do about it if
you cut from another application.

I think the only solution is to either allow an 'undo' step, as has been
indicated, or have a separate "dumb-paste" that doesn't try to escape the
string contents, so that you can invoke "dumb paste" if you KNOW the
contents of the clipboard are already properly escaped.

Personally, I think the undo-thing is probably more intuitive and easy to
do.

"Maxim Shafirov (JetBrains)" <max@intellij.net> wrote in message
news:bkspc7$evc$1@is.intellij.net...

But as far as I understand the original thing being pasted is just wrong!

It

contains newline characters where they can't be like in the middle of the
identifiers! What can I say - "garbage in - garbage out"...

>

Once again I can't do more that switching ALL smarts off in this case.

This

way you'll get the same many lines but without leading " and trailing " +
and espaces in the middle of the query if they happen. I'm affraid this

will

require much more manual editing than just removing \n's. Alternatively

you

may remove newlines from the clipboard somewhere in the text editor and
repaste proper value.

>

Am I wrong?

>

--

>

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Gregory Pierce" <no_mail@jetbrains.com> wrote in message
news:26161869.1064428573205.JavaMail.itn@is.intellij.net...

<![CDATA[
> > System.out.println( PageBrowser.browseURL(
> "http://subscriberdev1/hockey/nhl/scoreboards/nhl_minisco\n" +
> >
>
"reboard.jsp?FILEDATE=10/9/2002&si_home_team_id=11&sportID=NHL&home_team_id=
> 11&visitingTeam_displayName=Ranger\n" +
> >
>
"s&visitingTeam_savesPlayer=Jean-Sebastien%20Giguere&JMS_IBM_PutDate=2003092
> 3&SPORT=NHL&sport=NHL&PERIOD=3&hom\n" +
> >
>
"eTeam_saves=24&visitingTeam_goalsAllowed=2.8&code=boxscore&VST_HI_GOALS_AST
> =25---&STATUS=FINA&homeTeam_leadin\n" +
> >
>
"gPointsGoals=2&HOME_TEAM_ID=11&JMS_IBM_PutTime=17253784&VSTR_PERIOD2=0&HOME
> _PERIOD1=0&homeTeam_threeLetterNam\n" +
> >
>
"e=CAR&JMSXDeliveryCount=1&HOME_HI_GOALS_AST=11-Jeff%20Friesen-2-0-^M&month=
> 9&day=10&VSTR_TEAM_ID=25&VSTR_PERI\n" +
> >
>
"OD1=0&homeTeam_displayName=Hurricanes&si_vstr_team_id=25&messageType=NHL.bo
> xscore&visitingTeam_losses=0&vstr_\n" +
> >
>
"team_id=25&JMSXUserID=mqm&FILENAME=NHLBOX2002100907.TXT&HOME_PERIOD2=2&visi
> tingTeam_ties=0&visitingTeam_overt\n" +
> >
>
"imeLosses=0&source=STATS&VSTR_PERIOD3=0&homeTeam_powerPlayPercentage=14.4&h
> omeTeam_losses=1&homeTeam.runs=3&c\n" +
> >
>
"ontestID=2002100907&VST_HI_SAVES=25-Jean-Sebastien%20Giguere-22-^M&isAOL=tr
> ue&visitingTeam.runs=0&JMS_IBM_Put\n" +
> >
>
"ApplType=26&homeTeam_divisionID=5&visitingTeam_saves=22&substage=1&homeTeam
> _leadingPointsPlayer=Jeff%20Friese\n" +
> >
>
"n&HOME_HI_SAVES=11-Martin%20Brodeur-24-&homeTeam_ties=0&MSGTOPIC=CNNSI/NHL/
> STPERSISTER/STATS/BOXSCORE/25/11&v\n" +
> >
>
"isitingTeam_goalsPerGame=2.8&visitingTeam_threeLetterName=NYR&si_contestid=
> 2002100907&JMS_IBM_MsgType=8&homeT\n" +
> >
>
"eam.score=3&homeTeam_savesPlayer=Martin%20Brodeur&SOURCE=STATS&JMS_IBM_Form
> at=MQSTR&period=3&visitingTeam.sco\n" +
> >
>
"re=0&GAME_DATE=09-10-2002%2000:00&homeTeam_leadingPointsAssists=0&SI_VSTR_T
> EAM_ID=25&homeTeam_score=3&status=\n" +
> >
>
"FINA&visitingTeam_powerPlayPercentage=16.3&TIMEREMAIN=0:00&homeTeam_wins=0&
> SI_CONTESTID=2002100907&HOME_PERIO\n" +
> >
>
"D3=1&payloadClass=class%20java.util.HashMap&homeTeam_overtimeLosses=0&year=
> 2002&visitingTeam_wins=1&visitingT\n" +
> >
>
"eam_score=0&homeTeam_goalsAllowed=2.9&SI_HOME_TEAM_ID=11&CODE=boxscore&home
> Team_goalsPerGame=2.1&VSTR_SCORE=0\n" +
> >
>
"&visitingTeam_divisionID=2&HOME_SCORE=3&JMSXAppID=BROKERDEV1&stage=1&CONTES
> TID=2002100907\n" ));]]>

>
>

I can't get into why, but those \n's cause this particular service to

fail

something horrible. But since I cannot rewrite that piece of code since I
don't own it - I need to get Idea to not put the \n's in there if at all
possible.

>
>


0
Comment actions Permalink

Or you could just leave the pasted string alone :) Give me the option to turn the feature off altogether so I won't get newlines all over the place where clearly they simply cannot exist :)

0
Comment actions Permalink

The original string starts off as one REALLY long line. IntelliJ breaks it up in this manner.

0
Comment actions Permalink

I think it would be cool for IDEA to have an option to show strings in code in their completely raw form, with some sort of special syntax coloring to indicate that it's the raw form. For example, if I have the string:

<![CDATA[private static final String RE = "[;=\\s]*+(\\S+?)\\s*(?:=\\s*(?:\"(.*?)\"|(\\S*?))\\s*)?(?:[=\\s]*;[=\\s]*|\\z)"]]>


IDEA could show it as:

<![CDATA[private static final String RE = "*+_[;=\s]*+(\S+?)\s*(?:=\s*(?:"(.*?)"|(\S*?))\s*)?(?:[=\s]*;[=\s]*|\z)_+*"]]>


The way I'm imagining the UI is that it would resemble code folding - you could switch between the Java code view or the raw string view. Also, multi-line strings could be shown as actual multi-line strings, in a box whose upper-left corner is where the string begins in the code.

Or, alternatively, maybe someone could write a string editor plugin.

If anyone else thinks this would be cool maybe I'll file an SCR. :)

0
Comment actions Permalink

So would you please provide some samples of such undesired behavior so we
can decide what actually needed in this case and probably find a common
denominator of all cases or some sequence of undoable actions that will
cover all the cases.


Not all the strings pasted in IDEA are meant to be printed out. Take, for
example, the SQL statements one might have in the java classes.

We often split them on multiple lines for readability. One common use case
is copying them back and forth between the java class and a SQL tool (or
the SQL plugin, for that matter) for testing purposes.

I agree with this topic's request, IDEA should allow a paste operation
that does the concatenation part, but does not include the escaping of new
lines.

Pasting the following

SELECT x1, x2, x3
FROM someTable
WHERE someConditionsHere

in a string
String s = "|";

should result in
String s = "SELECT x1, x2, x3 " +
"FROM someTable " +
"WHERE someConditionsHere";

So this version would just insert a space instead on \n. Make it an option
(I see myself using the space version most of the time) or a different
type of paste, but do provide it, please. The current behaviour it's just
too intrusive, IMO.

Thx,
Andrei

P.S.
<![CDATA[]]>
A while ago, I filled in a feature request that was
talking about the ability to copy the concatenated string without the
concatenations(http://www.intellij.net/tracker/idea/viewSCR?publicId=12099),
but since that one was (partially) taken care of by the SQL plugin, there was no need
to pursue it further. I don't say I wouldn't like to see IDEA taking care
of this copy type as well, since the SQL plugin is not the only place the
copied string can be pasted to. :)
</slightly_offtopic>

0
Comment actions Permalink

I like your idea, but I think perhaps it'd be better implemented by removing the quotes and changing the background color of the literal string.

Please submit an SCR!

0
Comment actions Permalink


Maxim Shafirov (JetBrains wrote:

1. Seems you've missed surrounding each new pasted line with '" " +'
pattern in your 1, 2, 3 list.

Yep, right.

2. Am I right you're suggesting completely ignore newline characters in
clipboard when pasting? This way it gonna be a single long line with no idea
for intention on where to break it or insert \n chars. Let's be a bit more
formal in this discussion.
Well, as far as I understand there are cases when current IDEA's behaviour
is oversmart and annoying and it actually doing something it shouldn't do in
user's opinion.

>

So would you please provide some samples of such undesired behavior so we
can decide what actually needed in this case and probably find a common
denominator of all cases or some sequence of undoable actions that will
cover all the cases.

>

Sascha, Gregory?

>

P.S.: "c:\new" case has been fixed. That wasn't an intention. Just a bug.

>

--

>

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:bksjbo$u27$1@is.intellij.net...
>

Maxim Shafirov (JetBrains) wrote:

Well, it seems I have the things completely messed in my head.
We can do "Smart Paste" undoable but this is not what Gregory wants!

>

Oops, yes you're right. But this is IMHO a second aspect of Smart Paste

that

converts hard newlines into \n sequences and is independent from the auto-
escaping.

>

My primary concern was that dealing with already escaped strings is

pretty

painful right now and would directly benefit from a seperate undo. I even

think

Smart Paste involves three steps:

>

1. Paste
2. Convert newlines from clipboard into \n
3. Escape protected characters

>

Step 3 should be undoable and 1+2 together because that exactly resembles

the

contents of the clipboard.

>

Does this sound reasonable or am I dead wrong :) ?

>
>

Sascha

>
>

>
>


0
Comment actions Permalink

Oops, hit the wrong key and prematurely sent the message. Sorry.

Maxim Shafirov (JetBrains) wrote:

1. Seems you've missed surrounding each new pasted line with '" " +'
pattern in your 1, 2, 3 list.

Yep, right. I think I thought of this as part of step 2 :)

2. Am I right you're suggesting completely ignore newline characters in
clipboard when pasting? This way it gonna be a single long line with no idea
for intention on where to break it or insert \n chars.

Oh, no. On the contrary. This is exactly right and this is why I distinguished
escaping and converting newlines: The escaping will be redundant (wrong)
when dealing with strings from other languages that use C-like string-escaping,
while the conversion of newlines is - as far as I can see - always right.

This might be in conflict with Gregory's problem though, which I also can't see a
good solution for: If you copy multiple lines you should get a String that contains
'\n's when pasting.

So would you please provide some samples of such undesired behavior so we
can decide what actually needed in this case and probably find a common
denominator of all cases or some sequence of undoable actions that will
cover all the cases.

I agree that cases were IDEA seems to be oversmart are very rare but sometimes
I copy strings from other applications (Visual Studio, UltraEdit) that are already
escaped. It is very annoying to have no other way than to manually remove the
extraneous '\'s and it is kinda error prone.

I very much favor the extra undo step over a second 'dumb' paste key because
there is no new key-combination to learn. The undo is IMHO much more intuitive.

Sascha


0
Comment actions Permalink


"Vilya Harvey" <vilya.harvey@digitalsteps.com> wrote in message
news:bksvcs$ktr$1@is.intellij.net...

Maxim Shafirov (JetBrains) wrote:

Once again I can't do more that switching ALL smarts off in this case.

>

I think it would be helpful would be to have two separate paste actions:

one

for the Smart Paste and another for the regular Dumb Paste. Personally I
don't think I'd use the Dumb Paste very often, but this thread shows there
are definitely times when it would come in handy.


MSWord has several paste modes, like normal (with formatting and stuff),
unformatted, rtf, ... I hate its normal paste, I almost always use
informatted. It is not displayed in the main menu, and formatted paste is
still a default, but whatever...

Unformatted paste rules.


0
Comment actions Permalink

Is there any update on this? I'm all for having a smart paste feature, but not at the lack of my regular paste that I am used to. I find I have to undo manually what smart paste does most of the time - not necessarily because what smart paste does is incorrect but I don't need or want to see escape characters when they are not needed.

0
Comment actions Permalink

Yes, cutting and pasting SQL Queries is where this has bitten me, while I can see the logic behind the \n's it would be really nice to have an undo that got rid of them.

Damian

0

Please sign in to leave a comment.