Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type based coloring #202901

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/debug/browser/baseDebugView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { localize } from 'vs/nls';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { defaultInputBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
import { IDebugService, IExpression, IExpressionContainer } from 'vs/workbench/contrib/debug/common/debug';
import { IDebugService, IExpression, IExpressionValue } from 'vs/workbench/contrib/debug/common/debug';
import { Expression, ExpressionContainer, Variable } from 'vs/workbench/contrib/debug/common/debugModel';
import { ReplEvaluationResult } from 'vs/workbench/contrib/debug/common/replModel';

Expand Down Expand Up @@ -51,7 +51,7 @@ export function renderViewTree(container: HTMLElement): HTMLElement {
return treeContainer;
}

export function renderExpressionValue(expressionOrValue: IExpressionContainer | string, container: HTMLElement, options: IRenderValueOptions): void {
export function renderExpressionValue(expressionOrValue: IExpressionValue | string, container: HTMLElement, options: IRenderValueOptions): void {
let value = typeof expressionOrValue === 'string' ? expressionOrValue : expressionOrValue.value;

// remove stale classes
Expand All @@ -63,7 +63,7 @@ export function renderExpressionValue(expressionOrValue: IExpressionContainer |
container.classList.add('error');
}
} else {
if ((expressionOrValue instanceof ExpressionContainer) && options.showChanged && expressionOrValue.valueChanged && value !== Expression.DEFAULT_VALUE) {
if (typeof expressionOrValue !== 'string' && options.showChanged && expressionOrValue.valueChanged && value !== Expression.DEFAULT_VALUE) {
// value changed color has priority over other colors.
container.className = 'value changed';
expressionOrValue.valueChanged = false;
Expand Down
11 changes: 7 additions & 4 deletions src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,18 @@ export interface IReplElementSource {
readonly column: number;
}

export interface IExpressionContainer extends ITreeElement {
export interface IExpressionValue {
readonly value: string;
readonly type?: string;
valueChanged?: boolean;
}

export interface IExpressionContainer extends ITreeElement, IExpressionValue {
readonly hasChildren: boolean;
evaluateLazy(): Promise<void>;
getChildren(): Promise<IExpression[]>;
readonly reference?: number;
readonly memoryReference?: string;
readonly value: string;
readonly type?: string;
valueChanged?: boolean;
readonly presentationHint?: DebugProtocol.VariablePresentationHint | undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { renderExpressionValue } from 'vs/workbench/contrib/debug/browser/baseDe
import { INotebookVariableElement } from 'vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource';

const $ = dom.$;
const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024;

export class NotebookVariablesTree extends WorkbenchObjectTree<INotebookVariableElement> { }

Expand Down Expand Up @@ -56,7 +57,11 @@ export class NotebookVariableRenderer implements ITreeRenderer<INotebookVariable
const text = element.element.value.trim() !== '' ? `${element.element.name}:` : element.element.name;
data.name.textContent = text;

renderExpressionValue(element.element.value, data.value, { colorize: true, showHover: true });
renderExpressionValue(element.element, data.value, {
colorize: true,
showHover: true,
maxValueLength: MAX_VALUE_RENDER_LENGTH_IN_VIEWLET
});
}

disposeTemplate(): void {
Expand Down
Loading