From bf83fb7b10091d7c76c489330b46cd0f96682478 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 21 Nov 2014 11:06:22 -0800 Subject: [PATCH] :arrow_up: text-buffer@3.7.0 for checkpoints Also add methods on TextEditor to expose the new checkpoint functionality --- package.json | 2 +- src/text-editor.coffee | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4db00fd30..fdd3e62cf 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "serializable": "^1", "space-pen": "3.8.2", "temp": "0.7.0", - "text-buffer": "^3.6.1", + "text-buffer": "^3.7.0", "theorist": "^1.0.2", "underscore-plus": "^1.6.1", "vm-compatibility-layer": "0.1.0" diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 6701108d0..012666d5d 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -1126,6 +1126,32 @@ class TextEditor extends Model # within the transaction. abortTransaction: -> @buffer.abortTransaction() + # Experimental: Create a pointer to the current state of the buffer for use + # with {::revertToCheckpoint} and {::groupChangesSinceCheckpoint}. + # + # Returns a checkpoint value. + createCheckpoint: -> @buffer.createCheckpoint() + + # Experimental: Revert the buffer to the state it was in when the given + # checkpoint was created. + # + # The redo stack will be empty following this operation, so changes since the + # checkpoint will be lost. If the given checkpoint is no longer present in the + # undo history, no changes will be made to the buffer and this method will + # return `false`. + # + # Returns a {Boolean} indicating whether the operation succeeded. + revertToCheckpoint: (checkpoint) -> @buffer.revertToCheckpoint(checkpoint) + + # Experimental: Group all changes since the given checkpoint into a single + # transaction for purposes of undo/redo. + # + # If the given checkpoint is no longer present in the undo history, no + # grouping will be performed and this method will return `false`. + # + # Returns a {Boolean} indicating whether the operation succeeded. + groupChangesSinceCheckpoint: (checkpoint) -> @buffer.groupChangesSinceCheckpoint(checkpoint) + ### Section: TextEditor Coordinates ###