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

Propagate context information on CopyValueAction evaluate requests #68585

Merged
merged 1 commit into from
Feb 19, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import { isWindows } from 'vs/base/common/platform';
export class CopyValueAction extends Action {
static readonly ID = 'workbench.debug.viewlet.action.copyValue';
static LABEL = nls.localize('copyValue', "Copy Value");
private context: string;

constructor(id: string, label: string, private value: any, @IDebugService private readonly debugService: IDebugService) {
constructor(id: string, label: string, private value: any, @IDebugService private readonly debugService: IDebugService, context?: string) {
super(id, label, 'debug-action copy-value');
this.context = context;
this._enabled = typeof this.value === 'string' || (this.value instanceof Variable && !!this.value.evaluateName);
}

public run(): Promise<any> {
if (this.value instanceof Variable) {
const frameId = this.debugService.getViewModel().focusedStackFrame.frameId;
const session = this.debugService.getViewModel().focusedSession;
return session.evaluate(this.value.evaluateName, frameId).then(result => {
return session.evaluate(this.value.evaluateName, frameId, this.context).then(result => {
clipboard.writeText(result.body.result);
}, err => clipboard.writeText(this.value.value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export class VariablesView extends ViewletPanel {
const element = e.element;
if (element instanceof Variable && !!element.value) {
const actions: IAction[] = [];
const variable = <Variable>element;
const variable = element as Variable;
actions.push(new SetValueAction(SetValueAction.ID, SetValueAction.LABEL, variable, this.debugService, this.keybindingService));
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable, this.debugService));
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable, this.debugService, 'variables'));
actions.push(new CopyEvaluatePathAction(CopyEvaluatePathAction.ID, CopyEvaluatePathAction.LABEL, variable));
actions.push(new Separator());
actions.push(new AddToWatchExpressionsAction(AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable, this.debugService, this.keybindingService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class WatchExpressionsView extends ViewletPanel {
actions.push(new AddWatchExpressionAction(AddWatchExpressionAction.ID, AddWatchExpressionAction.LABEL, this.debugService, this.keybindingService));
actions.push(new EditWatchExpressionAction(EditWatchExpressionAction.ID, EditWatchExpressionAction.LABEL, this.debugService, this.keybindingService));
if (!expression.hasChildren) {
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, expression.value, this.debugService));
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, expression.value, this.debugService, 'watch'));
}
actions.push(new Separator());

Expand All @@ -157,9 +157,9 @@ export class WatchExpressionsView extends ViewletPanel {
} else {
actions.push(new AddWatchExpressionAction(AddWatchExpressionAction.ID, AddWatchExpressionAction.LABEL, this.debugService, this.keybindingService));
if (element instanceof Variable) {
const variable = <Variable>element;
const variable = element as Variable;
if (!variable.hasChildren) {
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable, this.debugService));
actions.push(new CopyValueAction(CopyValueAction.ID, CopyValueAction.LABEL, variable, this.debugService, 'watch'));
}
actions.push(new Separator());
}
Expand Down