2017-02-20 15:33:51 +00:00
|
|
|
// 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) {
|
2017-02-20 15:39:04 +00:00
|
|
|
console.log('next-note: activated');
|
2017-02-20 15:33:51 +00:00
|
|
|
|
2017-02-20 15:39:04 +00:00
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('extension.sayHello', function () {
|
2017-02-20 15:33:51 +00:00
|
|
|
vscode.window.showInformationMessage('Hello World!');
|
2017-02-20 15:39:04 +00:00
|
|
|
}));
|
2017-02-20 15:33:51 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-02-20 15:39:04 +00:00
|
|
|
var d = new Date();
|
2017-02-20 15:33:51 +00:00
|
|
|
editor.edit(editBuilder => {
|
2017-02-20 15:39:04 +00:00
|
|
|
editBuilder.insert(cursorEnd, "## "+ d.toString() +"\n");
|
2017-02-20 15:33:51 +00:00
|
|
|
});
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
exports.activate = activate;
|
|
|
|
|
|
|
|
// this method is called when your extension is deactivated
|
|
|
|
function deactivate() {
|
2017-02-20 15:39:04 +00:00
|
|
|
console.log("next-note: deactivated")
|
2017-02-20 15:33:51 +00:00
|
|
|
}
|
|
|
|
exports.deactivate = deactivate;
|