Skip to content

Commit 134002c

Browse files
committed
simplify
1 parent ca3b6ea commit 134002c

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

packages/javascript-kernel/src/executor.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import type { IMimeBundle } from '@jupyterlab/nbformat';
1010

1111
export { IDisplayData, IDisplayCallbacks, DisplayHelper } from './display';
1212

13+
/** Matches the word "eval" in a stack frame (user eval code). */
14+
const RE_EVAL = /\beval\b/;
15+
1316
/**
1417
* Configuration for magic imports.
1518
*/
@@ -793,19 +796,10 @@ export class JavaScriptExecutor {
793796
break;
794797
}
795798

796-
// Keep eval frames from user code.
797-
if (/\beval\b/.test(trimmed) || trimmed.includes('<anonymous>')) {
799+
// Only keep lines that reference user eval code.
800+
if (RE_EVAL.test(trimmed) || trimmed.includes('<anonymous>')) {
798801
userFrames.push(line);
799-
continue;
800-
}
801-
802-
// Drop stack frames that point to bundled code.
803-
if (/^\s*at\s+/.test(trimmed) || /^[^@]*@\S+:\d+:\d+$/.test(trimmed)) {
804-
continue;
805802
}
806-
807-
// Keep any other lines (may be useful context).
808-
userFrames.push(line);
809803
}
810804

811805
if (userFrames.length > 0) {

0 commit comments

Comments
 (0)