Initialized a new vscode-extension.

This commit is contained in:
Juha Ristolainen
2017-03-17 10:48:33 +00:00
parent 25558c7930
commit 69f89cc4c4
13 changed files with 313 additions and 2 deletions

34
src/code-stats.ts Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
// the module 'vscode' contains the VS Code extensibility API
// import the module and reference it with the alias vscode in your code below
import * as vscode from "vscode";
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// use the console to output diagnostic information (console.log) and errors (console.error)
// this line of code will only be executed once when your extension is activated
console.log("Congratulations, your extension \"code-stats-vscode\" is now active!");
// the command has been defined in the package.json file
// now provide the implementation of the command with registerCommand
// the commandId parameter must match the command field in package.json
let disposable: vscode.Disposable = vscode.commands.registerCommand("codestats.sayHello", () => {
var editor: vscode.TextEditor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
var selection: vscode.Selection = editor.selection;
var text: string = editor.document.getText(selection);
vscode.window.showInformationMessage("Selected characters: " + text.length);
});
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
export function deactivate() {
}