Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Resolve #16: Setting variable values #20

Merged
merged 1 commit into from
Jan 24, 2018
Merged
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
24 changes: 24 additions & 0 deletions ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def on_initialize(self, request, args):
request,
supportsExceptionInfoRequest=True,
supportsConfigurationDoneRequest=True,
supportsSetVariable=True,
exceptionBreakpointFilters=[
{'filter': 'raised', 'label': 'Raised Exceptions'},
{'filter': 'uncaught', 'label': 'Uncaught Exceptions'},
Expand Down Expand Up @@ -456,6 +457,29 @@ def on_variables(self, request, args):

self.send_response(request, variables=variables)

@async_handler
def on_setVariable(self, request, args):
vsc_var = int(args['variablesReference'])
pyd_var = self.var_map.to_pydevd(vsc_var)

# VSC gives us variablesReference to the parent of the variable being set, and
# variable name; but pydevd wants the ID (or rather path) of the variable itself.
pyd_var += (args['name'],)
vsc_var = self.var_map.to_vscode(pyd_var)

cmd_args = [str(s) for s in pyd_var] + [args['value']]
_, _, resp_args = yield self.pydevd_request(pydevd_comm.CMD_CHANGE_VARIABLE, '\t'.join(cmd_args))
xml = untangle.parse(resp_args).xml
xvar = xml.var

response = {
'type': unquote(xvar['type']),
'value': unquote(xvar['value']),
}
if bool(xvar['isContainer']):
response['variablesReference'] = vsc_var
self.send_response(request, **response)

@async_handler
def on_pause(self, request, args):
# TODO: docstring
Expand Down