From e8ad4cb544c45194d4b8e8b165e78a88fbd0a17f Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 4 Jan 2010 07:37:58 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5714 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/res/operationHistory.js | 30 +++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/content/treestyletab/res/operationHistory.js b/content/treestyletab/res/operationHistory.js index 0571ae7b..75c9280f 100644 --- a/content/treestyletab/res/operationHistory.js +++ b/content/treestyletab/res/operationHistory.js @@ -155,10 +155,11 @@ this._doingUndo = true; var processed = false; - while (processed === false) - { - let error; - let data = history.entries[history.index--]; + var error; + do { + let data = history.entries[history.index]; + history.index = Math.max(0, history.index-1); + if (!data) continue; let f = this._getAvailableFunction(data.onUndo, data.onundo, data.undo); let done = false; try { @@ -175,9 +176,12 @@ } this._dispatchEvent('UIOperationGlobalHistoryUndo', options, data, done); } + while (processed === false && history.index > 0) this._doingUndo = false; - if (error) throw error; + if (error) + throw error; + return true; }, @@ -185,14 +189,17 @@ { var options = this._getOptionsFromArguments(arguments); var history = options.history; - if (history.index > history.entries.length-1) + var max = history.entries.length; + if (history.index > max-1) return false; this._doingUndo = true; var processed = false; - while (processed === false) - { - let error; + var error; + do { + let data = history.entries[history.index]; + history.index = Math.min(max-1, history.index+1); + if (!data) continue; let f = this._getAvailableFunction(data.onRedo, data.onredo, data.redo); let done = false; try { @@ -209,9 +216,12 @@ } this._dispatchEvent('UIOperationGlobalHistoryRedo', options, data, done); } + while (processed === false && history.index < max-1) this._doingUndo = false; - if (error) throw error; + if (error) + throw error; + return true; },