فهرست منبع

Make h2d.Console ignore duplicates in command history

Leonardo Jeanteur 3 سال پیش
والد
کامیت
7fba08f8f5
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      h2d/Console.hx

+ 8 - 2
h2d/Console.hx

@@ -374,18 +374,24 @@ class Console #if !macro extends h2d.Object #end {
 				curCmd = tf.text;
 				logIndex = logs.length - 1;
 			}
-			else logIndex--;
+			else {
+				var curLog = logs[logIndex];
+				while(curLog == logs[logIndex] && logIndex > 0)
+					logIndex--;
+			}
 			tf.text = logs[logIndex];
 			tf.cursorIndex = tf.text.length;
 		case Key.DOWN:
 			if(tf.text == curCmd) return;
+			var curLog = logs[logIndex];
+			while(curLog == logs[logIndex] && logIndex < logs.length - 1)
+				logIndex++;
 			if(logIndex == logs.length - 1) {
 				tf.text = curCmd == null ? "" : curCmd;
 				tf.cursorIndex = tf.text.length;
 				logIndex = -1;
 				return;
 			}
-			logIndex++;
 			tf.text = logs[logIndex];
 			tf.cursorIndex = tf.text.length;
 		}