forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoPep8Formatter.ts
More file actions
21 lines (18 loc) · 1.16 KB
/
Copy pathautoPep8Formatter.ts
File metadata and controls
21 lines (18 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
import * as vscode from 'vscode';
import {BaseFormatter} from './baseFormatter';
import * as settings from '../common/configSettings';
export class AutoPep8Formatter extends BaseFormatter {
constructor(protected outputChannel: vscode.OutputChannel, protected pythonSettings: settings.IPythonSettings, protected workspaceRootPath: string) {
super('autopep8', outputChannel, pythonSettings, workspaceRootPath);
}
public formatDocument(document: vscode.TextDocument, options: vscode.FormattingOptions, token: vscode.CancellationToken, range?: vscode.Range): Thenable<vscode.TextEdit[]> {
let autopep8Path = this.pythonSettings.formatting.autopep8Path;
let autoPep8Args = Array.isArray(this.pythonSettings.formatting.autopep8Args) ? this.pythonSettings.formatting.autopep8Args : [];
autoPep8Args = autoPep8Args.concat(['--diff']);
if (range && !range.isEmpty) {
autoPep8Args = autoPep8Args.concat(['--line-range', (range.start.line + 1).toString(), (range.end.line + 1).toString()]);
}
return super.provideDocumentFormattingEdits(document, options, token, autopep8Path, autoPep8Args);
}
}