diff --git a/lib/parinfer.js b/lib/parinfer.js
index <HASH>..<HASH> 100644
--- a/lib/parinfer.js
+++ b/lib/parinfer.js
@@ -1006,6 +1006,10 @@ function updateRememberedParenTrail(result) {
   }
   else {
     trail.endX = result.parenTrail.endX;
+    if (result.returnParens) {
+      var opener = result.parenTrail.openers[result.parenTrail.openers.length-1];
+      opener.closer.trail = trail;
+    }
   }
 }
 
diff --git a/lib/sandbox.js b/lib/sandbox.js
index <HASH>..<HASH> 100644
--- a/lib/sandbox.js
+++ b/lib/sandbox.js
@@ -9,8 +9,9 @@ const parinferTest = require('./test');
 const parinfer = require('./parinfer');
 
 const code = `
-(foo
-  |)
+(bar
+  |(foo)
+  )
 `;
 
 console.log(parinferTest.smartMode(code, {printParensOnly: true}));
mark leading close-parens as paren trails in the paren tree