()
| 1697 | } |
| 1698 | |
| 1699 | private deleteWordForward(): void { |
| 1700 | this.exitHistoryBrowsing(); |
| 1701 | |
| 1702 | const currentLine = this.state.lines[this.state.cursorLine] || ""; |
| 1703 | |
| 1704 | // If at end of line, merge with next line (delete the newline) |
| 1705 | if (this.state.cursorCol >= currentLine.length) { |
| 1706 | if (this.state.cursorLine < this.state.lines.length - 1) { |
| 1707 | this.pushUndoSnapshot(); |
| 1708 | |
| 1709 | // Treat newline as deleted text (forward deletion = append) |
| 1710 | this.killRing.push("\n", { prepend: false, accumulate: this.lastAction === "kill" }); |
| 1711 | this.lastAction = "kill"; |
| 1712 | |
| 1713 | const nextLine = this.state.lines[this.state.cursorLine + 1] || ""; |
| 1714 | this.state.lines[this.state.cursorLine] = currentLine + nextLine; |
| 1715 | this.state.lines.splice(this.state.cursorLine + 1, 1); |
| 1716 | } |
| 1717 | } else { |
| 1718 | this.pushUndoSnapshot(); |
| 1719 | |
| 1720 | // Save lastAction before cursor movement (moveWordForwards resets it) |
| 1721 | const wasKill = this.lastAction === "kill"; |
| 1722 | |
| 1723 | const oldCursorCol = this.state.cursorCol; |
| 1724 | this.moveWordForwards(); |
| 1725 | const deleteTo = this.state.cursorCol; |
| 1726 | this.setCursorCol(oldCursorCol); |
| 1727 | |
| 1728 | const deletedText = currentLine.slice(this.state.cursorCol, deleteTo); |
| 1729 | this.killRing.push(deletedText, { prepend: false, accumulate: wasKill }); |
| 1730 | this.lastAction = "kill"; |
| 1731 | |
| 1732 | this.state.lines[this.state.cursorLine] = |
| 1733 | currentLine.slice(0, this.state.cursorCol) + currentLine.slice(deleteTo); |
| 1734 | } |
| 1735 | |
| 1736 | if (this.onChange) { |
| 1737 | this.onChange(this.getText()); |
| 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | private handleForwardDelete(): void { |
| 1742 | this.exitHistoryBrowsing(); |
no test coverage detected