Skip to content

Fix the REPL's rough edges with output, keys and the editor - #32

Merged
bbatsov merged 10 commits into
mainfrom
repl-polish
Oct 20, 2026
Merged

bbatsov merged 10 commits into
mainfrom
repl-polish

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixes for the interactive REPL: partial lines from other threads, Ctrl-R's prompt under eldoc, typed-ahead text echoed into evaluation output, eldoc tips that wrap, and NO_COLOR in the completion menu. ,stacktrace no longer drops back to the prompt on a frame without source, ,edit opens definitions in jars as copies, and C-x C-s and C-x C-a join C-x C-d.

Echo is off only while an evaluation or a lookup runs, not for the whole session, so an editor opened with ,edit still gets a terminal that echoes.

Printing above the prompt takes whole lines only, so the start of a line
from another thread waited for its newline, which a question or dots
showing progress may never print, and then ran into the next value. It
now goes above the prompt a quarter of a second after it comes, on a line
of its own, or before what's printed next, once the line's been read,
whichever's first.
JLine clears what goes below the line, the search's prompt among it,
whenever it shows a tail tip, which eldoc uses, so Ctrl-R and Ctrl-S
searched blind. The search now runs with the tip turned off.
Enter on a frame without source, a Java one say, left the view for the
prompt with a message, so trying the next frame meant starting over, and
so did opening a second frame in the editor. The message goes on the
view's status line now, and the view comes back, on the same frame, once
the editor exits.
,edit took a jar: URL, which is where the server says a library's
definitions are, for a file it couldn't find. The file gets copied out of
its jar into neorepl's cache, read-only, since changing it changes
nothing, and again when the jar changes, as a snapshot's can.
The terminal echoed what was typed while an evaluation ran, in among
what the evaluation printed, and the line editor showed it again at the
next prompt, where it goes. Echo's off while an evaluation runs now, and
while a command waits on the server for a lookup, like ,reload, so it
only shows up there. Ctrl-C still interrupts, and a read from *in* still
shows what's typed, the line editor doing that itself.
The marks say what index to push a value by, which neorepl inspect
--push and the full-screen inspector take, but the REPL without a line
editor has no way to push, so they were only noise there.
In the REPL without a line editor, the terminal echoes ^C where the
cursor is, and "The evaluation was interrupted" followed it on the same
line. The REPL now ends that line first, before the interrupt, which
waits for the server, and before exiting at the prompt. Only when
standard input is a terminal that echoed the ^C, though: Emacs' M-x
shell has echo off, and would get an empty line.
Arglists longer than what's left of the line, like a Java method's or
those of a function with many arities, wrapped onto the lines below the
one being edited. The tip now ends in an ellipsis where the line does,
the prompt's width coming from the read that shows it.
The menu showed what's typed so far in cyan and the candidates' types in
gray, JLine's styles, whatever NO_COLOR said. An empty style doesn't
turn them off, since JLine falls back on its own for a style that comes
out as none, so they're the terminal's default color instead.
The REPL had rebel-readline's C-x C-d for docs, but not the other two of
its keys, which babashka's REPL has as well. C-x C-s shows the source of
the symbol at the cursor, or of the call it's in, highlighted, and C-x
C-a the vars whose names have the symbol in them, taken literally rather
than as a regex. Both wait up to five seconds, being asked for.
@bbatsov
bbatsov merged commit cfbc77d into main Oct 20, 2026
18 checks passed
@bbatsov
bbatsov deleted the repl-polish branch October 20, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant