better command history

This commit is contained in:
Mathew committed 2019-06-20 12:40:56 +02:00
1 parent 03a84481d8
commit afea8ffe7a
1 file changed
+9 -7
+9 -7
View File
@@ -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]
}