From 44fec5abfdcce644b6913d01a8ce2971cca8dd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Thu, 17 Mar 2016 07:16:06 +0800 Subject: [PATCH] Store the stacks indefinitely --- botanjs/src/Components/Vim/State/Recorder.js | 10 ++++++++-- botanjs/src/Components/Vim/State/Stack.js | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/botanjs/src/Components/Vim/State/Recorder.js b/botanjs/src/Components/Vim/State/Recorder.js index 1ba8a59..8e095f4 100644 --- a/botanjs/src/Components/Vim/State/Recorder.js +++ b/botanjs/src/Components/Vim/State/Recorder.js @@ -4,7 +4,9 @@ var Recorder = function() { this.__steps = []; + this.__stacks = []; this.__i = 0; + this.__j = 0; }; Recorder.prototype.undo = function() @@ -31,8 +33,12 @@ Recorder.prototype.record = function( StateObj ) { - this.__steps[ this.__i ] = StateObj; - StateObj.id = this.__i ++; + this.__steps[ this.__i ++ ] = StateObj; + this.__stacks[ this.__j ++ ] = StateObj; + + delete this.__steps[ this.__i ]; + + StateObj.id = this.__j; }; ns[ NS_EXPORT ]( EX_CLASS, "Recorder", Recorder ); diff --git a/botanjs/src/Components/Vim/State/Stack.js b/botanjs/src/Components/Vim/State/Stack.js index 0e7d561..5096ccc 100644 --- a/botanjs/src/Components/Vim/State/Stack.js +++ b/botanjs/src/Components/Vim/State/Stack.js @@ -4,10 +4,7 @@ /** @type {Components.Vim.DateTime} */ var RelativeTime = __import( "Components.Vim.DateTime.RelativeTime" ); - var Stack = function() - { - - }; + var Stack = function() { }; Stack.prototype.store = function( handler ) {