languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

Code folding won't work if there is a single grammar error in one of the code trunks

Open alanzchen opened this issue 3 years ago • 4 comments

A minimum RMD to reproduce this:

```{r}
good()
```

**You need to fix the following code trunk for the code folding to work.**

```{r}
bad(
```

Ideally a single error in one of the code trunks should not affect the code folding of the entire document.

alanzchen avatar Dec 01 '21 07:12 alanzchen

Currently, we parse the whole document rather than chunks to provide the folding ranges, which assumes that the document is syntactically correct.

If we process rmd document chunk by chunk, then it is perfectly possible to make not only the folding ranges but also some other features more error tolerant.

renkun-ken avatar Dec 01 '21 08:12 renkun-ken

I think we need to at least support eval = FALSE by the chunk options.

randy3k avatar Dec 01 '21 17:12 randy3k

It would also be nice to be able to alert users of grammatical errors. How difficult is this to implement?

alanzchen avatar Dec 01 '21 18:12 alanzchen

Diagnostics are supported for Rmarkdown documents in languageserver's perspective. @renkun-ken would know more about vscode.

randy3k avatar Dec 01 '21 18:12 randy3k