From afea8ffe7ae5704c7f7307c69b8102bcbddce969 Mon Sep 17 00:00:00 2001 From: Mathew Date: Thu, 20 Jun 2019 12:40:56 +0200 Subject: [PATCH] better command history --- public/main.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/main.js b/public/main.js index 126f92f..c881cf3 100644 --- a/public/main.js +++ b/public/main.js @@ -1358,20 +1358,22 @@ class Con { commands: [""], push(com) { - this.commands.push(com) + this.commands.splice(1, 0, com) this.counter = 0 return this }, increment() { - this.counter++ - if (this.counter > this.commands.length - 1) this.counter = 0 + // this.counter++ + if (this.counter < this.commands.length - 1) this.counter++ + return this }, decrement() { - this.counter-- - if (this.counter < 0) this.counter = this.commands.length - 1 + // this.counter-- + if (this.counter > 0) this.counter-- + return this }, @@ -1380,12 +1382,12 @@ class Con { }, get up() { - this.decrement() + this.increment() return this.commands[this.counter] }, get down() { - this.increment() + this.decrement() return this.commands[this.counter] }