Merge pull request #656 from mathspace/#655-edit-handler-mismatched-brackets

[Mathspace] Reflow when closing brackets (Fixes #655)
diff --git a/src/commands/math/commands.js b/src/commands/math/commands.js
index 483d591..61b89c0 100644
--- a/src/commands/math/commands.js
+++ b/src/commands/math/commands.js
@@ -588,8 +588,8 @@
         Fragment(cursor[side], cursor.parent.ends[side], -side) // me and ghost outside
           .disown().withDirAdopt(-side, brack.parent, brack, brack[side])
           .jQ.insDirOf(side, brack.jQ);
-        brack.bubble('reflow');
       }
+      brack.bubble('reflow');
     }
     else {
       brack = this, side = brack.side;
diff --git a/test/unit/publicapi.test.js b/test/unit/publicapi.test.js
index 55645b6..4791491 100644
--- a/test/unit/publicapi.test.js
+++ b/test/unit/publicapi.test.js
@@ -304,6 +304,23 @@
       });
     }
   });
+  
+  suite('edit handler', function() {
+    test('fires when closing a bracket expression', function() {
+      var count = 0;
+      var mq = MQ.MathField($('<span>').appendTo('#mock')[0], {
+        handlers: {
+          edit: function() {
+            count += 1;
+          }
+        }
+      });
+      mq.typedText('(3, 4');
+      var countBeforeClosingBracket = count;
+      mq.typedText(']');
+      assert.equal(count, countBeforeClosingBracket + 1);
+    });
+  });
 
   suite('.cmd(...)', function() {
     var mq;