-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Report: Code completion when implementing functions in VSCode doesn't work properly. #11467
Comments
Might be caused by #11412 and us hitting some specific behaviour in VSCode. |
I can reproduce it in Emacs as well. |
@flodiebold, have you been having this issue, or did you just reproduce it? |
I'm not sure what you're asking; 'reproduce' means I have the same issue when I try it. It's a bug that needs to be fixed. |
@flodiebold, essentially what I asked was if the bug was occurring naturally for you, or if you had to do any proceeding steps to get it to (not) work. |
I've hit this several times when trying to fill in trait methods in the last few days. I haven't particularly noticed an issue with other completions, though they may also be affected. |
This does look like we are breaking the LSP somewhere as the server does send a proper completion response here.
Yep our response is invalid. |
@Veykril, can you explain what that means in laymans terms? - I wanna understand the issue, but idk the jargon. |
We currently send a completion with one text edit that replaces the text range at from |
@Veykril, what's the status of the bug? |
Same as stated in the previous message, we still violate the LSP which makes clients discard our completion. |
Note that this happens not just with trait Tr {
const KONST: u8;
}
impl Tr for () {
const $0
} For this, we send the following LSP
|
11967: fix: Fix trait impl completions not triggering after `fn`/`const`/`type` r=jonas-schievink a=jonas-schievink ![screenshot-2022-04-12-17:13:01](https://user-images.githubusercontent.com/1786438/162996087-56540f5e-a6be-4111-a4a5-8de21f483a5e.png) Fixes #11467 cc #11860 bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
11967: fix: Fix trait impl completions not triggering after `fn`/`const`/`type` r=jonas-schievink a=jonas-schievink ![screenshot-2022-04-12-17:13:01](https://user-images.githubusercontent.com/1786438/162996087-56540f5e-a6be-4111-a4a5-8de21f483a5e.png) Fixes #11467 cc #11860 bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
I see the fix previously, but I'm experiencing exactly this issue. Have spent an hour on various posts to no avail. What commands can I run to get you the details you need to further debug? Explanations appear which is a feature of the LSP I guess, but completion does not trigger. Settings are enabled as far as I can tell. I'm currently on the rust-analyzer pre-release version v0.4.1082 as of this message. I don't know that it makes any difference, but I frequently switch languages within VS Code, and my settings are tied to User instead of Workspace, if there is potentially a conflict where one setting is overriding another, such as a default LSP setting as opposed to a language-specific LSP setting, please provide some guidance on how I would locate that info to help. |
Your screenshot and description doesn't look like you're experiencing the bug described here. Can you open a new issue, and describe in more detail what you're doing and what you're expecting to happen? |
Before opening a new issue, let me state that what I'm doing is typing The OP of this issue describes this exact phenomenon:
That is precisely what is happening. No predictions pop up entries where I expect code completion. If you still feel this is a separate issue, I would be happy to open a new issue to track. But OP's description of their experience and my experience are identical as far as I can tell. |
Your screenshot does not show you typing |
Here is a screenshot of the issue in action: Here is the full contents of the code as it is currently:
I would like to be able to find some log where the call from VS Code is made to the code completion service, as there must be some logging statement that would show the issue. Do you know how I could grab that output? |
There is currently no completion in that position. The completions this bug is about only happen when implementing a trait. There is a snippet for |
Hi @flodiebold - I created a video to demonstrate what I'm seeing and what I'm expecting - if you see this and determine it's a separate issue, I will open a separate issue. https://www.loom.com/share/b15192081e6044358eade1e1a0c5c720 At the end of the video, I show a bit of backtrace, I've pasted the entire output here:
I see messages like "expected a name", "expected arguments", "expected a block" in the error. If it helps, line 751 in the cursor.rs file (https://github.com/rust-analyzer/rowan/blob/master/src/cursor.rs) is the assertion within this code:
I don't know where to take it from here. |
Ok, so apparently you don't get any completions at all? This is indeed a separate issue then. Some things to check when you report a new issue would be:
|
Specs.
In Visual Studio Code, I have suspicion that Rust Analyzer's code completion isn't working as intended.
Here's some specs:
Description.
As far as I can tell, only one prediction (pattern) doesn't work, though, similar bugs may be present in other forms.
Whenever I try to implement a trait onto a datatype I have (for this example's purposes
Trait
ontoS
*), when implementing the functions inTrait
, no predictions come up when I start writing "fn
" (with a space at the end); even if I add the first letter(s) of a function name.Reproduction.
Example:
When I replace
// I START WRITING HERE...
withfn t
, with my cursor and focus still in the textarea of VSCode, no predictions pop up.However, instead of writing
fn t
, if I just start writingte
; for example, then the predictionfn test() -> String
comes up. (Even though it should work in only the former OR both scenarios.)I can tell it's not strictly a VSCode bug, because when I do Ctrl + Space, I'm told "No suggestions.".
Working Example.
This bug came up while I was working on my game RuntDeale.
I had a trait,
Positioned
, inposition.rs
. After usingPositioned
insprites.rs
(sibling ofposition.rs
), I was implementingPositioned
forSprite<'_, T>
(specific implementation details not important*).This is the point I found the bug, entering the
impl
block, typing away, noticingfn se
didn't trigger the completion forfn setX(&mut self, x:Scalar) -> ()
.Temporary Workaround.
There is an "assist" that's provided, nicked "Implement Missing Members", which works fine.
But it implements everything at once, which is overwhelming for me. - I usually work on each function one at a time.
Exception.
This bug is not apparent in at-least one setup, in NioVim, according to testimonial @olestrohm:
The text was updated successfully, but these errors were encountered: