<commit_before>/**
 * HistoryTracker is a handrolled undo/redo tracker for VSC. We currently
 * track history as a list of "steps", each of which consists of 1 or more
 * "changes".
 *
 * A Change is something like adding or deleting a few letters.
 *
 * A Step is multiple Changes.
 *
 * Undo/Redo will advance forward or backwards through Steps.
 */

import * as vscode from "vscode";
import * as _ from "lodash";

import { Position } from './../motion/position';
import { TextEditor } from './../textEditor';
import { RecordedState } from './../mode/ModeHandler';

import DiffMatchPatch = require("diff-match-patch");

const diffEngine = new DiffMatchPatch.diff_match_patch();
diffEngine.Diff_Timeout = 1; // 1 second

export class DocumentChange {
  start : Position;
  text  : string;
  isAdd : boolean;

  constructor(start: Position, text: string, isAdd: boolean) {
    this.start = start;
    this.text  = text;
    this.isAdd = isAdd;
  }

  /**
   * Run this change.
   */
  public async do(undo = false): Promise<void> {
    if ((this.isAdd && !undo) || (!this.isAdd && undo)) {
      await TextEditor.insert(this.text, this.start, false);
    } else {
      await TextEditor.delete(new vscode.Range(this.start, this.end()));
    }
  }
<commit_msg>travis is not smart about upper/lower case<commit_after>/**
 * HistoryTracker is a handrolled undo/redo tracker for VSC. We currently
 * track history as a list of "steps", each of which consists of 1 or more
 * "changes".
 *
 * A Change is something like adding or deleting a few letters.
 *
 * A Step is multiple Changes.
 *
 * Undo/Redo will advance forward or backwards through Steps.
 */

import * as vscode from "vscode";
import * as _ from "lodash";

import { Position } from './../motion/position';
import { TextEditor } from './../textEditor';
import { RecordedState } from './../mode/modeHandler';

import DiffMatchPatch = require("diff-match-patch");

const diffEngine = new DiffMatchPatch.diff_match_patch();
diffEngine.Diff_Timeout = 1; // 1 second

export class DocumentChange {
  start : Position;
  text  : string;
  isAdd : boolean;

  constructor(start: Position, text: string, isAdd: boolean) {
    this.start = start;
    this.text  = text;
    this.isAdd = isAdd;
  }

  /**
   * Run this change.
   */
  public async do(undo = false): Promise<void> {
    if ((this.isAdd && !undo) || (!this.isAdd && undo)) {
      await TextEditor.insert(this.text, this.start, false);
    } else {
      await TextEditor.delete(new vscode.Range(this.start, this.end()));
    }
  }

{'fraction_non_alphanumeric': 0.13152728700431882, 'fraction_numerical': 0.002355712603062426, 'mean_word_length': 3.260869565217391, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3195919', 'n_tokens_mistral': 802, 'n_tokens_neox': 782, 'n_words': 258}