Skip to content

Commit ad01f49

Browse files
authored
Fix #1764 (#1824)
1 parent ab15063 commit ad01f49

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/repl.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export function createRepl(options: CreateReplOptions = {}) {
207207
state,
208208
input: code,
209209
context,
210+
overrideIsCompletion: false,
210211
});
211212
assert(result.containsTopLevelAwait === false);
212213
return result.value;
@@ -512,13 +513,20 @@ function appendCompileAndEvalInput(options: {
512513
/** Enable top-level await but only if the TSNode service allows it. */
513514
enableTopLevelAwait?: boolean;
514515
context: Context | undefined;
516+
/**
517+
* Added so that `evalCode` can be guaranteed *not* to trigger the `isCompletion`
518+
* codepath. However, the `isCompletion` logic is ancient and maybe should be removed entirely.
519+
* Nobody's looked at it in a long time.
520+
*/
521+
overrideIsCompletion?: boolean;
515522
}): AppendCompileAndEvalInputResult {
516523
const {
517524
service,
518525
state,
519526
wrappedErr,
520527
enableTopLevelAwait = false,
521528
context,
529+
overrideIsCompletion,
522530
} = options;
523531
let { input } = options;
524532

@@ -533,7 +541,7 @@ function appendCompileAndEvalInput(options: {
533541
}
534542

535543
const lines = state.lines;
536-
const isCompletion = !/\n$/.test(input);
544+
const isCompletion = overrideIsCompletion ?? !/\n$/.test(input);
537545
const undo = appendToEvalState(state, input);
538546
let output: string;
539547

0 commit comments

Comments
 (0)