mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
more strict on regex, fix special character
This commit is contained in:
parent
6afac1d3f7
commit
8ba75dfdc8
|
@ -31,7 +31,7 @@ export function formatStackTrace(stack: string) {
|
||||||
|
|
||||||
const formatSequence = /\u001b\[.+?m/g;
|
const formatSequence = /\u001b\[.+?m/g;
|
||||||
const fileRegex = /File\s+(?:\u001b\[.+?m)?(.+):(\d+)/;
|
const fileRegex = /File\s+(?:\u001b\[.+?m)?(.+):(\d+)/;
|
||||||
const lineNumberRegex = /^((?:\u001b\[.+?m)?[ ->]*?)(\d+)(.*)/;
|
const lineNumberRegex = /^((?:\u001b\[.+?m)?[ \->]+?)(\d+)(?:\u001b\[0m)?( .*)/;
|
||||||
const cellRegex = /(?<prefix>Cell\s+(?:\u001b\[.+?m)?In\s*\[(?<executionCount>\d+)\],\s*)(?<lineLabel>line (?<lineNumber>\d+)).*/;
|
const cellRegex = /(?<prefix>Cell\s+(?:\u001b\[.+?m)?In\s*\[(?<executionCount>\d+)\],\s*)(?<lineLabel>line (?<lineNumber>\d+)).*/;
|
||||||
// older versions of IPython ~8.3.0
|
// older versions of IPython ~8.3.0
|
||||||
const inputRegex = /(?<prefix>Input\s+?(?:\u001b\[.+?m)(?<cellLabel>In\s*\[(?<executionCount>\d+)\]))(?<postfix>.*)/;
|
const inputRegex = /(?<prefix>Input\s+?(?:\u001b\[.+?m)(?<cellLabel>In\s*\[(?<executionCount>\d+)\]))(?<postfix>.*)/;
|
||||||
|
|
|
@ -43,8 +43,6 @@ suite('StackTraceHelper', () => {
|
||||||
assert.ok(formatted.indexOf('<a href=\'C:\\venvs\\myLib.py:2\'>2</a>') > 0, 'Missing frame link in ' + formatted);
|
assert.ok(formatted.indexOf('<a href=\'C:\\venvs\\myLib.py:2\'>2</a>') > 0, 'Missing frame link in ' + formatted);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test('IPython stack line numbers are linkified for IPython 8.3', () => {
|
test('IPython stack line numbers are linkified for IPython 8.3', () => {
|
||||||
// stack frames within functions do not list the line number, i.e.
|
// stack frames within functions do not list the line number, i.e.
|
||||||
// 'Input In [1], in myfunc()' vs
|
// 'Input In [1], in myfunc()' vs
|
||||||
|
@ -93,7 +91,11 @@ suite('StackTraceHelper', () => {
|
||||||
'\u001b[1;36m Cell \u001b[1;32mIn[6], line 1\u001b[1;36m\u001b[0m\n' +
|
'\u001b[1;36m Cell \u001b[1;32mIn[6], line 1\u001b[1;36m\u001b[0m\n' +
|
||||||
'\u001b[1;33m print(\u001b[0m\n' +
|
'\u001b[1;33m print(\u001b[0m\n' +
|
||||||
'\u001b[1;37m ^\u001b[0m\n' +
|
'\u001b[1;37m ^\u001b[0m\n' +
|
||||||
'\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m incomplete input\n';
|
'\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m incomplete input\n' +
|
||||||
|
// contrived examples to check for more false positives
|
||||||
|
'1 print(\n' +
|
||||||
|
'a 1 print(\n' +
|
||||||
|
' 1a print(\n';
|
||||||
|
|
||||||
const formattedLines = formatStackTrace(stack).split('\n');
|
const formattedLines = formatStackTrace(stack).split('\n');
|
||||||
assert.ok(/<a href='vscode-notebook-cell.*>/.test(formattedLines[0]), 'line should contain a link: ' + formattedLines[0]);
|
assert.ok(/<a href='vscode-notebook-cell.*>/.test(formattedLines[0]), 'line should contain a link: ' + formattedLines[0]);
|
||||||
|
|
Loading…
Reference in a new issue