Comments (11)
It is VSCode specific issue, but there is more going on here. The problem is, in range formatting
, we always get the full lines of the selection.
Lines 77 to 80 in 94a8db0
When you paste "a" to "p", the text being formatted is
colnames = c("a", "b", "c", "d", "e",
"f", "g", "h", "i", "j", "k", "l",
"m", "n", "o", "p")))
That's why we get an error.
The easiest fix is to catch the possible error of style_text
since we cannot predict what will be passed to it.
Does VSCode really expect to run formatting for every paste? Sometime user may copy and paste an incomplete piece of code and obviously we don't want to format it.
from languageserver.
In vscode, there are formatOnType
, formatOnPaste
, and formatOnSave
options. I think such formatting error can be suppressed unless debug mode is on.
from languageserver.
I believe that the error is suppressed when debug mode is off, isn't it?
from languageserver.
My debug mode is off but this still appears.
from languageserver.
Note that you will need to restart VSCode. You are right.
from languageserver.
The problem is more complicated when I thought.
foo <- function(
x = 1,
y = 2
) {
# body
}
If I paste z = 1
to replace y = 2
. I got
foo <- function(
x = 1,
z <- 1
) {
# body
}
from languageserver.
I guess we need to check if the selection is from the beginning to the end of all the lines included.
from languageserver.
This example is caused by assignment operator fix, even if you select the full line, the formatting would make this happen, doesn't it?
from languageserver.
Yes, it would still be an issue. But at least it is not triggered all the times. A better solution is to check the scope of the selection. But it can be difficult in some situations.
from languageserver.
Maybe we can turn off operator replace by default?
from languageserver.
Use format selection
in vscode will make this happen too.
Operator replacement is dangerous because <-
and =
are not always interchangeable. I think we should turn if off by default as an argument of style_text
.
from languageserver.
Related Issues (20)
- Formatting Jupyter Notebooks adds a newline at the end of every cell
- Support for old R version HOT 3
- Support for path completions
- Availability of `formatOnType` in quarto
- Roxygen comments soft linebreaks aren't ignored in languageserver hover hints
- Reference support for S4 methods
- No documentSymbol response for Rmarkdown file with helix editor HOT 1
- Variable duplication, one from workspace, another from session
- Autocompletion Bugs in vscode rmd-files
- "glue" function semantic for the expressions inside {}
- spawn: bash failed with exit code 127 and signal 0. HOT 1
- callback error in Neovim: “attempt to compare string with number” HOT 1
- Completion dataframe variable/columns HOT 3
- Neovim lspinstall r-languageserver installation not using .Rprofile CRAN mirror address?
- languageserver crashes with regex in file
- VSCode outline fails in Rmarkdown document if there is pseudo chunk text inside the chunks
- VSCode Perl::LanguageServer causes a process that consumes CPU HOT 2
- Section collapsing issues HOT 1
- Error with renv: Header must provide a Content-Length property
- Hover and Outline do not appear to function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from languageserver.