<commit_before>package org.robotlegs.utilities.undoablecommand
{
	
	
	import org.robotlegs.utilities.undoablecommand.interfaces.*;
	
	public class CommandHistory
	{
		static public const NUM_HISTORY_STATES:uint = 999;
		
		private var _historyStack:Vector.<IUndoableCommand>;
		
		public var currentPosition:uint;
		public var isReady:Boolean;
		
		public function CommandHistory() {
			_historyStack = new Vector.<IUndoableCommand>();
			currentPosition = 0;
		}
		
		public function get canStepForward():Boolean {
			// numberOfHistoryItems > 0
			// currentPosition < numberOfHistoryItems
			return (currentPosition < numberOfHistoryItems);
			
		}
		
		public function get canStepBackward():Boolean {
			return (currentPosition > 0);
		}
		
		public function stepForward():void {
			if (canStepForward) {
				_historyStack[currentPosition].execute();
			}
			currentPosition++;
		}
		
		public function stepBackward():void {
			if (canStepBackward) {
				_historyStack[currentPosition - 1].undo();
			}
			currentPosition--;
		}
		
		public function rewind():void {
			var count:uint = 0;
			while(canStepBackward) {
				stepBackward();
				count++;
				if (count > NUM_HISTORY_STATES) {
					throw new Error("Possible infinite loop.");
				}
			}
		}
		
		public function fastForward():void {
			var count:uint = 0;
			while(canStepForward) {
				stepForward();
				count++;
				if (count > NUM_HISTORY_STATES) {
					throw new Error("Possible infinite loop.");
				}
			}
		}
		
		public function get numberOfHistoryItems():uint {
			return _historyStack.length;
		}
		
		public function push(command:IUndoableCommand):void {
			
			if (currentPosition != numberOfHistoryItems) {
				_historyStack = _historyStack.slice(0, currentPosition);	
			}
			_historyStack.push(command);
			currentPosition = numberOfHistoryItems;
		}
	}
}<commit_msg>Fixed bug in stepBackward() where current position changed when history stack wasn't actually moved through<commit_after>package org.robotlegs.utilities.undoablecommand
{
	
	
	import org.robotlegs.utilities.undoablecommand.interfaces.*;
	
	public class CommandHistory
	{
		static public const NUM_HISTORY_STATES:uint = 999;
		
		private var _historyStack:Vector.<IUndoableCommand>;
		
		public var currentPosition:uint;
		public var isReady:Boolean;
		
		public function CommandHistory() {
			_historyStack = new Vector.<IUndoableCommand>();
			currentPosition = 0;
		}
		
		public function get canStepForward():Boolean {
			// numberOfHistoryItems > 0
			// currentPosition < numberOfHistoryItems
			return (currentPosition < numberOfHistoryItems);
			
		}
		
		public function get canStepBackward():Boolean {
			return (currentPosition > 0);
		}
		
		public function stepForward():void {
			if (canStepForward) {
				_historyStack[currentPosition++].execute();
			}
		}
		
		public function stepBackward():void {
			if (canStepBackward) {
				_historyStack[--currentPosition].undo();
			}
		}
		
		public function rewind():void {
			var count:uint = 0;
			while(canStepBackward) {
				stepBackward();
				count++;
				if (count > NUM_HISTORY_STATES) {
					throw new Error("Possible infinite loop.");
				}
			}
		}
		
		public function fastForward():void {
			var count:uint = 0;
			while(canStepForward) {
				stepForward();
				count++;
				if (count > NUM_HISTORY_STATES) {
					throw new Error("Possible infinite loop.");
				}
			}
		}
		
		public function get numberOfHistoryItems():uint {
			return _historyStack.length;
		}
		
		public function push(command:IUndoableCommand):void {
			
			if (currentPosition != numberOfHistoryItems) {
				_historyStack = _historyStack.slice(0, currentPosition);	
			}
			_historyStack.push(command);
			currentPosition = numberOfHistoryItems;
		}
	}
}
{'fraction_non_alphanumeric': 0.09836065573770492, 'fraction_numerical': 0.004866803278688525, 'mean_word_length': 2.9846938775510203, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6078075', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1121, 'n_words': 239}