开发者

How to get around Eclipse swallowing double quotes for ${selected_text}

I am using Eclipse 3.6.1 Build id: M20100909-0800 and 开发者_运维技巧Aptana Studio 2.0.5 which is based on Eclipse 3.5.2 (both on OS X) and in both programs the external tools feature seems to swallow double quotes and whitespace for the ${selected_text} variable.

Isn't the ${selected_text} variable essentially useless with the mentioned behaviour? Is there a way around that or maybe a hidden setting somewhere?

Thanks for reading.


This could easily be considered a safety/security feature.

I suggest "${selected_text}".

...but if it's eating ALL whitespace, that won't really help. Huh. Maybe it's clever enough to detect the quotes and preserve the whitespace... but probably not.


Okay, I did a little poking around. Quotes within the argument list itself are preserved, as per my initial suggestion above. I found the following auto-generated argument list that was working Just Fine:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -debug "${workspace_loc:/com.cardiff.bpm.ide.webforms.ui/debug.options}"

But if your text selection contains quotes, I'd expect it to be handled as per the underlying OS. Windows "cmd" does some... creative things with them for example. My *nix-fu is Not Mighty, so I couldn't tell you what OS X will do under the covers, but I suspect that's where you'll find your solution.

You may have to do something goofy like URL-encode your selection, and use some command line tool to un-encode it before passing it to your desired external tool once the text is out of Eclipse's clutches.

A (very) quick look around my 3.6.1 UI didn't turn up that would do this automagically for you, but there's probably a plugin out there somewhere that'll add that feature to an editor's context (right click) menu.

I'd expect the HTML editor to have this ability already... but I don't see anything other than "smart insert mode" that sounds promising, and I don't see that working either.


That doth bloweth goats, most heartily, yay for weeks on end. E'en till yon goat hath a rash, most unpleasant in both severity and locality. Verily.

I don't think you're getting my proposed solution:

  1. Set up your tool so it'll de-url-encode-ificate the incoming string with some proposed command line tool.
  2. In your editor (in eclipse), URL-encode the text you wish to select and pass to the tool. Manually.
  3. Run the tool on the selected (url-encoded) text.
  4. Revert the selected text. Also manually. Probably just "undo".

"1" is why I was looking for some eclipse UI way of url-encoding a selection. The HTML Editor won't even do it when you paste into an attribute string. Sheesh.

Two Other Options:

  1. Fix the bug yourself. Open Source and all that.
  2. Write a plugin that exposes it's own version of ${selected_text} that doesn't strip out all the strings.
  3. Hey! SED! Replace the quotes with some random (unused in any selection you might make) high-ascii character and sed it back to a double quote instead of the proposed de-url-encode-ificationizer. You'd still have to manually edit/undo the text, but at least you won't have to """ Actually search/replace over a given selection makes that less painful than one might think.

I'm not sure what the scope of #2 is, but I'd image if you don't have any eclipse plugin experience the thought might be rather daunting. There might even be a sample plugin that exposes such a variable, though I haven't checked.


I don't think we're communicating.

You don't select text with quotes in it. You select mangled text, and sed demangles it back into quotes for you.

For example, you have the string print("hello world"); in your editor and want to send that to your tool.

  1. change it to print(~hello world~); in your editor. Manually or via a script or whatever.
  2. select it
  3. run your tool, maybe wrapped in a script that'll sed the ~s back to "s.
  4. change it back to print("hello world");.

This is a manual process. It's not pretty. Bug workarounds are like that. You can probably come up with a monkey script to convert quotes to Something Else, and "undo" is easy. You might even be able to get your script attached to a keyboard short cut... dunno. And ~ is a lousy choice for a replacement character, it's just the first thing I could think of that was rare enough to be a decent example.

Are we communicating yet?


For the record, I put together a patch using some guidance from a gentleman in the bug comments.

I don't know if it will be accepted, but it fixes things for me so maybe someone else may find it useful.
Again, this is only for Mac OS X Eclipse.

  1. Start Eclipse.
  2. Go to Import > Plug-ins and Fragments.

    Import From: Active Platform
    Fragments to import: Select from all plug-ins
    Import As: Projects from a repository

    Next >

  3. Pick org.eclipse.debug.ui and org.eclipse.debug.core

  4. Once the projects are in your workspace, apply the two patches that compose proposed patch v1, found at the bug tracker page for bug 255619

  5. Go to Export > Deployable plug-ins and fragments and make a jar out of your changed packages.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜