<commit_before>'use strict';

exports.create = function(_page) {
    var _keyboard = {};

    var _current_text = '';
    var _remaining = '';
    var _delay = 2;
    var _timeout = null;

    /**
     * Send individual keyboard events for typing text
     * This function is called both as a trigger for the sequence as well as
     * to check if the typing has finished
     */
    _keyboard.type = function(text) {
        if (text !== _current_text) {
            _current_text = text;
            _remaining = text;

            if (_timeout) clearTimeout(_timeout);

            sendKeys();
        }

        // Typing has not finished yet
        if (_remaining.length) {
            return 'Typing <' + _current_text + '> could not be finished.';
        }

        // Typing has finished
        _timeout = null;
        return '';
    };


    function sendKeys() {
        var next_key;

        // Check if the next key is a <SpecialKey>
        var special_keys = /^<([^>]+)>/;
        var matches = _remaining.match(special_keys);
<commit_msg>Fixed major bug in keyboard handling where it would skip a type command if it had the same text as the previous type command<commit_after>'use strict';

exports.create = function(_page) {
    var _keyboard = {};

    var _current_text = '';
    var _remaining = '';
    var _delay = 2;
    var _timeout = null;

    /**
     * Send individual keyboard events for typing text
     * This function is called both as a trigger for the sequence as well as
     * to check if the typing has finished
     */
    _keyboard.type = function(text) {
        if (text !== _current_text) {
            _current_text = text;
            _remaining = text;

            if (_timeout) clearTimeout(_timeout);

            sendKeys();
        }

        // Typing has not finished yet
        if (_remaining.length) {
            return 'Typing <' + _current_text + '> could not be finished.';
        }

        // Typing has finished
        _timeout = null;
        _current_text = null;
        return '';
    };


    function sendKeys() {
        var next_key;

        // Check if the next key is a <SpecialKey>
        var special_keys = /^<([^>]+)>/;
        var matches = _remaining.match(special_keys);

{'fraction_non_alphanumeric': 0.10013291980505096, 'fraction_numerical': 0.0008861320336730173, 'mean_word_length': 1.9210866752910738, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6852306', 'n_tokens_mistral': 639, 'n_tokens_neox': 616, 'n_words': 213}