'use strict';
import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
	console.log('Congratulations, your extension "vscode-extension-boilerplate" 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 disposableHelloWorld = vscode.commands.registerCommand(
		'taskjuggler.helloWorld', () => {
			// Display a message box to the user
			vscode.window.showInformationMessage('Hello World!');
		});
	context.subscriptions.push(disposableHelloWorld);

	var disposableTJP = vscode.languages.registerDocumentFormattingEditProvider(
		'taskjuggler',
		formattingEditProvider);

	// vscode.workspace.onDidChangeConfiguration(updateVKBeautify, this, context.subscriptions);
	context.subscriptions.push(disposableTJP);
}

// this method is called when your extension is deactivated
export function deactivate() { }

const formattingEditProvider = {
	provideDocumentFormattingEdits(document: vscode.TextDocument):
		vscode.TextEdit[] {
		const firstLine = document.lineAt(0);

		// if (firstLine.text !== '42') {
		// 	return [vscode.TextEdit.insert(firstLine.range.start, '42\n')];
		// }
		return [vscode.TextEdit.insert(firstLine.range.start, '')];
	}
};