-
Notifications
You must be signed in to change notification settings - Fork 59
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
Completion of function calls sometimes fails to include snippet #1785
Comments
This branch is being incorrectly taken, because |
Going into Things go downhill on this line, though: Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts); After this, |
Having a bit of a "how did this ever work" moment here. Inside ... but then adds that 12 to the code completion location (which differs from the start of the comment token by the intervening whitespace that was skipped), resulting in a location in the middle of the comment token 🤯 |
I guess the way the current code manages to successfully identify cases where the next token after the completion location really is a It basically works by accident, but the mechanism is pretty badly broken. |
One more thing I noticed while stepping through the lexer code that may be relevant: the lexer's inner loop does have a check for the code completion location, but checking for this requires the lexer to have a |
My best idea for how to fix this is to have clangd not use It would be nicer to get |
Proposed fix: llvm/llvm-project#69153 |
Thanks for the fix. Looking around the changed lines, I remembered that once I encountered the case where the "don't add new parens & placeholders if arg list does exist." heuristic doesn't work when completing a setter function call generated by Protobuf. I'd like to have a try on this patch and see if this solves that problem. (I didn't get around to reducing the code snippet since I first ran into it. Looks like it is somehow particular to protobuf because I've never seen this issue for my hand-written functions.) |
The code was previously using Lexer::findNextToken() which does not handle being passed the completion point as input. Fixes clangd/clangd#1785
…#69153) The code was previously using Lexer::findNextToken() which does not handle being passed the completion point as input. Fixes clangd/clangd#1785
…llvm#69153) The code was previously using Lexer::findNextToken() which does not handle being passed the completion point as input. Fixes clangd/clangd#1785
In the following code:
Place the cursor at the location indicated by
^
, invoke completion, and select the only result.Expected result:
waldo(int arg)
is inserted.Actual result:
waldo
is inserted.The behaviour has something to do with the commented line.
The text was updated successfully, but these errors were encountered: