Skip to content

Commit f99b66f

Browse files
committed
fix(repl): invisible typed input in REPL editor
Bug: redrawFromCursor() printed line[e.pos:] after the cursor had already been advanced past the newly inserted/deleted character. When typing at end of line (the common case), line[e.pos:] was empty — so no character was ever rendered to the terminal. Fix: replace the partial redraw (print line[e.pos:] + clear + cursor moveback) with a full drawLine() call. drawLine() does \r + prompt + full line text + clear-to-end + cursor positioning, which always shows the complete buffer regardless of cursor position. Affects: insert, backspace, delete, deleteLine, deleteToEnd, historyPrev, historyNext — every editing operation.
1 parent 1be1482 commit f99b66f

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

cmd/odek/repl_editor.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,12 @@ func (e *replEditor) drawLine() {
357357
fmt.Fprintf(os.Stderr, "\r\x1b[%dC", offset)
358358
}
359359

360-
// redrawFromCursor redraws from the current cursor position to the end.
360+
// redrawFromCursor redraws the full line from scratch.
361+
// The old partial-redraw logic (printing from e.pos onward) failed when
362+
// e.pos == len(e.line) — the common "typing at end" case — leaving
363+
// every keystroke invisible. A full drawLine() is correct and fast.
361364
func (e *replEditor) redrawFromCursor() {
362-
fmt.Fprint(os.Stderr, string(e.line[e.pos:]))
363-
// Clear to end
364-
fmt.Fprint(os.Stderr, "\x1b[K")
365-
// Move cursor back
366-
if remaining := len(e.line) - e.pos; remaining > 0 {
367-
fmt.Fprintf(os.Stderr, "\x1b[%dD", remaining)
368-
}
365+
e.drawLine()
369366
}
370367

371368
func (e *replEditor) clearScreen() {

0 commit comments

Comments
 (0)