From f3157d82cb4c9f410ac30cb4bc9bfee050c1e6ed Mon Sep 17 00:00:00 2001 From: DanielYampolschi Date: Wed, 19 Jun 2019 15:40:19 -0300 Subject: [PATCH] =?UTF-8?q?FIx=20#91=20Corrigido=20erro=20ao=20chamar=20o?= =?UTF-8?q?=20comando=20de=20formata=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/extension.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4dd28f8a..24c6a96e 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/extension.ts b/src/extension.ts index 627ef7c7..aae0daa3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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)) { @@ -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