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

Disable editing of read only variables #14440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 5 additions & 1 deletion packages/debug/src/browser/console/debug-console-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export class DebugVariable extends ExpressionContainer {
return this._value || this.variable.value;
}

get readOnly(): boolean {
return this.variable.presentationHint?.attributes?.includes('readOnly') ?? false;
}

override render(): React.ReactNode {
const { type, value, name } = this;
return <div className={this.variableClassName}>
Expand Down Expand Up @@ -234,7 +238,7 @@ export class DebugVariable extends ExpressionContainer {
protected setNameRef = (nameRef: HTMLSpanElement | null) => this.nameRef = nameRef || undefined;

async open(): Promise<void> {
if (!this.supportSetVariable) {
if (!this.supportSetVariable || this.readOnly) {
return;
}
const input = new SingleTextInputDialog({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi

registry.registerCommand(DebugCommands.SET_VARIABLE_VALUE, {
execute: () => this.selectedVariable && this.selectedVariable.open(),
isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable,
isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable && !this.selectedVariable.readOnly,
isVisible: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable
});
registry.registerCommand(DebugCommands.COPY_VARIABLE_VALUE, {
Expand Down
Loading