Skip to content

Commit 0898fe3

Browse files
committed
be more strict about what we match to linkify a stack frame
1 parent c75f69e commit 0898fe3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extensions/notebook-renderers/src/stackTraceHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function formatStackTrace(stack: string) {
3131

3232
const formatSequence = /\u001b\[.+?m/g;
3333
const fileRegex = /File\s+(?:\u001b\[.+?m)?(.+):(\d+)/;
34-
const lineNumberRegex = /((?:\u001b\[.+?m)?[ ->]*?)(\d+)(.*)/;
34+
const lineNumberRegex = /^((?:\u001b\[.+?m)?[ \->]+?)(\d+)(?:\u001b\[0m)?( .*)/;
3535
const cellRegex = /(?<prefix>Cell\s+(?:\u001b\[.+?m)?In\s*\[(?<executionCount>\d+)\],\s*)(?<lineLabel>line (?<lineNumber>\d+)).*/;
3636
// older versions of IPython ~8.3.0
3737
const inputRegex = /(?<prefix>Input\s+?(?:\u001b\[.+?m)(?<cellLabel>In\s*\[(?<executionCount>\d+)\]))(?<postfix>.*)/;
@@ -41,7 +41,7 @@ function isIpythonStackTrace(stack: string) {
4141
}
4242

4343
function stripFormatting(text: string) {
44-
return text.replace(formatSequence, '');
44+
return text.replace(formatSequence, '').trim();
4545
}
4646

4747
type cellLocation = { kind: 'cell'; path: string };

0 commit comments

Comments
 (0)