<commit_before>/* global ace removeAllVCMarkers */

var createEditor;
var author;

function injectCreate(id) {
    $("#" + id).load("right/html/rightHTML", function () {
        injectCreateEditor();

        // Check to see if we already have an author ID
        if (localStorage.getItem("author")) {
            // Reuse the same author ID
            author = localStorage.getItem("author");
        } else {
            // Generate a random number from 1 to 10000
            author = Math.floor(Math.random() * 10000 + 1);
            localStorage.setItem("author", author);
        }
    });
}

function injectCreateEditor() {
    var ResolveMode = ace.require("ace/mode/resolve").Mode;

    Range = ace.require("ace/range").Range;
    createEditor = ace.edit("editor");
    createEditor.setTheme("ace/theme/github");

    // Set this to RESOLVE mode
    createEditor.session.setMode(new ResolveMode());

    // Gets rid of a weird Ace Editor bug
    // createEditor.$blockScrolling = Infinity;

    createEditor.setFontSize(18);
    createEditor.on("change", removeAllVCMarkers);
    createEditor.on("change", checkEdit);
}

function checkEdit(change) {
    var arr = [change];
    arr.forEach(function(obj){console.log(obj);});
    createEditor.getSession().undoChanges(arr, true);
}<commit_msg>Intermediate commit, cause I messed up<commit_after>/* global ace removeAllVCMarkers */

var createEditor;
var author;

function injectCreate(id) {
    $("#" + id).load("right/html/rightHTML", function () {
        injectCreateEditor();

        // Check to see if we already have an author ID
        if (localStorage.getItem("author")) {
            // Reuse the same author ID
            author = localStorage.getItem("author");
        } else {
            // Generate a random number from 1 to 10000
            author = Math.floor(Math.random() * 10000 + 1);
            localStorage.setItem("author", author);
        }
    });
}

function injectCreateEditor() {
    var ResolveMode = ace.require("ace/mode/resolve").Mode;

    Range = ace.require("ace/range").Range;
    createEditor = ace.edit("editor");
    createEditor.setTheme("ace/theme/github");

    // Set this to RESOLVE mode
    createEditor.session.setMode(new ResolveMode());

    // Gets rid of a weird Ace Editor bug
    // createEditor.$blockScrolling = Infinity;

    createEditor.setFontSize(18);
    createEditor.on("change", removeAllVCMarkers);
    createEditor.on("change", checkEdit);
}

function checkEdit(change) {
    var manager = createEditor.getSession().getUndoManager();
    
    // Must wait for the change to filter through the event system. There is
    // probably a way to catch it, but I couldn't find it.
    setTimeout(function(){
        console.log(change);

        if (manager.hasUndo())
            manager.undo(true);
    }, 0);
}
{'fraction_non_alphanumeric': 0.1303735024665257, 'fraction_numerical': 0.0102184637068358, 'mean_word_length': 2.780292942743009, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7028078', 'n_tokens_mistral': 829, 'n_tokens_neox': 796, 'n_words': 206}