提交 cda7b564 编写于 作者: I isidor

fixes #111191

上级 182fe687
...@@ -7,13 +7,13 @@ import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector'; ...@@ -7,13 +7,13 @@ import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
import { RGBA, Color } from 'vs/base/common/color'; import { RGBA, Color } from 'vs/base/common/color';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ansiColorIdentifiers } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; import { ansiColorIdentifiers } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { IDebugSession } from 'vs/workbench/contrib/debug/common/debug'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
/** /**
* @param text The content to stylize. * @param text The content to stylize.
* @returns An {@link HTMLSpanElement} that contains the potentially stylized text. * @returns An {@link HTMLSpanElement} that contains the potentially stylized text.
*/ */
export function handleANSIOutput(text: string, linkDetector: LinkDetector, themeService: IThemeService, debugSession: IDebugSession): HTMLSpanElement { export function handleANSIOutput(text: string, linkDetector: LinkDetector, themeService: IThemeService, workspaceFolder: IWorkspaceFolder | undefined): HTMLSpanElement {
const root: HTMLSpanElement = document.createElement('span'); const root: HTMLSpanElement = document.createElement('span');
const textLength: number = text.length; const textLength: number = text.length;
...@@ -54,7 +54,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector, theme ...@@ -54,7 +54,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector, theme
if (sequenceFound) { if (sequenceFound) {
// Flush buffer with previous styles. // Flush buffer with previous styles.
appendStylizedStringToContainer(root, buffer, styleNames, linkDetector, debugSession, customFgColor, customBgColor); appendStylizedStringToContainer(root, buffer, styleNames, linkDetector, workspaceFolder, customFgColor, customBgColor);
buffer = ''; buffer = '';
...@@ -100,7 +100,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector, theme ...@@ -100,7 +100,7 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector, theme
// Flush remaining text buffer if not empty. // Flush remaining text buffer if not empty.
if (buffer) { if (buffer) {
appendStylizedStringToContainer(root, buffer, styleNames, linkDetector, debugSession, customFgColor, customBgColor); appendStylizedStringToContainer(root, buffer, styleNames, linkDetector, workspaceFolder, customFgColor, customBgColor);
} }
return root; return root;
...@@ -268,7 +268,7 @@ export function appendStylizedStringToContainer( ...@@ -268,7 +268,7 @@ export function appendStylizedStringToContainer(
stringContent: string, stringContent: string,
cssClasses: string[], cssClasses: string[],
linkDetector: LinkDetector, linkDetector: LinkDetector,
debugSession: IDebugSession, workspaceFolder: IWorkspaceFolder | undefined,
customTextColor?: RGBA, customTextColor?: RGBA,
customBackgroundColor?: RGBA customBackgroundColor?: RGBA
): void { ): void {
...@@ -276,7 +276,7 @@ export function appendStylizedStringToContainer( ...@@ -276,7 +276,7 @@ export function appendStylizedStringToContainer(
return; return;
} }
const container = linkDetector.linkify(stringContent, true, debugSession.root); const container = linkDetector.linkify(stringContent, true, workspaceFolder);
container.className = cssClasses.join(' '); container.className = cssClasses.join(' ');
if (customTextColor) { if (customTextColor) {
......
...@@ -107,7 +107,7 @@ export class ReplGroupRenderer implements ITreeRenderer<ReplGroup, FuzzyScore, I ...@@ -107,7 +107,7 @@ export class ReplGroupRenderer implements ITreeRenderer<ReplGroup, FuzzyScore, I
} }
} }
export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluationResult, FuzzyScore, IReplEvaluationResultTemplateData> { export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluationResult | Variable, FuzzyScore, IReplEvaluationResultTemplateData> {
static readonly ID = 'replEvaluationResult'; static readonly ID = 'replEvaluationResult';
get templateId(): string { get templateId(): string {
...@@ -123,7 +123,7 @@ export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluati ...@@ -123,7 +123,7 @@ export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluati
return { value }; return { value };
} }
renderElement(element: ITreeNode<ReplEvaluationResult, FuzzyScore>, index: number, templateData: IReplEvaluationResultTemplateData): void { renderElement(element: ITreeNode<ReplEvaluationResult | Variable, FuzzyScore>, index: number, templateData: IReplEvaluationResultTemplateData): void {
const expression = element.element; const expression = element.element;
renderExpressionValue(expression, templateData.value, { renderExpressionValue(expression, templateData.value, {
showHover: false, showHover: false,
...@@ -187,7 +187,7 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme ...@@ -187,7 +187,7 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme
dom.clearNode(templateData.value); dom.clearNode(templateData.value);
// Reset classes to clear ansi decorations since templates are reused // Reset classes to clear ansi decorations since templates are reused
templateData.value.className = 'value'; templateData.value.className = 'value';
const result = handleANSIOutput(element.value, this.linkDetector, this.themeService, element.session); const result = handleANSIOutput(element.value, this.linkDetector, this.themeService, element.session.root);
templateData.value.appendChild(result); templateData.value.appendChild(result);
templateData.value.classList.add((element.severity === severity.Warning) ? 'warn' : (element.severity === severity.Error) ? 'error' : (element.severity === severity.Ignore) ? 'ignore' : 'info'); templateData.value.classList.add((element.severity === severity.Warning) ? 'warn' : (element.severity === severity.Error) ? 'error' : (element.severity === severity.Ignore) ? 'ignore' : 'info');
...@@ -320,14 +320,14 @@ export class ReplDelegate extends CachedListVirtualDelegate<IReplElement> { ...@@ -320,14 +320,14 @@ export class ReplDelegate extends CachedListVirtualDelegate<IReplElement> {
if (element instanceof Variable && element.name) { if (element instanceof Variable && element.name) {
return ReplVariablesRenderer.ID; return ReplVariablesRenderer.ID;
} }
if (element instanceof ReplEvaluationResult) { if (element instanceof ReplEvaluationResult || (element instanceof Variable && !element.name)) {
// Variable with no name is a top level variable which should be rendered like a repl element #17404
return ReplEvaluationResultsRenderer.ID; return ReplEvaluationResultsRenderer.ID;
} }
if (element instanceof ReplEvaluationInput) { if (element instanceof ReplEvaluationInput) {
return ReplEvaluationInputsRenderer.ID; return ReplEvaluationInputsRenderer.ID;
} }
if (element instanceof SimpleReplElement || (element instanceof Variable && !element.name)) { if (element instanceof SimpleReplElement) {
// Variable with no name is a top level variable which should be rendered like a repl element #17404
return ReplSimpleElementsRenderer.ID; return ReplSimpleElementsRenderer.ID;
} }
if (element instanceof ReplGroup) { if (element instanceof ReplGroup) {
......
...@@ -49,8 +49,8 @@ suite('Debug - ANSI Handling', () => { ...@@ -49,8 +49,8 @@ suite('Debug - ANSI Handling', () => {
assert.equal(0, root.children.length); assert.equal(0, root.children.length);
appendStylizedStringToContainer(root, 'content1', ['class1', 'class2'], linkDetector, session); appendStylizedStringToContainer(root, 'content1', ['class1', 'class2'], linkDetector, session.root);
appendStylizedStringToContainer(root, 'content2', ['class2', 'class3'], linkDetector, session); appendStylizedStringToContainer(root, 'content2', ['class2', 'class3'], linkDetector, session.root);
assert.equal(2, root.children.length); assert.equal(2, root.children.length);
...@@ -80,7 +80,7 @@ suite('Debug - ANSI Handling', () => { ...@@ -80,7 +80,7 @@ suite('Debug - ANSI Handling', () => {
* @returns An {@link HTMLSpanElement} that contains the stylized text. * @returns An {@link HTMLSpanElement} that contains the stylized text.
*/ */
function getSequenceOutput(sequence: string): HTMLSpanElement { function getSequenceOutput(sequence: string): HTMLSpanElement {
const root: HTMLSpanElement = handleANSIOutput(sequence, linkDetector, themeService, session); const root: HTMLSpanElement = handleANSIOutput(sequence, linkDetector, themeService, session.root);
assert.equal(1, root.children.length); assert.equal(1, root.children.length);
const child: Node = root.lastChild!; const child: Node = root.lastChild!;
if (child instanceof HTMLSpanElement) { if (child instanceof HTMLSpanElement) {
...@@ -320,7 +320,7 @@ suite('Debug - ANSI Handling', () => { ...@@ -320,7 +320,7 @@ suite('Debug - ANSI Handling', () => {
if (elementsExpected === undefined) { if (elementsExpected === undefined) {
elementsExpected = assertions.length; elementsExpected = assertions.length;
} }
const root: HTMLSpanElement = handleANSIOutput(sequence, linkDetector, themeService, session); const root: HTMLSpanElement = handleANSIOutput(sequence, linkDetector, themeService, session.root);
assert.equal(elementsExpected, root.children.length); assert.equal(elementsExpected, root.children.length);
for (let i = 0; i < elementsExpected; i++) { for (let i = 0; i < elementsExpected; i++) {
const child: Node = root.children[i]; const child: Node = root.children[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册