Skip to content

Instantly share code, notes, and snippets.

@simonpcouch
Created December 9, 2024 22:16
Show Gist options
  • Save simonpcouch/a0eea0d2a295fce8c0611a631dd54d91 to your computer and use it in GitHub Desktop.
Save simonpcouch/a0eea0d2a295fce8c0611a631dd54d91 to your computer and use it in GitHub Desktop.

Revisions

  1. simonpcouch created this gist Dec 9, 2024.
    640 changes: 640 additions & 0 deletions positron_prefixing_issue.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,640 @@
    A log of a problematic run of a prefixing (roxygen) pal in Positron using [these changes](https://github.com/simonpcouch/pal/commit/65094cd0097e4260bd4de35430a70341f0767cdb). Search for the first instance of `key_get()``modifyRange()` attempts to add a `"#' @"` in its sixth line, but the `rstudioapi::getActiveDocumentContext()` call immediately after it doesn't find it (and instead finds the line that follows what should be there) and instead picks up `key_get <- ...`, which is erroneously replaced in the next iteration.

    ```
    io$last_run
    $before
    $before$row_start_end
    [1] 1 1
    $before$before
    [1] ""
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 0 99999
    $during$text
    [1] "#"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 1
    $after$new_lines
    [1] "#"
    $before
    $before$row_start_end
    [1] 1 1
    $before$before
    [1] "#"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 0 99999
    $during$text
    [1] "#' Get environment variable values"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 1
    $after$new_lines
    [1] "#' Get environment variable values"
    $before
    $before$row_start_end
    [1] 1 1
    $before$before
    [1] "#' Get environment variable values"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 0 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 3
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#"
    $before
    $before$row_start_end
    [1] 1 3
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 2 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 3
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#"
    $before
    $before$row_start_end
    [1] 1 3
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 2 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 4
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param"
    $before
    $before$row_start_end
    [1] 1 4
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 3 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 4
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param"
    $before
    $before$row_start_end
    [1] 1 4
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 3 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 5
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    $before
    $before$row_start_end
    [1] 1 5
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 4 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 6
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    [6] "key_get <- function(name, error_call = caller_env()) {"
    $before
    $before$row_start_end
    [1] 1 6
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    [6] "key_get <- function(name, error_call = caller_env()) {"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 5 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 7
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    [6] "key_get <- function(name, error_call = caller_env()) {"
    [7] " val <- Sys.getenv(name)"
    $before
    $before$row_start_end
    [1] 1 7
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#"
    [6] "key_get <- function(name, error_call = caller_env()) {"
    [7] " val <- Sys.getenv(name)"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 6 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable."
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 7
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable."
    $before
    $before$row_start_end
    [1] 1 7
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable."
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 6 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 7
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not"
    $before
    $before$row_start_end
    [1] 1 7
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 6 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 8
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not"
    [8] " val <- Sys.getenv(name)"
    $before
    $before$row_start_end
    [1] 1 8
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 7 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 9
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    $before
    $before$row_start_end
    [1] 1 9
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 8 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    [10] "#' @export"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 10
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    [10] " val <- Sys.getenv(name)"
    $before
    $before$row_start_end
    [1] 1 10
    $before$before
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    [10] "#' @export"
    $during
    $during$ranges
    $during$ranges[[1]]
    [1] 0 0 9 99999
    $during$text
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    [10] "#' @export"
    $during$id
    NULL
    $after
    $after$row_start_end
    [1] 1 10
    $after$new_lines
    [1] "#' Get environment variable values"
    [2] "#'"
    [3] "#' @param name A single string."
    [4] "#' @param error_call Optional. The execution environment to use in error messages."
    [5] "#'"
    [6] "#' @returns"
    [7] "#' The value of the requested environment variable. Errors if the variable is not set"
    [8] "#' or is empty."
    [9] "#'"
    [10] "#' @export"
    ```