languageserver
languageserver copied to clipboard
Format selected lines stop working after trying to format already formatted lines
I'm not sure if this is a LanguageClient-neovim
issue or the language server. When I visually select for example a = c(1, 2)
in Vim and applied formatting, it will be corretly formatted to a <- c(1, 2)
, but when I changed <-
back to =
and applled formatting again, nothing happes.
Due to some technical reasons, if you only select partial line, the assignment operator won’t be modified. It’s only being modified when the whole line is selected or using "format document".
This a avoid accidentally changing the equal sign in for example
list(
x = 1,
y = 2
)
Thanks very much for you reponse! Although I thought your suggestion might not be related the issue I'm referring to. My own initial description was also incorrect. It is more likely formatting would stop working randomly at some point, but something I could do to make it consistently stop functionning is as follows:
- Open a new document
- Type
a = c(1, 2)
- Select the entire line and format. It will be successful.
- Open two new lines
- type
for
and snippet expand to a for loop
for (i in seq(1, 10)) {
print(i)
}
- Delete two spaces before
print(i)
so it is longer correctly formatted. - Select the entire for loop with line selection and formatting will not work
I see what's going on now. It is because there is a bug a linting as you type for (i in seq(
. languageserver
returns some garbage and perhaps LanguageClient-neovim
doesn't catch the error and breaks its other features. In Sublime Text, the LSP client caught the error and stop it from breaking the whole workflow.
By the way, what version of languageserver do you have?
2d2a81c should fix the bug in diagnostics
Thanks so much for looking over this! I was using the version on CRAN. Now i've installed the master branch version with source("https://install-github.me/REditorSupport/languageserver")
. It seems that the issue persists. There is another issue I'm not sure if is related. When I only have
for (i in seq(1, 10)) {
print(i)
}
# new line here
in the file. When I select the for loop, not including the trailing new line, and apply formatting, the for loop will be correctly formated but the unselected trailing new line will also be removed.
CRAN version should not be affected by the diagnostics bug.
About the new issue, I am quite sure that it is due to LanguageClient-neovim
.