<commit_before>import Mixin from '@ember/object/mixin';
import { computed, get, set } from '@ember/object';
import scrollIntoView from '../../utils/select-box/scroll-into-view';
import escapeRegExp from '../../utils/escape-regexp';
const { fromCharCode } = String;
export const COLLECT_CHARS_MS = 500;

export default Mixin.create({
  init() {
    this._super(...arguments);
    this._deactivateOptions();
  },

  _activateOptionAtIndex(index, scroll) {
    const under = index < 0;
    const over = index > this.options.length - 1;

    if (!(under || over)) {
      set(this, 'activeOptionIndex', index);
      this._activatedOption();
    }

    if (scroll) {
      this._scrollActiveOptionIntoView();
    }
  },

  _activateOptionForChar(char, scroll) {
    const lastChars = this._activateOptionChars || '';
    const lastMs = this._activateOptionCharsMs;
    const lastIndex = this._activateOptionCharsIndex || 0;
    const lastChar = lastChars.substring(lastChars.length - 1);
    const ms = Date.now();
    const duration = lastMs ? ms - lastMs : 0;
    const expired = duration > COLLECT_CHARS_MS;

    let chars;
    let matchIndex;

    if (expired) {
      chars = char;
      matchIndex = 0;
    } else if (char === lastChar) {
      chars = char;
      matchIndex = lastIndex + 1;
    } else {
      chars = `${lastChars}${char}`;
      matchIndex = 0;
    }

    const options = this._findOptionsMatchingChars(chars);
    const option = options[matchIndex];

    if (option) {
      this.send('activateOptionAtIndex', get(option, 'index'), scroll);
    }

    set(this, '_activateOptionChars', chars);
    set(this, '_activateOptionCharsMs', ms);
    set(this, '_activateOptionCharsIndex', matchIndex);
  },

  _findOptionsMatchingChars(chars) {
    chars = escapeRegExp(chars);

    const pattern = new RegExp(`^${chars}`, 'i');<commit_msg>update terminology<commit_after>import Mixin from '@ember/object/mixin';
import { computed, get, set } from '@ember/object';
import scrollIntoView from '../../utils/select-box/scroll-into-view';
import escapeRegExp from '../../utils/escape-regexp';
const { fromCharCode } = String;
export const COLLECT_CHARS_MS = 500;

export default Mixin.create({
  init() {
    this._super(...arguments);
    this._deactivateOptions();
  },

  _activateOptionAtIndex(index, scroll) {
    const under = index < 0;
    const over = index > this.options.length - 1;

    if (!(under || over)) {
      set(this, 'activeOptionIndex', index);
      this._activatedOption();
    }

    if (scroll) {
      this._scrollActiveOptionIntoView();
    }
  },

  _activateOptionForChar(char, scroll) {
    const lastChars = this._activateOptionChars || '';
    const lastMs = this._activateOptionCharsMs;
    const lastIndex = this._activateOptionCharsIndex || 0;
    const lastChar = lastChars.substring(lastChars.length - 1);
    const ms = Date.now();
    const duration = lastMs ? ms - lastMs : 0;
    const reset = duration > COLLECT_CHARS_MS;

    let chars;
    let matchIndex;

    if (reset) {
      chars = char;
      matchIndex = 0;
    } else if (char === lastChar) {
      chars = char;
      matchIndex = lastIndex + 1;
    } else {
      chars = `${lastChars}${char}`;
      matchIndex = 0;
    }

    const options = this._findOptionsMatchingChars(chars);
    const option = options[matchIndex];

    if (option) {
      this.send('activateOptionAtIndex', get(option, 'index'), scroll);
    }

    set(this, '_activateOptionChars', chars);
    set(this, '_activateOptionCharsMs', ms);
    set(this, '_activateOptionCharsIndex', matchIndex);
  },

  _findOptionsMatchingChars(chars) {
    chars = escapeRegExp(chars);

    const pattern = new RegExp(`^${chars}`, 'i');
{'fraction_non_alphanumeric': 0.13735523835173713, 'fraction_numerical': 0.005925127928898465, 'mean_word_length': 3.2108843537414966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7549520', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1112, 'n_words': 268}