Skip to content

Commit 51cdcfa

Browse files
DanielC-NNicolas
andauthored
fix(#338): now 'number' prompt type never renders '-Infinity' when pressing up or down arrows (#430)
* fix(number): now 'number' prompt type never renders '-inifinity' when pressing up or down arrows * fix(#338): now 'number' prompt type never renders '-Infinity' when pressing up or down arrows --------- Co-authored-by: Nicolas <[email protected]>
1 parent e051991 commit 51cdcfa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/elements/number.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class NumberPrompt extends Prompt {
124124
up() {
125125
this.typed = ``;
126126
if(this.value === '') {
127-
this.value = this.min - this.inc;
127+
this.value = this.min === -Infinity ? 0 - this.inc : this.min - this.inc;
128128
}
129129
if (this.value >= this.max) return this.bell();
130130
this.value += this.inc;
@@ -136,7 +136,7 @@ class NumberPrompt extends Prompt {
136136
down() {
137137
this.typed = ``;
138138
if(this.value === '') {
139-
this.value = this.min + this.inc;
139+
this.value = this.min === -Infinity ? 0 + this.inc : this.min + this.inc;
140140
}
141141
if (this.value <= this.min) return this.bell();
142142
this.value -= this.inc;
@@ -150,7 +150,7 @@ class NumberPrompt extends Prompt {
150150
if (val.length === 0) return this.bell();
151151
this.value = this.parse((val = val.slice(0, -1))) || ``;
152152
if (this.value !== '' && this.value < this.min) {
153-
this.value = this.min;
153+
this.value = this.min === -Infinity ? 0 : this.min;
154154
}
155155
this.color = `cyan`;
156156
this.fire();

0 commit comments

Comments
 (0)