vscode-next-note/extension.js
Vincent Batts 11161b33c5 *: cleanup
Making a few changes for publishing the first command
2017-02-20 10:39:04 -05:00

37 lines
No EOL
1.3 KiB
JavaScript

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
var vscode = require('vscode');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
console.log('next-note: activated');
context.subscriptions.push(vscode.commands.registerCommand('extension.sayHello', function () {
vscode.window.showInformationMessage('Hello World!');
}));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('extension.nextNoteInsertDate', function () {
var editor = vscode.window.activeTextEditor;
if (!editor) {
console.error("no active editor");
return;
};
//editor.document.getWordRangeAtPosition
var cursorEnd = editor.selection.end;
if (editor.document.lineCount > cursorEnd.line+1) {
cursorEnd.line += 1;
}
var d = new Date();
editor.edit(editBuilder => {
editBuilder.insert(cursorEnd, "## "+ d.toString() +"\n");
});
}));
}
exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {
console.log("next-note: deactivated")
}
exports.deactivate = deactivate;