<commit_before>var IEditor = (function() {

    /*
     * Input is idea of document body
     */
    function IEditor(editorPlace, terminalPlace, systemPlace) {
        
        var esprima_options = {
            comment: false,
            raw: false,
            range: false,
            loc: true
        };
        // good timer between series of input
        var parserTimeout = 850; //ms
        var timerId;
        var isAutoFormatted = false;
        
        function parse() {
            // clear out timer id
            timerId = undefined;
            try {
                var cachedEditorValue = editor.getValue();
                var tree = esprima.parse(cachedEditorValue, esprima_options);
                var snapshot = Tracer.trace(tree);
                // console.log(snapshot);
                Format.align(cachedEditorValue, terminal, snapshot);
                //isAutoFormatted = true;
                //editor.setValue(result.format);
                //var curloc = editor.getCursor();                
                
            } catch (e) { }
        }
        
        function editorOnChange(editor, changes) {            
            if (isAutoFormatted) {
                isAutoFormatted = false;
            }
            else {
                if (timerId !== undefined) {
                    window.clearTimeout(timerId);
                }
                
                // create new timer
                timerId = window.setTimeout(parse, parserTimeout);
            }            
        }

        function terminalOnChange(terminal, changes) {
        }



        var editorTextArea = document.getElementById(editorPlace);
        var terminalTextArea = document.getElementById(terminalPlace);

        if (!editorTextArea) {
            console.log("editor element doesn't exist.");
            return;
        }

        if (!terminalTextArea) {
            console.log("terminal element doesn't exist.");
            return;
        }

        var editor = CodeMirror.fromTextArea(editorTextArea, {
            mode: "javascript",
            indentUnit: 4,
            lineNumbers: true,
            matchBrackets: true,
            onChange: editorOnChange
        });

        var terminal = CodeMirror.fromTextArea(terminalTextArea, {
            mode: "javascript",
            onChange: terminalOnChange
        });
                
        return {editor: editor, terminal: terminal};
    }

    return IEditor;
})();
<commit_msg>implement copy and paste on change of editor to terminal<commit_after>var IEditor = (function() {

    /*
     * Input is idea of document body
     */
    function IEditor(editorPlace, terminalPlace, systemPlace) {
        
        var esprima_options = {
            comment: false,
            raw: false,
            range: false,
            loc: true
        };
        // good timer between series of input
        var parserTimeout = 850; //ms
        var timerId;
        var isAutoFormatted = false;
        
        function parse() {
            // clear out timer id
            timerId = undefined;
            try {
                var cachedEditorValue = editor.getValue();
                var tree = esprima.parse(cachedEditorValue, esprima_options);
                var snapshot = Tracer.trace(tree);
                // console.log(snapshot);
                Format.align(cachedEditorValue, terminal, snapshot);
                //isAutoFormatted = true;
                //editor.setValue(result.format);
                //var curloc = editor.getCursor();                
                
            } catch (e) { }
        }
        
        function mergeText(text) {
            
        }
        
        function editorOnChange(editor, changes) {
            do {
                // Put into terminal
                terminal.replaceRange(Util.merge(changes.text), changes.from, changes.to);                
            } while (changes = changes.next)
                        
            if (isAutoFormatted) {
                isAutoFormatted = false;
            }
            else {
                if (timerId !== undefined) {
                    window.clearTimeout(timerId);
                }
                
                // create new timer
                timerId = window.setTimeout(parse, parserTimeout);
            }            
        }
        
        function editorOnScroll() {
            
        }

        function terminalOnFocus() {
            
        }
        
        function terminalOnBlur() {
            
        }
        
        function terminalOnScroll() {
            
        }

        var editorTextArea = document.getElementById(editorPlace);
        var terminalTextArea = document.getElementById(terminalPlace);

        if (!editorTextArea) {
            console.log("editor element doesn't exist.");
            return;
        }

        if (!terminalTextArea) {
            console.log("terminal element doesn't exist.");
            return;
        }

        var editor = CodeMirror.fromTextArea(editorTextArea, {
            mode: "javascript",
            indentUnit: 4,
            lineNumbers: true,
            matchBrackets: true,
            onChange: editorOnChange,
            onScroll: editorOnScroll
        });

        var terminal = CodeMirror.fromTextArea(terminalTextArea, {
            mode: "javascript",
            readOnly: true,
            onFocus: terminalOnFocus,
            onBlur: terminalOnBlur,
            onScroll: terminalOnScroll
        });
                
        return {editor: editor, terminal: terminal};
    }

    return IEditor;
})();

{'fraction_non_alphanumeric': 0.08474876150035386, 'fraction_numerical': 0.0014154281670205238, 'mean_word_length': 1.271193250301326, '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': '1035069', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1302, 'n_words': 308}