* Add a prompt to history for up/down arrow navigation. * Called after successful submission.
(text: string)
| 430 | * Called after successful submission. |
| 431 | */ |
| 432 | addToHistory(text: string): void { |
| 433 | const trimmed = text.trim(); |
| 434 | if (!trimmed) return; |
| 435 | // Don't add consecutive duplicates |
| 436 | if (this.history.length > 0 && this.history[0] === trimmed) return; |
| 437 | this.history.unshift(trimmed); |
| 438 | // Limit history size |
| 439 | if (this.history.length > 100) { |
| 440 | this.history.pop(); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | private isEditorEmpty(): boolean { |
| 445 | return this.state.lines.length === 1 && this.state.lines[0] === ""; |