Skip to content

Commit

Permalink
Fix #1764 (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode authored Jul 2, 2022
1 parent ab15063 commit ad01f49
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit ad01f49

Please sign in to comment.