Comparing version 1.1.0 to 1.1.1
@@ -115,4 +115,4 @@ 'use strict'; | ||
let s2 = this.input.slice(this.cursor); | ||
this.cursor = this.cursor + 1; | ||
this.input = `${s1}${c}${s2}`; | ||
this.cursor = s1.length + 1; | ||
this.complete(this.render); | ||
@@ -123,3 +123,3 @@ this.render(); | ||
delete() { | ||
if (this.input.length === 0) return this.bell(); | ||
if (this.cursor === 0) return this.bell(); | ||
let s1 = this.input.slice(0, this.cursor - 1); | ||
@@ -133,2 +133,11 @@ let s2 = this.input.slice(this.cursor); | ||
deleteForward() { | ||
if (this.cursor * this.scale >= this.rendered.length) return this.bell(); | ||
let s1 = this.input.slice(0, this.cursor); | ||
let s2 = this.input.slice(this.cursor + 1); | ||
this.input = `${s1}${s2}`; | ||
this.complete(this.render); | ||
this.render(); | ||
} | ||
first() { | ||
@@ -135,0 +144,0 @@ this.moveSelect(0); |
@@ -129,6 +129,5 @@ 'use strict'; | ||
let s2 = this.value.slice(this.cursor); | ||
this.moveCursor(1); | ||
this.value = `${s1}${c}${s2}`; | ||
this.red = false; | ||
if (this.placeholder) this.cursor = 0; | ||
this.cursor = this.placeholder ? 0 : s1.length + 1; | ||
this.render(); | ||
@@ -138,3 +137,3 @@ } | ||
delete() { | ||
if (this.value.length === 0) return this.bell(); | ||
if (this.cursor === 0) return this.bell(); | ||
let s1 = this.value.slice(0, this.cursor - 1); | ||
@@ -148,2 +147,11 @@ let s2 = this.value.slice(this.cursor); | ||
deleteForward() { | ||
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell(); | ||
let s1 = this.value.slice(0, this.cursor); | ||
let s2 = this.value.slice(this.cursor + 1); | ||
this.value = `${s1}${s2}`; | ||
this.red = false; | ||
this.render(); | ||
} | ||
first() { | ||
@@ -150,0 +158,0 @@ this.cursor = 0; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
if (key.name === 'backspace') return 'delete'; | ||
if (key.name === 'delete') return 'deleteForward'; | ||
if (key.name === 'abort') return 'abort'; | ||
@@ -16,0 +17,0 @@ if (key.name === 'escape') return 'abort'; |
@@ -100,4 +100,4 @@ 'use strict'; | ||
let s2 = this.input.slice(this.cursor); | ||
this.cursor = this.cursor+1; | ||
this.input = `${s1}${c}${s2}`; | ||
this.cursor = s1.length+1; | ||
this.complete(this.render); | ||
@@ -108,3 +108,3 @@ this.render(); | ||
delete() { | ||
if (this.input.length === 0) return this.bell(); | ||
if (this.cursor === 0) return this.bell(); | ||
let s1 = this.input.slice(0, this.cursor-1); | ||
@@ -117,2 +117,11 @@ let s2 = this.input.slice(this.cursor); | ||
} | ||
deleteForward() { | ||
if(this.cursor*this.scale >= this.rendered.length) return this.bell(); | ||
let s1 = this.input.slice(0, this.cursor); | ||
let s2 = this.input.slice(this.cursor+1); | ||
this.input = `${s1}${s2}`; | ||
this.complete(this.render); | ||
this.render(); | ||
} | ||
@@ -119,0 +128,0 @@ first() { |
@@ -107,6 +107,5 @@ const color = require('kleur'); | ||
let s2 = this.value.slice(this.cursor); | ||
this.moveCursor(1); | ||
this.value = `${s1}${c}${s2}`; | ||
this.red = false; | ||
if (this.placeholder) this.cursor = 0; | ||
this.cursor = this.placeholder ? 0 : s1.length+1; | ||
this.render(); | ||
@@ -116,3 +115,3 @@ } | ||
delete() { | ||
if (this.value.length === 0) return this.bell(); | ||
if (this.cursor === 0) return this.bell(); | ||
let s1 = this.value.slice(0, this.cursor-1); | ||
@@ -125,2 +124,11 @@ let s2 = this.value.slice(this.cursor); | ||
} | ||
deleteForward() { | ||
if(this.cursor*this.scale >= this.rendered.length || this.placeholder) return this.bell(); | ||
let s1 = this.value.slice(0, this.cursor); | ||
let s2 = this.value.slice(this.cursor+1); | ||
this.value = `${s1}${s2}`; | ||
this.red = false; | ||
this.render(); | ||
} | ||
@@ -127,0 +135,0 @@ first() { |
@@ -14,2 +14,3 @@ 'use strict'; | ||
if (key.name === 'backspace') return 'delete'; | ||
if (key.name === 'delete') return 'deleteForward'; | ||
if (key.name === 'abort') return 'abort'; | ||
@@ -16,0 +17,0 @@ if (key.name === 'escape') return 'abort'; |
{ | ||
"name": "prompts", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Lightweight, beautiful and user-friendly prompts", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109175
2620