394
// Handle backspace key
395
if (this._lastUserInput === '\x7F') {
397
>
if (cursorIndex === this._cursorIndex - 1) {
398
>
// If trailing whitespace is being increased by removing a non-whitespace character
399
>
if (this._value.trimEnd().length > value.trimEnd().length && value.trimEnd().length <= cursorIndex) {
400
>
trailingWhitespace = Math.max((this._value.length - 1) - value.trimEnd().length, 0);
401
>
}
402
>
// Standard case; subtract from trailing whitespace
403
>
else {
404
>
trailingWhitespace = Math.max(trailingWhitespace - 1, 0);
405
>
}
406
>
407
>
}
408
>
}
409
410
// Handle delete key
411
if (this._lastUserInput === '\x1b[3~') {
413
>
if (cursorIndex === this._cursorIndex) {
414
>
trailingWhitespace = Math.max(trailingWhitespace - 1, 0);
415
>
}
416
>
}
417
418
const valueLines = value.split('\n');