rust-tools.nvim icon indicating copy to clipboard operation
rust-tools.nvim copied to clipboard

Manage command arguments that contains shell special characters

Open Kannen opened this issue 3 years ago • 3 comments

The command :RustRunnable is not able to run doctests of the form `XX<[T]>::foo'. I believe '[' is interpreted by the shell as a special character.

The work around I have found is to quote values of args.executableArgs in runnable.lua:44:

   ret = ret .. "'" .. value .. "'" .. " "

(That's the work of a none lua/vim coder.)

Kannen avatar Aug 20 '21 12:08 Kannen

There is another issue: the <argument> within cargo test -- <argument> must have spaces escaped, other wise cargo test split the <argument> at each space and run all tests that match any of the parts of the argument.

For example, if:

$ cargo test -- --list
[...]
test  X<T, P>::foo (line 33)
test  X<T, P>::bar (line 42)

then within the module containing X, rust-tool may try to execute cargo test -- 'X<T, P>::foo'. This is translated by cargo test to the equivalent of cargo test -- 'X<T,' 'P>::foo' so the 2 tests will be run.

What should be run is:cargo test -- 'X<T,\ P>::foo'

Kannen avatar Aug 21 '21 08:08 Kannen

Finaly I have forked your repo and added native support for code lens and more:

  • RustRunSingle that run span the rust-analyzer.runSingle whose range cover the cursor position
  • RustDebugSingle that run span the rust-analyzer.debugSingle whose range cover the cursor position
  • RustCrateGraph that open the crate graph in the system application
  • I escaped the space of the argument of run commands
  • and other things that I finally don't think are of interest.

Maybe have a look in the repo and if you want I can send you merge requests.

Kannen avatar Aug 22 '21 17:08 Kannen

Thanks for your work, feel free to send some PRs or I'll cherry pick your changes

simrat39 avatar Aug 22 '21 17:08 simrat39