External Tools: Tool Settings, Arguments: "$SelectedText$" breaks on double quotes in selection
I've double-quoted the $SelectedText$ placeholder, so multiple words do become one argument (in $argv, it's a php script), but it doesn't properly handle double quotes in the selection.
A selection with:
foo "bar" bazz // becomes 1 argument 'foo bar baz' without the double-quotes
foo bar" bazz // becomes 2 arguments ‘foo bar' and 'baz’
foo " " bar // becomes 2 arguments ‘foo ’ and ‘ bar’ ignoring all the other spaces.
Using single quotes around the placeholder works less well generally, for similar reasons.
NB: when copy/pasting these examples to test, replace any curly quotes inserted by the forum software with regular single and double quotes.
请先登录再写评论。
Hi there,
Not sure if it's the same, but sounds related at very least – https://youtrack.jetbrains.com/issue/IJPL-12046
Yeah.. I've resorted to ignoring $SelectedText$ and recreating the selection value using
$SelectionStartLine$:$SelectionStartColumn$:$SelectionEndLine$:$SelectionEndColumn$
which I then split on ‘:’, figure out the byte offsets (having *these* available as variables would be wonderful too..), and getting the substring from the file's contents. I'm fairly sure correctly escaping the selection before passing it as argument to the script on the commandline would fix this.