<commit_before>'use strict';
import * as vscode from 'vscode';

enum Scroll {
	Center,
	Top,
	Bottom
}
import { ExtPrefix } from './constants';


export function activateText(context: vscode.ExtensionContext) {
	var scrollPosition: Scroll = Scroll.Center;
    context.subscriptions.push(vscode.commands.registerCommand(ExtPrefix + ".back-to-indentation", () => {
        let editor = vscode.window.activeTextEditor;

        const pos = editor.selection.active;
        const line = editor.document.lineAt(pos.line);
        const n = new vscode.Position(pos.line, line.firstNonWhitespaceCharacterIndex);
        editor.selection = new vscode.Selection(n, n);
    }));

	vscode.window.onDidChangeTextEditorSelection(() => {
		scrollPosition = Scroll.Center;
	});
    context.subscriptions.push(vscode.commands.registerCommand(ExtPrefix + ".recenter", () => {
		if (scrollPosition === Scroll.Center) {
			vscode.window.activeTextEditor.revealRange(
				vscode.window.activeTextEditor.selection,
				vscode.TextEditorRevealType.InCenter
			);
			scrollPosition = Scroll.Top;
		} else if (scrollPosition === Scroll.Top) {
			let promises = [
				vscode.commands.executeCommand("scrollPageDown"),
				vscode.commands.executeCommand("scrollPageDown")
			];

			Promise.all(promises).then(() => {
				vscode.window.activeTextEditor.revealRange(
					vscode.window.activeTextEditor.selection,
					vscode.TextEditorRevealType.Default
				);
				scrollPosition = Scroll.Bottom;
			});
		} else if (scrollPosition === Scroll.Bottom) {
			let promises = [
				vscode.commands.executeCommand("scrollPageUp"),
				vscode.commands.executeCommand("scrollPageUp")
			];

			Promise.all(promises).then(() => {
				vscode.window.activeTextEditor.revealRange(
					vscode.window.activeTextEditor.selection,
					vscode.TextEditorRevealType.Default
				);
				scrollPosition = Scroll.Center;
			});
		}
	}));
}<commit_msg>use revealLine to recenter.<commit_after>'use strict';
import * as vscode from 'vscode';

enum Scroll {
	Center,
	Top,
	Bottom
}
import { ExtPrefix } from './constants';


export function activateText(context: vscode.ExtensionContext) {
	var scrollPosition: Scroll = Scroll.Center;
    context.subscriptions.push(vscode.commands.registerCommand(ExtPrefix + ".back-to-indentation", () => {
        let editor = vscode.window.activeTextEditor;

        const pos = editor.selection.active;
        const line = editor.document.lineAt(pos.line);
        const n = new vscode.Position(pos.line, line.firstNonWhitespaceCharacterIndex);
        editor.selection = new vscode.Selection(n, n);
    }));

	vscode.window.onDidChangeTextEditorSelection(() => {
		scrollPosition = Scroll.Center;
	});
    context.subscriptions.push(vscode.commands.registerCommand(ExtPrefix + ".recenter", () => {
		const editor = vscode.window.activeTextEditor;
        const pos = editor.selection.active;
        const line = editor.document.lineAt(pos.line);
        vscode.commands.executeCommand('revealLine', {
			'lineNumber': line.lineNumber,
            'at': 'center',
        });
	}));
}
{'fraction_non_alphanumeric': 0.13016596160104132, 'fraction_numerical': 0.0, 'mean_word_length': 3.7807153965785383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2517789', 'n_tokens_mistral': 1045, 'n_tokens_neox': 938, 'n_words': 151}