aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/completion.js')
-rw-r--r--src/console/completion.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/console/completion.js b/src/console/completion.js
index 0c21cb0..4c69afb 100644
--- a/src/console/completion.js
+++ b/src/console/completion.js
@@ -3,15 +3,16 @@ export default class Completion {
if (typeof completions.length !== 'number') {
throw new TypeError('completions does not have a length in number');
}
- this.completions = completions
+ this.completions = completions;
this.index = 0;
}
prev() {
- if (this.completions.length === 0) {
+ let length = this.completions.length;
+ if (length === 0) {
return null;
}
- this.index = (this.index + this.completions.length - 1) % this.completions.length
+ this.index = (this.index + length - 1) % length;
return this.completions[this.index];
}
@@ -20,7 +21,7 @@ export default class Completion {
return null;
}
let item = this.completions[this.index];
- this.index = (this.index + 1) % this.completions.length
+ this.index = (this.index + 1) % this.completions.length;
return item;
}
}