()
| 1585 | } |
| 1586 | |
| 1587 | private deleteToStartOfLine(): void { |
| 1588 | this.exitHistoryBrowsing(); |
| 1589 | |
| 1590 | const currentLine = this.state.lines[this.state.cursorLine] || ""; |
| 1591 | |
| 1592 | if (this.state.cursorCol > 0) { |
| 1593 | this.pushUndoSnapshot(); |
| 1594 | |
| 1595 | // Calculate text to be deleted and save to kill ring (backward deletion = prepend) |
| 1596 | const deletedText = currentLine.slice(0, this.state.cursorCol); |
| 1597 | this.killRing.push(deletedText, { prepend: true, accumulate: this.lastAction === "kill" }); |
| 1598 | this.lastAction = "kill"; |
| 1599 | |
| 1600 | // Delete from start of line up to cursor |
| 1601 | this.state.lines[this.state.cursorLine] = currentLine.slice(this.state.cursorCol); |
| 1602 | this.setCursorCol(0); |
| 1603 | } else if (this.state.cursorLine > 0) { |
| 1604 | this.pushUndoSnapshot(); |
| 1605 | |
| 1606 | // At start of line - merge with previous line, treating newline as deleted text |
| 1607 | this.killRing.push("\n", { prepend: true, accumulate: this.lastAction === "kill" }); |
| 1608 | this.lastAction = "kill"; |
| 1609 | |
| 1610 | const previousLine = this.state.lines[this.state.cursorLine - 1] || ""; |
| 1611 | this.state.lines[this.state.cursorLine - 1] = previousLine + currentLine; |
| 1612 | this.state.lines.splice(this.state.cursorLine, 1); |
| 1613 | this.state.cursorLine--; |
| 1614 | this.setCursorCol(previousLine.length); |
| 1615 | } |
| 1616 | |
| 1617 | if (this.onChange) { |
| 1618 | this.onChange(this.getText()); |
| 1619 | } |
| 1620 | } |
| 1621 | |
| 1622 | private deleteToEndOfLine(): void { |
| 1623 | this.exitHistoryBrowsing(); |
no test coverage detected