<commit_before>var
    esPhinx,
    Iterable;


(function($) {
    "use strict";

    $.prototype.extend({

        // autocomplete: function(elementsList, optionElements, options, callback) {
        autocomplete: function(elementsList, options, callback) {
            var
                nonCharacterKeysPattern = new RegExp($
                    .nonCharacterKeysPattern()),
                inline = false,
                searchTextBox = this,
                offlineListener,

                resolveArguments = function(options) {
                    if (!options || Object.getPrototypeOf(options) !=
                        Object.getPrototypeOf({})) {
                        options = {};
                    } else {
                        if (!options.caseSensitive ||
                            typeof options.caseSensitive != "boolean") {
                            options.caseSensitive = false;
                        }

                        if (!options.orderlySearch ||
                            typeof options.orderlySearch != "boolean") {
                            options.orderlySearch = false;
                        }
                    }

                },

                resolveAmountChar = function(options) {
                    if (options.afterAmountChar) {
                        return options.afterAmountChar;
                    } else {
                        return 1;
                    }
                },

                offlineSearch = function(elementsList, options) {
                    var
                        resolvedList,
                        firstResolvedList,
                        previousListNode = elementsList;

                    if (typeof offlineListener == "function") {
                        searchTextBox.off("input", offlineListener);
                        searchTextBox.off("focus", offlineListener);
                    }

                    offlineListener = function(e) {
                        if (searchTextBox.value()) {
                            resolvedList = resolveList(previousListNode,
                                options.order);

                            firstResolvedList = resolvedList.elements.parent()
                                .first();
                            if (firstResolvedList.childElements().some()) {
                                previousListNode = firstResolvedList.clone()
                                    .append(resolvedList.elements);
                            }

                            callback.call($(this), resolvedList.elements,
                                          resolvedList.maps, e);
                        } else {
                            // descobrir o porquê de ter de fazer um clone
                            previousListNode = elementsList.clone(true);
                            callback.call($(this), $(), e);
                        }<commit_msg>improves autocomplete<commit_after>var
    esPhinx,
    Iterable;


(function($) {
    "use strict";

    $.prototype.extend({

        // autocomplete: function(elementsList, optionElements, options, callback) {
        autocomplete: function(elementsList, options, callback) {
            var
                nonCharacterKeysPattern = new RegExp($
                    .nonCharacterKeysPattern()),
                inline = false,
                searchTextBox = this,
                offlineListener,

                resolveArguments = function(options) {
                    if (!options || Object.getPrototypeOf(options) !=
                        Object.getPrototypeOf({})) {
                        options = {};
                    } else {
                        if (!options.caseSensitive ||
                            typeof options.caseSensitive != "boolean") {
                            options.caseSensitive = false;
                        }

                        if (!options.orderlySearch ||
                            typeof options.orderlySearch != "boolean") {
                            options.orderlySearch = false;
                        }
                    }

                },

                resolveAmountChar = function(options) {
                    if (options.afterAmountChar) {
                        return options.afterAmountChar;
                    } else {
                        return 1;
                    }
                },

                offlineSearch = function(elementsList, options) {
                    var
                        resolvedList,
                        firstResolvedList,
                        previousSearchText = searchTextBox.value(),
                        previousElementsList = elementsList,
                        elementsList2Recovery = previousElementsList;

                    if (typeof offlineListener == "function") {
                        searchTextBox.off("input", offlineListener);
                        searchTextBox.off("focus", offlineListener);
                    }

                    offlineListener = function(e) {
                        if (searchTextBox.value()) {

                            // ainda pode ser considerado a questão de quantos caracteres um tem a menos que o outro
                            if (searchTextBox.value().length <
                                previousSearchText.length) {
                                previousElementsList = elementsList2Recovery
                                    .clone(true);
                            }
                            previousSearchText = searchTextBox.value();

                            resolvedList = resolveList(previousElementsList,
                                options.order);

                            firstResolvedList = resolvedList.elements.parent()
                                .first();

                            // debugger
                            if (firstResolvedList.childElements().some()) {
                                elementsList2Recovery = previousElementsList
                                    .clone(true);
                                previousElementsList = firstResolvedList.clone()
                                    .append(resolvedList.elements);
                            }

                            callback.call($(this), resolvedList.elements,
                                          resolvedList.maps, e);
                        } else {
                            // a clone must be doing cause' one change the another don't.
                            previousElementsList = elementsList.clone(true);
                            callback.call($(this), $(), e);
                        }
{'fraction_non_alphanumeric': 0.07522057723941977, 'fraction_numerical': 0.0007477194556602363, 'mean_word_length': 0.9470160116448326, 'pattern_counts': {'":': 0, '<': 4, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4377505', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1240, 'n_words': 247}