Skip to content

Function after an empty div breaks source code blocks in Quarto document #14652

Closed

Description

@kmmsks

Verify fixed in:

  • Patch: 2024.04.2
  • Release: 2024.07.0

System details

RStudio Edition : Desktop
RStudio Version : 2024.04.0+735 Chocolate Cosmos (desktop)
OS Version      : macOS Sonoma 14.4.1
R Version       :  4.4.0 (2024-04-24)

Steps to reproduce the problem

I have quarto document (code A:starting_point below) in Rstudio. It renders as it should, but the Run All Chunks Above button does not work.

When I insert a code chunk above the ### Refs -section, unexpected behaviour takes place. This is shown in code (A:unexpected).

If there is not a function defined in the last code block (see example B1), inserting a new code chunk above the ### Refs section works as expected (outcome shown in code B2) and now, the Run All Chunks Above button does work.

If I remove
::: {#refs} :::

from the code (A:starting_point) this odd behaviour disappears.

This issue seems to share some features with issue #14642

A:starting_point:

---
title: "Untitled"
format: html
---

## Quarto


```{r}

c(1, 2)

```



### Refs

::: {#refs}
:::

## Next

```{r}

my_fun <- function(x){
x+1
}
my_fun(1)

```

Consider code A:starting_point, move cursor between the first code block and the row containing ### Refs, and press Insert a new code chunk to reproduce the problem.

Describe the problem in detail

In the code A:starting_point, when there is a function defined after the ### Refs -section, unexpected behavior (code A:unexpected) is seen as far as I concern. What I would expect, is the code A:expected

The same happens if there is
::: {} :::

instead of
::: {#refs} :::

and the same happens if bibliography is defined in YAML: f.ex. bibliography: references.bib

The example function works as expected in a plain R script file.

In the example B1 (below), there is not a function defined after the section ### Refs, and what I get after inserting a new code chunk before the ### Refs section is as expected (see B2)

In Rmd-document, this issue does not take place.

Describe the behavior you expected

The expected outcome is as follows:

A:expected

---
title: "Untitled"
format: html
---

## Quarto



```{r}

c(1, 2)

```

```{r}

```


### Refs

::: {#refs}
:::

## Next

```{r}

my_fun <- function(x){
x+1
}
my_fun(1)

```

Consider code B1. Again, move cursor between the first code block and the row containing ### Refs, and press Insert a new code chunk.

B1:

---
title: "Untitled"
format: html
---

## Quarto


```{r}

c(1, 2)

```



### Refs

::: {#refs}
:::

## Next

```{r}

my_fun <- c(2,3)
my_fun

```

Now I get the expected behavior (see code B2), as there is not a function defined in the last code chunk.

B2:

---
title: "Untitled"
format: html
---

## Quarto


```{r}

c(1, 2)

```

```{r}

```


### Refs

::: {#refs}
:::

## Next

```{r}

my_fun <- c(2,3)
my_fun

```

Actual behavior

In the case of the code A:starting_point, what I get after pressing the Insert a new code chunk -button is the following:

A:unexpected:

---
title: "Untitled"
format: html
---

## Quarto


```{r}
c(1, 2)

```
```


```{r}
### Refs

::: {#refs}
:::

## Next

```{r}

my_fun <- function(x){
x+1
}
my_fun(1)

```
  • [x ] I have read the guide for submitting 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.
  • [ x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on May 6, 2024
  2. ronblum commented on May 6, 2024

    @ronblum
    Contributor

    @kmmsks Thank you for raising this! I can reproduce this in RStudio Desktop 2024.04.0+735 on Windows 11 with both R 4.3.3 and 4.4.0. It works correctly in version 2023.12.1+402.

    Also, after removing the div (:::) section, I need to insert chunk, undo, and insert chunk again for inserting to work.

  3. added and removed
    new
    on May 6, 2024
  4. added this to the Cranberry Hibiscus milestone on May 6, 2024
  5. gtritchie commented on May 9, 2024

    @gtritchie
    Member

    Regression caused by #14558.

  6. olearydj commented on May 10, 2024

    @olearydj

    This may be related to the bug I posted today #14684

  7. ronblum commented on May 10, 2024

    @ronblum
    Contributor

    QA note: Include the example in #14684 when testing.

  8. jaredbrewer commented on May 13, 2024

    @jaredbrewer

    This and the indentation issue is a major problem for me. Unless there's a timeline for a fix, it may be necessary to revert to 2023.12 until this is resolved.

  9. ronblum commented on May 30, 2024

    @ronblum
    Contributor

    Verified in RStudio Desktop 2024.04.2+762.pro1 on Windows 11 using the original example. The followup of what happens when removing ::: is immaterial due to the fix.

  10. ronblum commented on May 30, 2024

    @ronblum
    Contributor

    Verified in RStudio Desktop 2024.07.0-daily+178.pro1 on Windows 11, as well.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions