Closed dcluna closed 7 years ago
Hi @dcluna , thanks for the PR! :)
Could you give a code example where this is useful? I don't see how this affects racer-describe
, since as you say it's using thing-at-point
. We may also want to file a bug on upstream racer to make it smarter.
Hi @Wilfred, thanks for reviewing!
I was looking at a piece of code like the following:
::std::env::var("MY_ENV_VAR")
and just putting point at var
and running racer-describe
didn't open the documentation for var
as I expected. racer-debug
returned the following:
$ $HOME/.cargo/bin/racer complete-with-snippet 753 31 my-file.rs /tmp/racer3881nsF
This command terminated with exit code 0.
stdout:
PREFIX 24647,24650,var
END
No output on stderr.
The temporary file will have been deleted. You should be
able to reproduce the same output from racer with the
following command:
$ CARGO_HOME=$HOME/.cargo RUST_SRC_PATH=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src $HOME/.cargo/bin/racer complete-with-snippet 753 31 my-file.rs
The upstream racer
command has a complete
option that allows you to pass a fully-namespaced string for autocompletion, and that's what I'm using in this PR. It solved my problem, but as you say, maybe I should focus on fixing the upstream complete-with-snippet
. I must admit I am not familiar with it - particularly, the numbers after PREFIX
seem like internal pointers to crates to me, but I could use some guidance with it.
Anyway, have I made myself clear? Do you think this is mergeable (after adding some tests, ofc), or do you think this is a racer
bug in the complete-with-snippet
?
Thanks for the example. Based on it, I've written the following program, but I can't reproduce the issue:
fn main() {
let v = ::std::env::var("MY_ENV_VAR");
}
I'm able to jump to definition and run racer-describe
on var
. What version of racer are you using?
racer 2.0.9
. There are some rustc
errors in the crate I'm writing this code, so maybe that has something to do with it? What surprises me is that racer-call
with complete
does work. If this is expected behavior, I can change this PR to use the complete
option if complete-with-snippet
fails for whatever reason. WDYT?
Interesting that complete
works. Could you share the file you're working on?
I can't see any references to ::std::env::var
in that file, and ::std::env::current_dir
seems to work as expected. How can I reproduce the issue?
I added the following line (after line 752):
assert!(::std::env::var("RUST_SRC_PATH") == Ok(_));
It seems like this is mostly related to my own environment than any bug in racer
or this plugin, so I'll close this and re-open if I manage to reproduce it reliably. Thanks for your patience on this!
(thing-at-point 'symbol)
(here) doesn't always retrieve what we want - for instance, when describing a namespaced fn - so we may want to check it against the active region to work around this.