Skip to content

Commit

Permalink
fix formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Weslen Nascimento committed Feb 8, 2020
1 parent d6d2b72 commit 6cc2fe4
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/proto3Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,23 @@ export function activate(ctx: vscode.ExtensionContext): void {
});

vscode.languages.registerDocumentFormattingEditProvider('proto3', {
provideDocumentFormattingEdits(document: vscode.TextDocument): Thenable<vscode.TextEdit[]> {
return document.save().then(x => {

const style = getClangFormatStyle(document)
let args = [];
if (style) args.push(`-style=${style}`);
args.push(document.fileName);

try {
var output = cp.execFileSync("clang-format", args);
if (output) {
let start = new vscode.Position(0, 0)
let end = new vscode.Position(document.lineCount, 0)
let range = new vscode.Range(start, end);
return [vscode.TextEdit.replace(range, output.toString())];
}
} catch (e) {
vscode.window.showErrorMessage(e.message);
provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] {
const style = getClangFormatStyle(document)
let args = [];
if (style) args.push(`-style=${style}`);
args.push(document.fileName);

try {
var output = cp.execFileSync("clang-format", args);
if (output) {
let start = new vscode.Position(0, 0)
let end = new vscode.Position(document.lineCount, 0)
let range = new vscode.Range(start, end);
return [vscode.TextEdit.replace(range, output.toString())];
}
})
} catch (e) {
vscode.window.showErrorMessage(e.message);
}
}
});

Expand Down

0 comments on commit 6cc2fe4

Please sign in to comment.