rstudio / rstudio

RStudio is an integrated development environment (IDE) for R
https://posit.co/products/open-source/rstudio/
Other
4.59k stars 1.08k forks source link

Code chunk comprehension disrupted by div? #14674

Closed d-morrison closed 1 month ago

d-morrison commented 1 month ago

System details

RStudio Edition : Desktop
RStudio Version : "Chocolate Cosmos" Release (a00d0e77, 2024-04-24) for macOS
OS Version      : Mac OS 13.6 (22G120)
R Version       : 4.4.0

Steps to reproduce the problem

  1. Create a Quarto document.
  2. Create an R code chunk.
  3. Create a div before the code chunk.
  4. Reformat the code chunk (cmd-shift-A or Menu Bar > Code > Reformat Code).

Reprex:

---
format: html
---

:::{.callout-note}
bar
:::

```{r}
foo = function()
{
x + 1
}


### Describe the problem in detail

When I add a div prior to an R code chunk, the RStudio code editor appears to lose the ability to indent the code chunk correctly; using "Reformat the code chunk (cmd-shift A)" results in all leading whitespace being removed. Curly-brace folding also becomes disabled.

Before:

![image](https://github.com/rstudio/rstudio/assets/2474437/920d2b1a-8261-4a45-801e-bc91813141d8)

After:

![image](https://github.com/rstudio/rstudio/assets/2474437/1484e6f3-f66b-40a8-a65a-5ca491991a5d)

Note also that the curly-brace folding arrows have disappeared from the left margin.

The div class does not appear to matter.

### Describe the behavior you expected

I expected the code-chunk to be unaffected by the addition of the div.

- [x] I have read the guide for [submitting good bug reports](https://github.com/rstudio/rstudio/wiki/Writing-Good-Bug-Reports).
- [x] I have installed the latest version of RStudio, and confirmed that the issue still persists.
- [x] If I am reporting an RStudio crash, I have included a [diagnostics report](https://support.posit.co/hc/en-us/articles/200321257-Running-a-Diagnostics-Report).
- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
d-morrison commented 1 month ago

probably related to https://github.com/rstudio/rstudio/issues/14652, https://github.com/rstudio/rstudio/issues/14642, and https://github.com/rstudio/rstudio/issues/14640; I missed those issues before posting, but after now finding them, I'm guessing my report is effectively redundant. I'll leave it open and let the pros decide?

ronblum commented 1 month ago

@d-morrison Thank you for raising this, and calling out the other issues! This looks like a variation of #14640. I'll close this as a duplicate and add your observation regarding reformatting (contrast with reindenting).