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:
Joe Cheng
2015-11-24 11:55:08 -08:00
parent 179c931f85
commit b5e49a6619
2 changed files with 14 additions and 1 deletions

View File

@@ -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 = " ")
}

View File

@@ -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)