()
| 1652 | } |
| 1653 | |
| 1654 | private deleteWordBackwards(): void { |
| 1655 | this.exitHistoryBrowsing(); |
| 1656 | |
| 1657 | const currentLine = this.state.lines[this.state.cursorLine] || ""; |
| 1658 | |
| 1659 | // If at start of line, behave like backspace at column 0 (merge with previous line) |
| 1660 | if (this.state.cursorCol === 0) { |
| 1661 | if (this.state.cursorLine > 0) { |
| 1662 | this.pushUndoSnapshot(); |
| 1663 | |
| 1664 | // Treat newline as deleted text (backward deletion = prepend) |
| 1665 | this.killRing.push("\n", { prepend: true, accumulate: this.lastAction === "kill" }); |
| 1666 | this.lastAction = "kill"; |
| 1667 | |
| 1668 | const previousLine = this.state.lines[this.state.cursorLine - 1] || ""; |
| 1669 | this.state.lines[this.state.cursorLine - 1] = previousLine + currentLine; |
| 1670 | this.state.lines.splice(this.state.cursorLine, 1); |
| 1671 | this.state.cursorLine--; |
| 1672 | this.setCursorCol(previousLine.length); |
| 1673 | } |
| 1674 | } else { |
| 1675 | this.pushUndoSnapshot(); |
| 1676 | |
| 1677 | // Save lastAction before cursor movement (moveWordBackwards resets it) |
| 1678 | const wasKill = this.lastAction === "kill"; |
| 1679 | |
| 1680 | const oldCursorCol = this.state.cursorCol; |
| 1681 | this.moveWordBackwards(); |
| 1682 | const deleteFrom = this.state.cursorCol; |
| 1683 | this.setCursorCol(oldCursorCol); |
| 1684 | |
| 1685 | const deletedText = currentLine.slice(deleteFrom, this.state.cursorCol); |
| 1686 | this.killRing.push(deletedText, { prepend: true, accumulate: wasKill }); |
| 1687 | this.lastAction = "kill"; |
| 1688 | |
| 1689 | this.state.lines[this.state.cursorLine] = |
| 1690 | currentLine.slice(0, deleteFrom) + currentLine.slice(this.state.cursorCol); |
| 1691 | this.setCursorCol(deleteFrom); |
| 1692 | } |
| 1693 | |
| 1694 | if (this.onChange) { |
| 1695 | this.onChange(this.getText()); |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | private deleteWordForward(): void { |
| 1700 | this.exitHistoryBrowsing(); |
no test coverage detected