From 835228917ffb1a9b1bfb3505819a6bdef22a3a17 Mon Sep 17 00:00:00 2001 From: Andy Perlitch Date: Thu, 12 Jul 2018 13:34:06 -0700 Subject: [PATCH] add semicolon config option --- package.json | 11 ++++++++--- src/import-fixer.ts | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b2cf6cb..afa98b8 100644 --- a/package.json +++ b/package.json @@ -79,17 +79,22 @@ "autoimport.showNotifications": { "type": "boolean", "default": false, - "description": "Specifies wether to show notifications from Auto Import" + "description": "Specifies whether to show notifications from Auto Import" }, "autoimport.doubleQuotes": { "type": "boolean", "default": false, - "description": "Specifies wether to use double quotes" + "description": "Specifies whether to use double quotes" + }, + "autoimport.semicolon": { + "type": "boolean", + "default": true, + "description": "Specifies whether to use a semicolon at the end of the line" }, "autoimport.spaceBetweenBraces": { "type": "boolean", "default": true, - "description": "Specifies wether to use spaces between first and last brace" + "description": "Specifies whether to use spaces between first and last brace" }, "autoimport.autoComplete": { "type": "boolean", diff --git a/src/import-fixer.ts b/src/import-fixer.ts index fab04d9..1418d2e 100644 --- a/src/import-fixer.ts +++ b/src/import-fixer.ts @@ -7,12 +7,14 @@ export class ImportFixer { private spacesBetweenBraces; private doubleQuotes; + private semicolon; constructor() { let config = vscode.workspace.getConfiguration('autoimport'); this.spacesBetweenBraces = config.get('spaceBetweenBraces'); this.doubleQuotes = config.get('doubleQuotes'); + this.semicolon = config.get('semicolon'); } public fix(document: vscode.TextDocument, range: vscode.Range, @@ -110,7 +112,8 @@ export class ImportFixer { isDefault ? '' : this.spacesBetweenBraces ? ' }' : '}', ' from ', quoteSymbol + formattedPath + quoteSymbol, - endline ? ';\r\n' : ';', + this.semicolon ? ';' : '', + endline ? '\r\n' : '', ].join(''); return importStr; }