<commit_before>var Handsontable = require('./handsontablep/dist/handsontable.full.js');

class TableSearcher {
    constructor(hot, inputSearch) {
        this.hot = hot;
        this.inputSearch = inputSearch;
        
        //this.queryResult = n
        this.currentResult = 0;
        this.lastQuery = null;
        this.lastSelectedResult = null;
        var that = this;
        
        Handsontable.Dom.addEvent(inputSearch, 'keyup', function(event) {
            if (event.keyCode === 27){
                inputSearch.blur();
                hot.listen();
                event.preventDefault();
                event.stopPropagation();
                return;
            }

            if(that.lastQuery == this.value)
                return;
                
            that.lastQuery = this.value;
            that.currentResult = 0;
            that.queryResult = hot.search.query(this.value);
            hot.render();
            that.lastSelectedResult = null;
        });

    }
    
    search(){
        if(this.queryResult && this.queryResult.length){
            var firstResult = this.queryResult[this.currentResult];
            this.hot.selection.setRangeStart(new WalkontableCellCoords(firstResult.row,firstResult.col));
            this.hot.selection.setRangeEnd(new WalkontableCellCoords(firstResult.row,firstResult.col));
            this.lastSelectedResult = firstResult;
            this.inputSearch.focus();
            this.currentResult += 1;
            if(this.currentResult == this.queryResult.length)
                this.currentResult = 0;
        }
        return false;
    }
    
    setIsSearching(isSearching){<commit_msg>timeout search<commit_after>var Handsontable = require('./handsontablep/dist/handsontable.full.js');

class TableSearcher {
    constructor(hot, inputSearch) {
        this.hot = hot;
        this.inputSearch = inputSearch;
        
        //this.queryResult = n
        this.currentResult = 0;
        this.lastQuery = null;
        this.lastSelectedResult = null;
        var that = this;
        
        var searchTimeout = -1;
        
        Handsontable.Dom.addEvent(inputSearch, 'keyup', function(event) {
            if (event.keyCode === 27){
                inputSearch.blur();
                hot.listen();
                event.preventDefault();
                event.stopPropagation();
                return;
            }

            if(that.lastQuery == this.value)
                return;
                
            if(searchTimeout != -1)
                clearTimeout(searchTimeout);
                
            searchTimeout = setTimeout(function(){
                that.lastQuery = inputSearch.value;
                that.currentResult = 0;
                that.queryResult = hot.search.query(inputSearch.value);
                hot.render();
                that.lastSelectedResult = null;
                searchTimeout = -1;
            }, 200);
        });

    }
    
    search(){
        if(this.queryResult && this.queryResult.length){
            var firstResult = this.queryResult[this.currentResult];
            this.hot.selection.setRangeStart(new WalkontableCellCoords(firstResult.row,firstResult.col));
            this.hot.selection.setRangeEnd(new WalkontableCellCoords(firstResult.row,firstResult.col));
            this.lastSelectedResult = firstResult;
            this.inputSearch.focus();
            this.currentResult += 1;
            if(this.currentResult == this.queryResult.length)
                this.currentResult = 0;
        }
        return false;
    }
    
    setIsSearching(isSearching){
{'fraction_non_alphanumeric': 0.10359116022099447, 'fraction_numerical': 0.004972375690607734, 'mean_word_length': 1.6762749445676275, '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': '4361488', 'n_tokens_mistral': 977, 'n_tokens_neox': 935, 'n_words': 145}