mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
link test
This commit is contained in:
parent
8e8811a5c1
commit
315f158d20
|
@ -7,7 +7,7 @@ import type { ActivationFunction, OutputItem, RendererContext } from 'vscode-not
|
|||
import { createOutputContent, appendOutput, scrollableClass } from './textHelper';
|
||||
import { HtmlRenderingHook, IDisposable, IRichRenderContext, JavaScriptRenderingHook, OutputWithAppend, RenderOptions } from './rendererTypes';
|
||||
import { ttPolicy } from './htmlHelper';
|
||||
import { cleanStackTrace } from './stackTraceHelper';
|
||||
import { formatStackTrace } from './stackTraceHelper';
|
||||
|
||||
function clearContainer(container: HTMLElement) {
|
||||
while (container.firstChild) {
|
||||
|
@ -173,7 +173,7 @@ function renderError(
|
|||
if (err.stack) {
|
||||
outputElement.classList.add('traceback');
|
||||
|
||||
const stackTrace = cleanStackTrace(err.stack);
|
||||
const stackTrace = formatStackTrace(err.stack);
|
||||
|
||||
const outputScrolling = scrollingEnabled(outputInfo, ctx.settings);
|
||||
const content = createOutputContent(outputInfo.id, stackTrace ?? '', { linesLimit: ctx.settings.lineLimit, scrollable: outputScrolling, trustHtml });
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function cleanStackTrace(stack: string) {
|
||||
export function formatStackTrace(stack: string) {
|
||||
let cleaned: string;
|
||||
// Ansi colors are described here:
|
||||
// https://en.wikipedia.org/wiki/ANSI_escape_code under the SGR section
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { formatStackTrace } from '../stackTraceHelper';
|
||||
import * as assert from 'assert';
|
||||
|
||||
suite('StackTraceHelper', () => {
|
||||
|
||||
test('Non Ipython stack trace is left alone', () => {
|
||||
const stack = 'DivideError: integer division error\n' +
|
||||
'Stacktrace:\n' +
|
||||
'[1] divide_by_zero(x:: Int64)\n' +
|
||||
'@Main c:\\src\\test\\3\\otherlanguages\\julia.ipynb: 3\n' +
|
||||
'[2] top - level scope\n' +
|
||||
'@c:\\src\\test\\3\\otherlanguages\\julia.ipynb: 1; ';
|
||||
assert.equal(formatStackTrace(stack), stack);
|
||||
});
|
||||
|
||||
test('IPython cell references are linkified', () => {
|
||||
const stack =
|
||||
'---------------------------------------------------------------------------\n' +
|
||||
'Exception Traceback(most recent call last)\n' +
|
||||
'Cell In[3], line 2\n' +
|
||||
' 1 import myLib\n' +
|
||||
'----> 2 myLib.throwEx()\n' +
|
||||
'\n' +
|
||||
'File C:\\venvs\\myLib.py:2, in throwEx()\n' +
|
||||
' 1 def throwEx():\n' +
|
||||
'----> 2 raise Exception\n';
|
||||
|
||||
const formatted = formatStackTrace(stack);
|
||||
assert.ok(formatted.indexOf);
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in a new issue