diff --git a/lib/generate.js b/lib/generate.js
index <HASH>..<HASH> 100644
--- a/lib/generate.js
+++ b/lib/generate.js
@@ -11,15 +11,28 @@ function dedentFunc(func) {
         return [lines[0].replace(/^\s+|\s+$/g, '')];
     }
 
-    var match = /^\s*/.exec(lines[lines.length-1]);
-    var indent = match[0];
-    return lines
-        .map(function dedent(line) {
-            if (line.slice(0, indent.length) === indent) {
-                return line.slice(indent.length);
+    var indent = null;
+    var tail = lines.slice(1);
+    for (var i = 0; i < tail.length; i++) {
+        var match = /^\s+/.exec(tail[i]);
+        if (match) {
+            if (indent === null ||
+                match[0].length < indent.length) {
+                indent = match[0];
             }
-            return line;
-        });
+        }
+    }
+
+    if (indent === null) {
+        return lines;
+    }
+
+    return lines.map(function dedent(line) {
+        if (line.slice(0, indent.length) === indent) {
+            return line.slice(indent.length);
+        }
+        return line;
+    });
 }
 
 function serializeSymbol(s) {
lib/generate: generalize dedentFunc

Take take the min indent after the first line; now only has edge cases
if we see mixed tabs and spaces in the input.