Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const vscode = require('vscode');
const endWithSemicolon = vscode.workspace.getConfiguration('ConsoleUtils', 'endWithSemicolon')

const insertText = (val) => {
const editor = vscode.window.activeTextEditor;
Expand Down Expand Up @@ -51,6 +52,8 @@ function activate(context) {

const insertLogStatement = vscode.commands.registerCommand('extension.insertLogStatement', () => {
const editor = vscode.window.activeTextEditor;
const endWithSemicolon = vscode.workspace.getConfiguration('consoleUtils').endWithSemicolon;

if (!editor) { return; }

const selection = editor.selection;
Expand All @@ -59,7 +62,7 @@ function activate(context) {
text
? vscode.commands.executeCommand('editor.action.insertLineAfter')
.then(() => {
const logToInsert = `console.log('${text}: ', ${text});`;
const logToInsert = `console.log('${text}: ', ${text})${ endWithSemicolon ? ';' : '' }`;
insertText(logToInsert);
})
: insertText('console.log();');
Expand All @@ -85,6 +88,7 @@ function activate(context) {
exports.activate = activate;

function deactivate() {

}

exports.deactivate = deactivate;
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@
"key": "shift+ctrl+d",
"mac": "shift+cmd+d"
}
]
],
"configuration": {
"title": "ConsoleUtils",
"properties": {
"consoleUtils.endWithSemicolon": {
"type": "boolean",
"default": true,
"description": "Place a semicolon at the end of the console.log line."
}
}
}
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
Expand Down