rstudio / rstudio

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

Reindent & Reformat Lines stopped working in Quarto Callout Blocks #14640

Open cy-james-lee opened 2 weeks ago

cy-james-lee commented 2 weeks ago

System details

RStudio Edition : Desktop
RStudio Version : 2024.04.0 Build 735
OS Version      : Windows 10 x64 (build 19045)
R Version       : 4.4.0 (2024-04-24 ucrt)

Steps to reproduce the problem

  1. Open/create a quarto document.
  2. Create a Callout Block
  3. Create a code block inside the callout block and write any multi-line code (that should have indentations).
  4. Select all lines in the code block and perform Reindent Lines (Ctrl + I).

Describe the problem in detail

All lines are moved to the left end, without any indentation.

::: {.callout-note collapse="true"}
```{r}
library(dplyr)
mtcars |> 
mutate(
mpg = seq_len(
n()
)
)

:::


### Describe the behavior you expected
Normal Reindent Lines (Ctrl + I) behavior is this:
library(dplyr)
mtcars |> 
  mutate(
    mpg = seq_len(
      n()
    )
  )

<!-- 
Please keep the below portion in your issue, and check `[x]` the applicable boxes.
-->

- [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.
ronblum commented 2 weeks ago

@cy-james-lee Thank you for raising the issue! I can reproduce this in RStudio Desktop 2024.04.1+735 on Windows 11.

Note: This is source mode only--it works in visual mode. Also, this works correctly in version 2023.12.1+402.

petzi53 commented 1 week ago

I experienced the same problem in source mode on macOS. In my case, it didn't work inside and outside Quarto blocks.

RStudio Edition : Desktop RStudio Version : 2024.04.0+735 OS Version : MacOS Sonoma 14.4.1 R Version : 4.4.0 (2024-04-24) -- "Puppy Cup" Quarto Version: 1.4.554

Indentation works with the previous RStudio Version 2023.12.1+402, but only with 2 spaces. The older version didn't respect changes (even after restarting RStudio) in the global and project configuration. (I didn't notice this before).

In visual mode, everything works in the older and the latest RStudio version.

cy-james-lee commented 1 week ago

I also noticed that collapsing code section doesn't work inside of callout blocks.

I always add session info at the end of Quarto inside of a collapsed callout like so:

::: {.callout-note collapse="true"}
## Session Info
```{r}
sessionInfo()

:::



I don't have the collapse button next to ## Session Info:
![image](https://github.com/rstudio/rstudio/assets/13931593/736e79c5-1f82-49ab-950f-905e8ac75547)

If I comment out the callout block enclosure, I get the collapse button back.
![image](https://github.com/rstudio/rstudio/assets/13931593/ad995df1-eb8f-4e73-8a5f-b6a5d0d9dae0)
ronblum commented 1 week ago

@petzi53 Can you provide a brief example of code in which you're seeing the issue?

@cy-james-lee I believe that what you're seeing is discussed in issue #14642.

ronblum commented 1 week ago

Also @d-morrison found that this happens with reformatting (cmd-shift-A or Menu Bar > Code > Reformat Code).

gtritchie commented 1 week ago

Regression caused by https://github.com/rstudio/rstudio/pull/14558.

LeenSonneveld commented 1 week ago

This seems to occcur (in source editor) not only after callout block, but any ::: (eg. ::: column, ::: panel-tabset