From a2908fc2f300d038db30424a378e3c40d28868f8 Mon Sep 17 00:00:00 2001 From: otya128 Date: Mon, 12 Dec 2016 20:07:12 +0900 Subject: [PATCH] Fix input history --- SMILEBASIC/petitcomputer.d | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 13dce1c..e0e51f0 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -8,6 +8,7 @@ import std.file; import std.stdio; import std.conv; import std.string; +import std.range; import core.stdc.stdio; import core.sync.mutex; import core.sync.condition; @@ -996,7 +997,10 @@ class PetitComputer printPrompt(); } auto prg = input("", true); - inputHistory.put(prg); + if (!prg.empty && (inputHistory.length == 0 || inputHistory[inputHistory.length - 1] != prg)) + { + inputHistory.put(prg); + } auto lex = new Lexical(prg); lex.popFront(); auto token = lex.front();