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

debug: fix watch expression errors #11953

Merged
merged 1 commit into from
Dec 6, 2022
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
5 changes: 5 additions & 0 deletions packages/debug/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@
margin: auto;
}

.theia-debug-console-variable .watch-error {
font-style: italic;
color: var(--theia-debugConsole-errorForeground);
}

/** Editor **/

.theia-debug-breakpoint-icon {
Expand Down
12 changes: 8 additions & 4 deletions packages/debug/src/browser/view/debug-watch-expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { nls } from '@theia/core';
export class DebugWatchExpression extends ExpressionItem {

readonly id: number;
protected isError: boolean;

constructor(protected readonly options: {
id: number,
Expand All @@ -40,17 +41,20 @@ export class DebugWatchExpression extends ExpressionItem {
await super.evaluate('watch');
}

protected override setResult(body?: DebugProtocol.EvaluateResponse['body']): void {
// overridden to ignore error
super.setResult(body);
protected override setResult(body?: DebugProtocol.EvaluateResponse['body'], error?: string): void {
if (!this.options.session()) {
return;
}
msujew marked this conversation as resolved.
Show resolved Hide resolved
super.setResult(body, error);
this.isError = !!error;
this.options.onDidChange();
}

override render(): React.ReactNode {
return <div className='theia-debug-console-variable'>
<div className={TREE_NODE_SEGMENT_GROW_CLASS}>
<span title={this.type || this._expression} className='name'>{this._expression}: </span>
<span title={this._value} ref={this.setValueRef}>{this._value}</span>
<span title={this._value} ref={this.setValueRef} className={this.isError ? 'watch-error' : ''}>{this._value}</span>
</div>
<div className={codicon('close', true)} title={nls.localizeByDefault('Remove Expression')} onClick={this.options.remove} />
</div>;
Expand Down