Skip to content

Commit 6c7a0eb

Browse files
committed
fixes to json deserialization
1 parent f3c454c commit 6c7a0eb

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

pythonFiles/refactor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,13 @@ def watch(self):
244244
try:
245245
self._process_request(self._input.readline())
246246
except Exception as ex:
247-
message = ex.message + ' \n' + traceback.format_exc()
247+
message = ""
248+
try:
249+
message = ex.message
250+
except:
251+
pass
252+
253+
message = message + ' \n' + traceback.format_exc()
248254
sys.stderr.write('$ERROR' + str(len(message)) + ':' + message)
249255
sys.stderr.flush()
250256

src/client/refactor/proxy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export class RefactorProxy extends vscode.Disposable {
3636
this._process = null;
3737
}
3838
extractVariable<T>(document: vscode.TextDocument, name: string, filePath: string, range: vscode.Range): Promise<T> {
39-
let command = `{"lookup":"extract_variable", "file":"${filePath}", "start":"${document.offsetAt(range.start)}", "end":"${document.offsetAt(range.end)}", "id":"1", "name":"${name}"}`;
40-
return this.sendCommand<T>(command, REFACTOR.ExtractVariable);
39+
let command = {"lookup":"extract_variable", "file":`"${filePath}"`, "start":document.offsetAt(range.start).toString(), "end":document.offsetAt(range.end).toString(), "id":"1", "name":`"${name}"`};
40+
return this.sendCommand<T>(JSON.stringify(command), REFACTOR.ExtractVariable);
4141
}
4242
extractMethod<T>(document: vscode.TextDocument, name: string, filePath: string, range: vscode.Range): Promise<T> {
43-
let command = `{"lookup":"extract_method", "file":"${filePath}", "start":"${document.offsetAt(range.start)}", "end":"${document.offsetAt(range.end)}", "id":"1","name":"${name}"}`;
44-
return this.sendCommand<T>(command, REFACTOR.ExtractVariable);
45-
}
43+
let command = {"lookup":"extract_method", "file":`"${filePath}"`, "start":document.offsetAt(range.start).toString(), "end":document.offsetAt(range.end).toString(), "id":"1","name":`"${name}"`};
44+
return this.sendCommand<T>(JSON.stringify(command), REFACTOR.ExtractVariable);
45+
}
4646
private sendCommand<T>(command: string, telemetryEvent: string): Promise<T> {
4747
let timer = new Delays();
4848
return this.initialize(this.pythonSettings.pythonPath).then(() => {

0 commit comments

Comments
 (0)