()
| 318 | } |
| 319 | |
| 320 | private yankPop(): void { |
| 321 | if (this.lastAction !== "yank" || this.killRing.length <= 1) return; |
| 322 | |
| 323 | this.pushUndo(); |
| 324 | |
| 325 | // Delete the previously yanked text (still at end of ring before rotation) |
| 326 | const prevText = this.killRing.peek() || ""; |
| 327 | this.value = this.value.slice(0, this.cursor - prevText.length) + this.value.slice(this.cursor); |
| 328 | this.cursor -= prevText.length; |
| 329 | |
| 330 | // Rotate and insert new entry |
| 331 | this.killRing.rotate(); |
| 332 | const text = this.killRing.peek() || ""; |
| 333 | this.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor); |
| 334 | this.cursor += text.length; |
| 335 | this.lastAction = "yank"; |
| 336 | } |
| 337 | |
| 338 | private pushUndo(): void { |
| 339 | this.undoStack.push({ value: this.value, cursor: this.cursor }); |
no test coverage detected