<commit_before>import * as vscode from 'vscode';
import { TextEditor, Selection, Position } from 'vscode';
import { KillRing } from './kill-ring';

var markSet: boolean = false;
var isUserCommand: boolean = true;
var killRing: KillRing = new KillRing([]);

export function activate(context: vscode.ExtensionContext) {
  let commands = new Map<string, (...args: any[]) => any>([
    ['transient.cancel', cancel],
    ['transient.setMark', setMark],
    ['transient.unsetMark', unsetMark],
    ['transient.yank', yank],
    ['transient.kill', kill],
    ['transient.killRegion', killRegion],
    ['transient.killRegionOrBackwardWord', killRegionOrBackwardWord],
    ['transient.killBackwardWord', killBackwardWord],
    ['transient.copyRegion', copyRegion],
    ['cursorParagraphUp', cursorParagraphUp],
    ['cursorParagraphDown', cursorParagraphDown],
    ['cursorParagraphUpSelect', cursorParagraphUpSelect],
    ['cursorParagraphDownSelect', cursorParagraphDownSelect]
  ]);
  commands.forEach((func, key) =>
    context.subscriptions.push(vscode.commands.registerTextEditorCommand(key, func))
  );

  let moves = [
    'cursorLeft',
    'cursorRight',
    'cursorUp',
    'cursorDown',
    'cursorHome',
    'cursorEnd',
    'cursorTop',
    'cursorBottom',
    'cursorWordLeft',
    'cursorWordRight',
    'cursorParagraphUp',
    'cursorParagraphDown'
  ];

  moves.forEach(move => {
    let key = 'transient.' + move;
    let f = () => vscode.commands.executeCommand(markSet ? move + 'Select' : move);
    let command = vscode.commands.registerTextEditorCommand(key, f);
    context.subscriptions.push(command);
  });

  vscode.window.onDidChangeTextEditorSelection(() => {
    if (isUserCommand) killRing.seal();
  });
}

export function deactivate() {}

function cursorParagraphDown(editor: TextEditor) {
  let end = editor.document.lineAt(editor.document.lineCount - 1).range.end;
  cursorParagraphMove(editor, l => l + 1, l => l < editor.document.lineCount, end, false);
}

function cursorParagraphDownSelect(editor: TextEditor) {
  let end = editor.document.lineAt(editor.document.lineCount - 1).range.end;
  cursorParagraphMove(editor, l => l + 1, l => l < editor.document.lineCount, end, false);
}
<commit_msg>Add an event listner to subscriptions<commit_after>import * as vscode from 'vscode';
import { TextEditor, Selection, Position } from 'vscode';
import { KillRing } from './kill-ring';

var markSet: boolean = false;
var isUserCommand: boolean = true;
var killRing: KillRing = new KillRing([]);

export function activate(context: vscode.ExtensionContext) {
  let commands = new Map<string, (...args: any[]) => any>([
    ['transient.cancel', cancel],
    ['transient.setMark', setMark],
    ['transient.unsetMark', unsetMark],
    ['transient.yank', yank],
    ['transient.kill', kill],
    ['transient.killRegion', killRegion],
    ['transient.killRegionOrBackwardWord', killRegionOrBackwardWord],
    ['transient.killBackwardWord', killBackwardWord],
    ['transient.copyRegion', copyRegion],
    ['cursorParagraphUp', cursorParagraphUp],
    ['cursorParagraphDown', cursorParagraphDown],
    ['cursorParagraphUpSelect', cursorParagraphUpSelect],
    ['cursorParagraphDownSelect', cursorParagraphDownSelect]
  ]);
  commands.forEach((func, key) =>
    context.subscriptions.push(vscode.commands.registerTextEditorCommand(key, func))
  );

  let moves = [
    'cursorLeft',
    'cursorRight',
    'cursorUp',
    'cursorDown',
    'cursorHome',
    'cursorEnd',
    'cursorTop',
    'cursorBottom',
    'cursorWordLeft',
    'cursorWordRight',
    'cursorParagraphUp',
    'cursorParagraphDown'
  ];

  moves.forEach(move => {
    let key = 'transient.' + move;
    let f = () => vscode.commands.executeCommand(markSet ? move + 'Select' : move);
    let command = vscode.commands.registerTextEditorCommand(key, f);
    context.subscriptions.push(command);
  });

  context.subscriptions.push(
    vscode.window.onDidChangeTextEditorSelection(() => {
      if (isUserCommand) killRing.seal();
    })
  );
}

export function deactivate() {}

function cursorParagraphDown(editor: TextEditor) {
  let end = editor.document.lineAt(editor.document.lineCount - 1).range.end;
  cursorParagraphMove(editor, l => l + 1, l => l < editor.document.lineCount, end, false);
}

function cursorParagraphDownSelect(editor: TextEditor) {
  let end = editor.document.lineAt(editor.document.lineCount - 1).range.end;
  cursorParagraphMove(editor, l => l + 1, l => l < editor.document.lineCount, end, false);
}

{'fraction_non_alphanumeric': 0.1458980044345898, 'fraction_numerical': 0.0017738359201773836, 'mean_word_length': 4.528186274509804, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '1951531', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1399, 'n_words': 282}