-
-
Notifications
You must be signed in to change notification settings - Fork 32k
repl: support previews by eager evaluating input #30811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,8 @@ const experimentalREPLAwait = require('internal/options').getOptionValue( | |
); | ||
const { | ||
isRecoverableError, | ||
kStandaloneREPL | ||
kStandaloneREPL, | ||
setupPreview, | ||
} = require('internal/repl/utils'); | ||
const { | ||
getOwnNonIndexProperties, | ||
|
@@ -204,6 +205,9 @@ function REPLServer(prompt, | |
} | ||
} | ||
|
||
const preview = options.terminal && | ||
ZYSzys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(options.preview !== undefined ? !!options.preview : true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this still prevent previews from being enabled if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct. I would have liked to do that but the current proposal does not support previews for non-terminals yet. That requires additional work and I would rather do that in a follow-up PR. |
||
|
||
this.inputStream = options.input; | ||
this.outputStream = options.output; | ||
this.useColors = !!options.useColors; | ||
|
@@ -804,9 +808,20 @@ function REPLServer(prompt, | |
} | ||
}); | ||
|
||
const { | ||
clearPreview, | ||
showInputPreview | ||
} = setupPreview( | ||
this, | ||
kContextId, | ||
kBufferedCommandSymbol, | ||
preview | ||
); | ||
|
||
// Wrap readline tty to enable editor mode and pausing. | ||
const ttyWrite = self._ttyWrite.bind(self); | ||
self._ttyWrite = (d, key) => { | ||
clearPreview(); | ||
key = key || {}; | ||
if (paused && !(self.breakEvalOnSigint && key.ctrl && key.name === 'c')) { | ||
pausedBuffer.push(['key', [d, key]]); | ||
|
@@ -819,6 +834,7 @@ function REPLServer(prompt, | |
self.clearLine(); | ||
} | ||
ttyWrite(d, key); | ||
showInputPreview(); | ||
return; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.