Skip to content

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

Closed

Description

@alanzchen

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.

Activity

  1. renkun-ken commented on Dec 1, 2021

    @renkun-ken
    Member

    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.

  2. randy3k commented on Dec 1, 2021

    @randy3k
    Member

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

  3. changed the title [-]Code folding won't work if there is a single grammar error in one of the code trunk[/-] [+]Code folding won't work if there is a single grammar error in one of the code trunks[/+] on Dec 1, 2021
  4. alanzchen commented on Dec 1, 2021

    @alanzchen
    Author

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

  5. randy3k commented on Dec 1, 2021

    @randy3k
    Member

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

  6. renkun-ken commented on Oct 6, 2026

    @renkun-ken
    Member

    Fixed by merged #752. I checked the exact good() / bad( Rmd example on current master: the folding response includes both code cells despite the syntax error in the second cell. Cell parsing is now independent, so a broken cell no longer removes folding and symbols from the rest of the document.

    Closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions