Skip to content

Commit

Permalink
temporary fix for #209 -- workaround bug in RStudio
Browse files Browse the repository at this point in the history
  • Loading branch information
achubaty committed Oct 29, 2015
1 parent 485c8f6 commit d1f8af3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Expand Up @@ -11,8 +11,8 @@ Description: Easily implement a variety of simulation models, with a focus on
installed with `install.packages("fastshp", repos="http://rforge.net",
type="source")`.
URL: https://github.com/PredictiveEcology/SpaDES
Version: 1.0.3.9007
Date: 2015-10-28
Version: 1.0.3.9008
Date: 2015-10-29
Authors@R: c(
person(c("Alex", "M"), "Chubaty", email="alexander.chubaty@canada.ca",
role=c("aut", "cre")),
Expand Down Expand Up @@ -100,4 +100,5 @@ Collate:
'spades-package.R'
'splitRaster.R'
'spread-process.R'
'temp.R'
'zzz.R'
44 changes: 44 additions & 0 deletions R/temp.R
@@ -0,0 +1,44 @@
### TEMPORARY FIX FOR ISSUE #209 -- FIXES RSTUDIO BUG
### https://github.com/achubaty/rstudio/commit/378ae10a29a3c6a0eb7680ff7f99d495b44aed9c
### pull request to come, pending copyright transfer agreement form

options(editor = function(name, file, title) {

# use internal editor for files and functions, otherwise
# delegate to the default editor
if (missing(name) || is.null(name) || is.function(name)) {

# if no name then use file
if (missing(name) || is.null(name)) {
if (!is.null(file) && nzchar(file))
targetFile <- file
else
targetFile <- scratchFile
}
# otherwise it's a function, write it to a file for editing
else {
functionSrc <- .rs.deparseFunction(name, TRUE, FALSE)
targetFile <- scratchFile
writeLines(functionSrc, targetFile)
}

# invoke the RStudio editor on the file
if (.Call("rs_editFile", targetFile)) {

# try to parse it back in
newFunc <- try(eval.parent(parse(targetFile)),
silent = TRUE)
if (inherits(newFunc, "try-error")) {
stop(newFunc, "You can attempt to correct the error using ",
title, " = edit()")
}

return(newFunc)
}
else {
stop("Error occurred while editing function '", name, "'")
}
}
else
edit(name, file, title, editor=defaultEditor)
})

0 comments on commit d1f8af3

Please sign in to comment.