Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export function createRepl(options: CreateReplOptions = {}) {
state,
input: code,
context,
overrideIsCompletion: false,
});
assert(result.containsTopLevelAwait === false);
return result.value;
Expand Down Expand Up @@ -512,13 +513,20 @@ function appendCompileAndEvalInput(options: {
/** Enable top-level await but only if the TSNode service allows it. */
enableTopLevelAwait?: boolean;
context: Context | undefined;
/**
* Added so that `evalCode` can be guaranteed *not* to trigger the `isCompletion`
* codepath. However, the `isCompletion` logic is ancient and maybe should be removed entirely.
* Nobody's looked at it in a long time.
*/
overrideIsCompletion?: boolean;
}): AppendCompileAndEvalInputResult {
const {
service,
state,
wrappedErr,
enableTopLevelAwait = false,
context,
overrideIsCompletion,
} = options;
let { input } = options;

Expand All @@ -533,7 +541,7 @@ function appendCompileAndEvalInput(options: {
}

const lines = state.lines;
const isCompletion = !/\n$/.test(input);
const isCompletion = overrideIsCompletion ?? !/\n$/.test(input);
const undo = appendToEvalState(state, input);
let output: string;

Expand Down