Christophe Weblog Wiki Code Publications Music
fix bug #21
authorChristophe Rhodes <csr21@cantab.net>
Mon, 23 Apr 2012 10:33:44 +0000 (11:33 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Mon, 23 Apr 2012 10:33:44 +0000 (11:33 +0100)
%in% needs a `vector' first argument, so make it so, listifying
anything that isn't already a vector.  (Note: there seem to be plenty
of non-vector first arguments that work, such as
as.Date("2012-01-01"), which returns FALSE to is.vector() -- but the new
code seems to get that right anyway, based on very limited testing.

BUGS.org
swank.R

index 7132a71a463442cb8ed34a70f281b634ffb617c7..3976058af6284b03472c6712507b3fe74c763cc2 100644 (file)
--- a/BUGS.org
+++ b/BUGS.org
@@ -74,7 +74,7 @@
   I'm not sure what else that does.
 * RESOLVED #20 closing the connection causes infinite R errors    :IMPORTANT:
   reported by "Philipp Marek" <philipp@marek.priv.at> by private mail.
-* OPEN #21 inspecting an environment causes error in match()          :MINOR:
+* RESOLVED #21 inspecting an environment causes error in match()      :MINOR:
   reported by "Philipp Marek" <philipp@marek.priv.at> by private mail.
 
   To reproduce, C-c I globalenv() RET, or hit RET on environment
diff --git a/swank.R b/swank.R
index 20311847afef86a62468a50c58b0f1962cc7dc9b..d91c35fdbd3663c3d8312a2a204a3e6a0ec73af7 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -601,12 +601,19 @@ resetInspector <- function(slimeConnection) {
 }
 
 inspectObject <- function(slimeConnection, object) {
+  vectorify <- function(x) {
+    if(is.vector(x)) {
+      x
+    } else {
+      list(x)
+    }
+  }
   previous <- slimeConnection$istate
   slimeConnection$istate <- new.env()
   slimeConnection$istate$object <- object
   slimeConnection$istate$previous <- previous
   slimeConnection$istate$content <- emacsInspect(object)
-  if(!(object %in% slimeConnection$inspectorHistory)) {
+  if(!(vectorify(object) %in% slimeConnection$inspectorHistory)) {
     slimeConnection$inspectorHistory <- c(slimeConnection$inspectorHistory, object)
   }
   if(!is.null(slimeConnection$istate$previous)) {