<commit_before>const {Disposable, CompositeDisposable} = require('atom')
const Base = require('./base')

// opration life in operationStack
// 1. run
//    instantiated by new.
//    complement implicit Operator.VisualModeSelect operator if necessary.
//    push operation to stack.
// 2. process
//    reduce stack by, popping top of stack then set it as target of new top.
//    check if remaining top of stack is executable by calling isReady()
//    if executable, then pop stack then execute(poppedOperation)
//    if not executable, enter "operator-pending-mode"
module.exports = class OperationStack {
  get mode () { return this.vimState.mode } // prettier-ignore
  get submode () { return this.vimState.submode } // prettier-ignore

  constructor (vimState) {
    this.vimState = vimState
    this.editor = vimState.editor
    this.editorElement = vimState.editorElement
    this.operationToRunNext = null

    this.vimState.onDidDestroy(() => this.destroy())
    this.reset()
  }

  // Return handler
  subscribe (handler) {
    this.operationSubscriptions.add(handler)
    return handler // DONT REMOVE
  }

  getLastCommandName () {
    return this.lastCommandName
  }

  reset () {
    this.resetCount()
    this.stack = []
    this.running = false

    // this has to be BEFORE this.operationSubscriptions.dispose()
    this.vimState.emitDidResetOperationStack()

    if (this.operationSubscriptions) this.operationSubscriptions.dispose()
    this.operationSubscriptions = new CompositeDisposable()

    if (this.operationToRunNext) {
      const args = this.operationToRunNext
      this.operationToRunNext = null
      this.run(...args)
    }
  }

  destroy () {
    if (this.operationSubscriptions) this.operationSubscriptions.dispose()
    this.stack = this.operationSubscriptions = null
  }

  peekTop () {
    return this.stack[this.stack.length - 1]
  }

  isEmpty () {
    return this.stack.length === 0
  }

  // Main<commit_msg>runNext runs operation on nextTick<commit_after>const {Disposable, CompositeDisposable} = require('atom')
const Base = require('./base')

// opration life in operationStack
// 1. run
//    instantiated by new.
//    complement implicit Operator.VisualModeSelect operator if necessary.
//    push operation to stack.
// 2. process
//    reduce stack by, popping top of stack then set it as target of new top.
//    check if remaining top of stack is executable by calling isReady()
//    if executable, then pop stack then execute(poppedOperation)
//    if not executable, enter "operator-pending-mode"
module.exports = class OperationStack {
  get mode () { return this.vimState.mode } // prettier-ignore
  get submode () { return this.vimState.submode } // prettier-ignore

  constructor (vimState) {
    this.vimState = vimState
    this.editor = vimState.editor
    this.editorElement = vimState.editorElement
    this.operationToRunNext = null

    this.vimState.onDidDestroy(() => this.destroy())
    this.reset()
  }

  // Return handler
  subscribe (handler) {
    this.operationSubscriptions.add(handler)
    return handler // DONT REMOVE
  }

  getLastCommandName () {
    return this.lastCommandName
  }

  reset () {
    this.resetCount()
    this.stack = []
    this.running = false

    // this has to be BEFORE this.operationSubscriptions.dispose()
    this.vimState.emitDidResetOperationStack()

    if (this.operationSubscriptions) this.operationSubscriptions.dispose()
    this.operationSubscriptions = new CompositeDisposable()

    if (this.operationToRunNext) {
      const args = this.operationToRunNext
      this.operationToRunNext = null
      process.nextTick(() => {
        this.run(...args)
      })
    }
  }

  destroy () {
    if (this.operationSubscriptions) this.operationSubscriptions.dispose()
    this.stack = this.operationSubscriptions = null
  }

  peekTop () {
    return this.stack[this.stack.length - 1]
  }

  isEmpty () {
    return this.stack.length === 0
  }

  // Main
{'fraction_non_alphanumeric': 0.10662969498361483, 'fraction_numerical': 0.00201663725737333, 'mean_word_length': 3.0739219712525667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '199755', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1132, 'n_words': 296}