Skip to content

Commit 49a240f

Browse files
committed
fix #363
1 parent 8d02364 commit 49a240f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pythonFiles/preview/jedi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit b594a7d861af662fcb6487c9cada20dc7857e89b

src/client/refactor/proxy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export class RefactorProxy extends vscode.Disposable {
4444
return this.sendCommand<T>(JSON.stringify(command), REFACTOR.ExtractVariable);
4545
}
4646
extractMethod<T>(document: vscode.TextDocument, name: string, filePath: string, range: vscode.Range): Promise<T> {
47+
// Ensure last line is an empty line
48+
if (!document.lineAt(document.lineCount - 1).isEmptyOrWhitespace && range.start.line === document.lineCount - 1) {
49+
return Promise.reject<T>('Missing blank line at the end of document (PEP8).')
50+
}
4751
let command = { "lookup": "extract_method", "file": filePath, "start": document.offsetAt(range.start).toString(), "end": document.offsetAt(range.end).toString(), "id": "1", "name": name };
4852
return this.sendCommand<T>(JSON.stringify(command), REFACTOR.ExtractVariable);
4953
}
@@ -76,7 +80,7 @@ export class RefactorProxy extends vscode.Disposable {
7680
}
7781
this._process = child_process.spawn(pythonPath, ['refactor.py', this.workspaceRoot],
7882
{
79-
cwd: path.join(this._extensionDir, 'pythonFiles'),
83+
cwd: path.join(this._extensionDir, 'pythonFiles'),
8084
env: environmentVariables
8185
});
8286
this._process.stderr.on('data', this.handleStdError.bind(this));

0 commit comments

Comments
 (0)