setupSuggestionBehaviors(): () => string
zsh-style typeahead: the rest of the last matching line, greyed out after the cursor, Ctrl-F to take it.
Drawn AFTER readline has drawn, on the tick following each keypress. readline draws on that same
keypress and would paint over anything written first; the ghost is appended to its output and
the cursor walked back over it, so the line readline believes it has is the line it has. Nothing
here touches server.line, which is why an unaccepted suggestion cannot end up in what gets
evaluated.
import { setupSuggestionBehaviors } from './completion.ts'; import type { REPLServer } from 'node:repl'; // Defined, not invoked: it listens on a live terminal. function example(server: REPLServer) { setupSuggestionBehaviors(server); // ghost text on, Ctrl-F accepts }