mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Fix bugs reported by @daattali
- reactive srcrefToLabel call fails if code is pasted in at RStudio console - Stack trace fails when promise (!?) is in call stack
This commit is contained in:
@@ -67,6 +67,8 @@ getCallNames <- function(calls) {
|
||||
"<Anonymous>"
|
||||
} else if (inherits(call[[1]], "call")) {
|
||||
paste0(format(call[[1]]), collapse = " ")
|
||||
} else if (typeof(call[[1]]) == "promise") {
|
||||
"<Promise>"
|
||||
} else {
|
||||
paste0(as.character(call[[1]]), collapse = " ")
|
||||
}
|
||||
|
||||
@@ -520,7 +520,18 @@ srcrefToLabel <- function(srcref, defaultLabel) {
|
||||
if (is.null(srcfile$lines))
|
||||
return(defaultLabel)
|
||||
|
||||
firstLine <- substring(srcfile$lines[srcref[1]], 1, srcref[2] - 1)
|
||||
lines <- srcfile$lines
|
||||
# When pasting at the Console, srcfile$lines is not split
|
||||
if (length(lines) == 1) {
|
||||
lines <- strsplit(lines, "\n")[[1]]
|
||||
}
|
||||
|
||||
if (length(lines) < srcref[1]) {
|
||||
return(defaultLabel)
|
||||
}
|
||||
|
||||
firstLine <- substring(lines[srcref[1]], 1, srcref[2] - 1)
|
||||
|
||||
m <- regexec("(.*)(<-|=)\\s*reactive\\s*\\($", firstLine)
|
||||
if (m[[1]][1] == -1) {
|
||||
return(defaultLabel)
|
||||
|
||||
Reference in New Issue
Block a user