Skip to content

Commit

Permalink
Merge pull request #614 from REditorSupport/fix609
Browse files Browse the repository at this point in the history
make sure column is defined
  • Loading branch information
randy3k committed Apr 21, 2023
2 parents ec39b06 + 8866f58 commit b42e0e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ DiagnosticSeverity <- list(
diagnostic_range <- function(result, content) {
line <- result$line_number - 1
column <- result$column_number - 1
if (is.null(column) || is.na(column)) {
column <- 0
}
text <- if (line + 1 <= length(content)) content[line + 1] else ""
if (is.null(result$ranges)) {
cols <- code_point_to_unit(text, c(column, column + 1))
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ code_point_from_unit <- function(line, units) {
#'
#' @noRd
code_point_to_unit <- function(line, pts) {
pts[pts < 0] <- 0
if (!nzchar(line)) return(pts)
offsets <- c(0, cumsum(ncodeunit(strsplit(line, "")[[1]])))
result <- offsets[pts + 1]
Expand Down

0 comments on commit b42e0e3

Please sign in to comment.