Skip to content

Diagnostic source markers in the editor gutter get muddled when both "Run diagnostics in background" and "Check code for problems when saving" are checked #10430

Closed

Description

@jgutman

System details

RStudio Edition : Desktop
RStudio Version : 2022.06.0-daily+26
OS Version      :  macOS Monterey 12.1, aarch64-apple-darwin20 (64-bit)
R Version       :  R-devel (4.2 2022-01-11 r81471)

Steps to reproduce the problem

The behavior is wonky and difficult to pin down, but here's my best attempt and reproducing the behavior.

  1. Create a file with a bunch of diagnostic issues:
add_numbers <- function(x,y) {
  x + y
}

add_numbers(1)

list(
  first = 1
  second = 2
)

hw <- HoltWinters(ldeaths)
p <- predict(HW, n.ahead = 36, level = 0.95)

add_two <- function(number_1, number_2) {
  result <- number_1 + number_2
  return(number_1 + number_2)
}

x<-2+1   # comment
  1. In Tools > Global Options > Code Diagnostics, select the following options
    image

Diagnostic markers appear in the gutter, on lines 5, 8, 13, 16, and 20. Great.

  1. Edit the file, adding 2 blank lines after line 11. Save the file. Restart R Session (Shift + Cmd + 0).

Now the source markers in the gutter are all messed up. All markers now appear twice. Old line 5 and old line 8 are still on lines 5 and 8, and the markers on those lines are duplicated (one with unrendered symbols, one correctly). Old line 13 and old line 20 are still there, despite the associated code having been moved, and the symbols are not rendered correctly, but they also appear on lines 15 and 22, where they should be, and rendered correctly.

image
image

I was also able to produce the same issue even with "Run diagnostics in background" unchecked and "Check code for problems when saving", with or without refreshing the R session.

Describe the problem in detail

There's a weird persistence and duplication of source markers when refreshing the R session. Sometimes, it seems like this can happen even without refreshing the R session. Sometimes, it seems like this can happen even if only one of "Check code for problems when saving" or "Run diagnostics in background" are checked.

Describe the behavior you expected

Source markers should render correctly and only display on the line of code where the associated code now lives.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. jgutman commented on Jan 26, 2022

    @jgutman
    ContributorAuthor

    cc @kevinushey who might be familiar with what's going on here

  2. jgutman commented on Jan 26, 2022

    @jgutman
    ContributorAuthor

    This behavior does not exist in 2022.02.0-preview+405 or 2022.06.0-daily+13. It appears to be introduced in 2022.06.0-daily+14

  3. astayleraz commented on Jan 26, 2022

    @astayleraz
    Contributor
  4. timtmok commented on Jan 31, 2022

    @timtmok
    Contributor

    I've reproduced it successfully now. Restarting R definitely triggers it. The code diagnostics has to have run so it produces source markers. Restarting R likely triggers the linting code and adds the source markers for the gutter, which creates the duplicates.

  5. jgutman commented on Feb 1, 2022

    @jgutman
    ContributorAuthor

    Note that we can see this duplicate issue in the diagnostics under the visual markdown editor as well.

    image

    Code:

    {r}
    print(b)
    b <- "hello world!"
    

    when editing the markdown in Visual mode and restarting the R session

  6. jgutman commented on Feb 8, 2022

    @jgutman
    ContributorAuthor

    Verified this is fixed in RStudio Desktop 2022.06.0+76, tested on Mac OS 12.2 with R-devel 4.2.0

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions