From 03463da72928cdb3dbe6aa77be1c09bdcabe3d1b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 2 Jun 2014 17:48:40 +0900 Subject: [PATCH] Allow Editor::batchUpdates calls to be nested --- src/editor.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/editor.coffee b/src/editor.coffee index acf03251d..b676130e4 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -144,6 +144,7 @@ class Editor extends Model cursors: null selections: null suppressSelectionMerging: false + updateBatchDepth: 0 @delegatesMethods 'suggestedIndentForBufferRow', 'autoIndentBufferRow', 'autoIndentBufferRows', 'autoDecreaseIndentForBufferRow', 'toggleLineCommentForBufferRow', 'toggleLineCommentsForBufferRows', @@ -1842,9 +1843,11 @@ class Editor extends Model abortTransaction: -> @buffer.abortTransaction() batchUpdates: (fn) -> - @emit 'batched-updates-started' + @emit 'batched-updates-started' if @updateBatchDepth is 0 + @updateBatchDepth++ result = fn() - @emit 'batched-updates-ended' + @updateBatchDepth-- + @emit 'batched-updates-ended' if @updateBatchDepth is 0 result inspect: ->