<commit_before>var
    esPhinx,
    Iterable;


(function($) {
    "use strict";

    $.prototype.extend({

        autocomplete: function(elementsList, options, callback) {
            var
                charactersNumber,
                searchTextBox = this,
                nonCharacterKeysPattern = new RegExp($
                    .nonCharacterKeysPattern()),
                inline = false,
                elements2Recovery = [],
                afterAmountCharacters = options.afterAmountChar,

                fillInToRecovery = function(object, times) {
                    var
                        i = 0;

                    while (i++ < Math.abs(times)) {
                        elements2Recovery.push(object);
                    }
                },

                resolveArguments = function(options) {
                    if (Object.getPrototypeOf(options) !=
                        Object.getPrototypeOf({})) {
                        options = {};
                    }

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

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

                    if (typeof afterAmountCharacters != "number") {
                        afterAmountCharacters = 1;
                    }

                },

                inlineSearch = function(elements, options) {
                    var
                        eventListenerMethod,
                        previousElements = elements,
                        previousSearchText = searchTextBox.value();

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

                    eventListenerMethod = function(e) {
                        var
                            resolvedList,
                            resolvedElementsParent,
                            foundElements,
                            exclusionIndex,
                            searchTextLength = searchTextBox.value().length;

                        if (searchTextBox.value()) {
                            charactersNumber = previousSearchText.length -
                                searchTextLength;

                            exclusionIndex = searchTextBox.cursorPosition();

                            // when delete
                            if (searchTextLength < previousSearchText.length &&
                                searchTextLength >= afterAmountCharacters) {

                                elements2Recovery.delete(exclusionIndex,
                                    elements2Recovery.lastIndex());

                                previousElements = elements2Recovery[
                                    elements2Recovery.lastIndex()];
                            }

                            resolvedList = resolveList(previousElements,
                                options.order);
                            foundElements = resolvedList.elements;


                            if (searchTextLength > afterAmountCharacters ||
                                afterAmountCharacters == 1) {

                                if (foundElements.some()) {
                                    if (charactersNumber < 0) {
                                        fillInToRecovery(foundElements.parent(),
                                                       charactersNumber);
                                    }

                                    resolvedElementsParent = elements.clone();
                                    previousElements = resolvedElementsParent
                                        .append(foundElements);
                                } else {
                                    fillInToRecovery(previousElements.parent(),
                                                   charactersNumber);
                                }

                            }

                            // if (foundElements.some()) {
                            //     if ((charactersNumber < 0 &&
                            //         searchTextLength > afterAmountCharacters) ||
                            //         afterAmountCharacters == 1) {

                            //         fillInToRecovery(foundElements.parent(),
                            //                        charactersNumber);
                            //     }

                            //     resolvedElementsParent = elements.clone();
                            //     previousElements = resolvedElementsParent
                            //         .append(foundElements);
                            // } else {
                            //     if (searchTextLength > afterAmountCharacters ||
                            //         afterAmountCharacters == 1) {

                            //         fillInToRecovery(previousElements.parent(),
                            //                        charactersNumber);
                            //     }
                            // }

                            previousSearchText = searchTextBox.value();
                            callback.call($(this), foundElements, resolvedList
                                          .maps, e);
                        } else {
                            // reset
                            elements2Recovery = [];
                            previousSearchText = "";
                            previousElements = elements;
                            callback.call($(this), $(), e);
                        }

                    };

                    searchTextBox.on("input", eventListenerMethod);
                    searchTextBox.on("focus", eventListenerMethod);
                },

                remoteSearch = function(options) {
                    var
                        word,
                        prevText,
                        nextText,
                        elements,
                        URLParameters,
                        resolvedList,
                        clipboardData,

                        request = function(e) {
                            if (options.remote.URLParameters) {
                                URLParameters = options.remote.URLParameters
                                    .call(searchTextBox);
                            }

                            $.Ajax.new(options.remote.url.call(searchTextBox))
                                .get({
                                    URLParameters: URLParameters,
                                    progress: function(xhr) {
                                        if (options.remote.loading) {
                                            options.remote
                                                .loading(xhr, e);
                                        }
                                    },
                                    complete: function() {
                                        $(e.target).off("keypress");
                                    },
                                    success: function(r) {
                                        elements = $(r);

                                        if (elements.some()) {
                                            charactersNumber = (searchTextBox
                                                .value().length -
                                                afterAmountCharacters) + 1;

                                            debugger
                                            fillInToRecovery(elements,
                                                           charactersNumber);
                                        }

                                        resolvedList = resolveList(elements,
                                                                options.order);
                                        callback.call(searchTextBox,
                                            resolvedList.elements,
                                            resolvedList.maps, e);
                                        if (elements.length) {
                                            inlineSearch(elements, options);
                                        }
                                    }
                                });
                        };

                    searchTextBox.on("keyup", function(e) {
                        word = searchTextBox.value();<commit_msg>autocomplete<commit_after>var
    esPhinx,
    Iterable;


(function($) {
    "use strict";

    $.prototype.extend({

        autocomplete: function(elementsList, options, callback) {
            var
                charactersNumber,
                searchTextBox = this,
                nonCharacterKeysPattern = new RegExp($
                    .nonCharacterKeysPattern()),
                inline = false,
                elements2Recovery = [],
                afterAmountCharacters = options.afterAmountChar,

                fillInToRecovery = function(object, times) {
                    var
                        i = 0;

                    while (i++ < Math.abs(times)) {
                        elements2Recovery.push(object);
                    }
                },

                resolveArguments = function(options) {
                    if (Object.getPrototypeOf(options) !=
                        Object.getPrototypeOf({})) {
                        options = {};
                    }

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

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

                    if (typeof afterAmountCharacters != "number") {
                        afterAmountCharacters = 1;
                    }

                },

                inlineSearch = function(element, options) {
                    var
                        eventListenerMethod,
                        previousSearchText = searchTextBox.value();

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

                    eventListenerMethod = function(e) {
                        var
                            resolvedList,
                            resolvedElementsParent,
                            foundElements,
                            exclusionIndex,
                            finalIndex,
                            previousElements = element,
                            parent = element.clone(),
                            searchTextLength = searchTextBox.value().length,

                            restartList = function() {
                                previousElements = elements;
                            };

                        if (searchTextBox.value()) {
                            charactersNumber = previousSearchText.length -
                                searchTextLength;

                            exclusionIndex = searchTextBox.cursorPosition();
                            finalIndex = exclusionIndex + charactersNumber - 1;

                            // when delete
                            if (searchTextLength < previousSearchText.length &&
                                searchTextLength >= afterAmountCharacters) {

                                // debugger
                                if (exclusionIndex === 0) {
                                    elements2Recovery.delete(exclusionIndex,
                                        finalIndex);
                                } else {
                                    elements2Recovery.delete(exclusionIndex,
                                        elements2Recovery.lastIndex());
                                }

                                previousElements = elements2Recovery[
                                        elements2Recovery.lastIndex()];
                                // debugger
                            }

                            // debugger
                            resolvedList = resolveList(previousElements,
                                options.order);
                            foundElements = resolvedList.elements;

                            if (searchTextLength > afterAmountCharacters ||
                                afterAmountCharacters == 1) {

                                if (foundElements.some()) {
                                    if (charactersNumber < 0) {
                                        fillInToRecovery(parent
                                                         .append(foundElements),
                                                       charactersNumber);
                                    }

                                    previousElements = parent
                                        .append(foundElements);
                                } else {
                                    fillInToRecovery(parent
                                                     .append(previousElements),
                                                   charactersNumber);
                                }

                            }
                            // debugger

                            previousSearchText = searchTextBox.value();
                            callback.call($(this), foundElements, resolvedList
                                          .maps, e);
                        } else {
                            // reset
                            elements2Recovery = [];
                            previousSearchText = "";
                            previousElements = element;
                            callback.call($(this), $(), e);
                        }

                    };

                    searchTextBox.on("input", eventListenerMethod);
                    searchTextBox.on("focus", eventListenerMethod);
                },

                remoteSearch = function(options) {
                    var
                        word,
                        prevText,
                        nextText,
                        element,
                        URLParameters,
                        resolvedList,
                        clipboardData,

                        request = function(e) {
                            if (options.remote.URLParameters) {
                                URLParameters = options.remote.URLParameters
                                    .call(searchTextBox);
                            }

                            $.Ajax.new(options.remote.url.call(searchTextBox))
                                .get({
                                    URLParameters: URLParameters,
                                    progress: function(xhr) {
                                        if (options.remote.loading) {
                                            options.remote
                                                .loading(xhr, e);
                                        }
                                    },
                                    complete: function() {
                                        $(e.target).off("keypress");
                                    },
                                    success: function(r) {
                                        element = $(r);

                                        if (element.some()) {
                                            charactersNumber = (searchTextBox
                                                .value().length -
                                                afterAmountCharacters) + 1;

                                            fillInToRecovery(element,
                                                           charactersNumber);
                                        }

                                        resolvedList = resolveList(element,
                                                                options.order);
                                        callback.call(searchTextBox,
                                            resolvedList.elements,
                                            resolvedList.maps, e);
                                        if (element.length) {
                                            inlineSearch(element, options);
                                        }
                                    }
                                });
                        };

                    searchTextBox.on("keyup", function(e) {
                        word = searchTextBox.value();
{'fraction_non_alphanumeric': 0.0641048240202127, 'fraction_numerical': 0.0017627357659086903, 'mean_word_length': 0.6564476885644769, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 146, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5623059', 'n_tokens_mistral': 2920, 'n_tokens_neox': 2660, 'n_words': 457}