Skip to content

Commit

Permalink
FIx #91 Corrigido erro ao chamar o comando de formatação
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYampolschi committed Jun 19, 2019
1 parent e698f4f commit f3157d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
},
{
"command": "totvs-developer-studio.run.formatter",
"title": "Formatar",
"title": "Format",
"description": "Aplica formatação em arquivo fontes AdvPL e e suas variações.",
"category": "TOTVS",
"icon": {
Expand Down
13 changes: 9 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,13 @@ export function activate(context: ExtensionContext) {
// Inicialização do formatador Adv/PL
context.subscriptions.push(
vscode.commands.registerCommand('totvs-developer-studio.run.formatter', (args: any[]) => {
console.log("formatador ativado");

//console.log("formatador ativado");
if(args === undefined) {
let aeditor = vscode.window.activeTextEditor;
if(aeditor !== undefined) {
args = [aeditor.document.uri]
}
}
if (instanceOfUri(args)) {
advplResourceFormatting([args.fsPath]);
} else if (instanceOfUriArray(args)) {
Expand Down Expand Up @@ -357,11 +362,11 @@ export function activate(context: ExtensionContext) {
}

function instanceOfUri(object: any): object is Uri {
return 'scheme' in object;
return object !== undefined && 'scheme' in object;
}

function instanceOfUriArray(object: any): object is Uri[] {
return Array.isArray(object);
return object !== undefined && Array.isArray(object);
}

// this method is called when your extension is deactivated
Expand Down

0 comments on commit f3157d8

Please sign in to comment.