vscode-R
vscode-R copied to clipboard
VSCode autocompletion doesn't "complete", duplicates existing text
Apologies if this is easily fixed, but I wasn't able to find it in the docs.
On my Mac, when I type any VSCode autocompletion, the autocompletion appends to what I have already written, producing invalid code. Say I'm writing is.infinite, and I have written is., I navigate over to infinite and press tab or Enter and the editor produces is.is.infinite().
Is there a setting to change this behavior? Is this intended to be the default behavior? Or am I missing something?
Thank you.
It is an editor issue, let me transfer it to vscode-R.
It is an editor issue, let me transfer it to vscode-R.
Thanks!
A further detail: it seems to only occur with completions in the is. and the as. family (perhaps others???). When I type geo and fill geom_point, it correctly appends the remaining text. I thought it had to do with dot operators, but typing data. correctly completes to data.frame. Strangely, typing infinite and then selecting is.infinite autocompletes the correct code.
I cannot reproduce it in latest vscode-R (2.3.1) vscode release (1.61.1) on macOS (11.6). What version of vscode-R, vscode, macOS and languageserver are you using?
Could you confirm with the latest vscode-R, vscode, and languageserver?
Sure. The above issues were on vscode-R (2.3.1), vscode release (1.61.0) on macOS (11.5.2) with languageserver (0.3.11). Updating to vscode (1.61.1) did not resolve the issue. I doubt the OS version would make a difference?
Ah! I just noticed that this issue only occurs inside .Rmd code chunks and not in .R files. Can you reproduce there?
Ah! I just noticed that this issue only occurs inside .Rmd code chunks and not in .R files. Can you reproduce there?
Yes, I could reproduce it in rmd. Thanks for reporting!
I tried with defining a function like is.test <- function(x) x in an rmd chunk and run it in an R session and see if both session completion provider and language server completion provide have the same problem. It turns out that only completion results from the language server completion provider have the problem, i.e. when I type is. that triggers a completion request, the token being completed is no longer is. but the string after it as indicated by the following image where the blue highlight does not include the beginning is..
Still not sure if it is an vscode-R or languageserver issue. Will take a closer look at this.
Only is. and as. have the problem. I guess it is caused by vscode-R syntax file where is. and as. are treated differently from other functions somehow. @andycraig any idea?
I had a bit of a look just now and I think this might apply to all matches in Rmd files where the prefix contains a period ., not just is. and as.. When I type data.f my first match is for data.frame, but it's from a vscode-R snippet. (The little square to the left of the candidate data.frame means the source is a snippet.) The 4th candidate is just matching f and I think that's the one coming from {languageserver}. The meanings of the little icons is here: https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions

It seems that when generating the candidates the prefix including the . is used. E.g., if I type c.d I get c.Diff as the top candidate, but if I just type d I get diff.Date as the top candidate. So I think VS Code is correctly passing the editor text to the completion provider and the candidates are being correctly determined. It looks like something is going wrong after that, when determining which of the characters in the candidate match the text in the editor.
My best guess at the moment is that the problem is in {languageserver} when returning the matches and their metadata, but it's just a guess.
I'm going to try seeing if I can reproduce this behaviour in a different editor like Vim or Kakoune.
My best guess at the moment is that the problem is in {languageserver} when returning the matches and their metadata, but it's just a guess.
The returned metadata looks correct to me. As it is an issue of Rmarkdown files only, I suspect it is related to editor.wordSeparators.
I tried using the suggested editor.wordSeparators but it does not work either.
I observe that the behavior might be mixed:
https://user-images.githubusercontent.com/4662568/137612797-55feaf9d-6965-4c85-a3fc-37fbf8e22b60.mp4
From the logging of the languageserver, the beginning tokens seem correct:
[2021-10-17 13:27:02.649] token: {
"full_token": "is.",
"right_token": "",
"package": null,
"accessor": "",
"token": "is."
}
[2021-10-17 13:27:02.656] bracket is
[2021-10-17 13:27:02.657] completions: {
"init_count": 57,
"final_count": 57,
"time": 0.0078,
"isIncomplete": false
}
[2021-10-17 13:27:19.168] token: {
"full_token": "data.",
"right_token": "",
"package": null,
"accessor": "",
"token": "data."
}
[2021-10-17 13:27:19.176] bracket is
[2021-10-17 13:27:19.177] completions: {
"init_count": 62,
"final_count": 62,
"time": 0.0089,
"isIncomplete": false
}
@renkun-ken I tried the examples from your video and in some cases had different results. For me the completion candidates never have the text before the . highlighted. Not sure if that's useful or not but I thought I'd mention it.
Haven't found the Neovim and Kakoune equivalents of wordPattern so no update on that front.
In Neovim, it seems to work as intended.
It seems that the first dot and the part before it are being ignored in R Markdown files?
.R file

.Rmd file

.R file

.Rmd file

I just want to confirm that I have for a long time had the same problem with names that contain a dot. Today I discovered that this problem also occurs when the name to be completed starts with a dot:
This issue is stale because it has been open for 365 days with no activity.
unstale
I'm experiencing the same issue on Rmarkdown. Kindly ask if there is any update?