 # Refactoring status: 100%
 _ = require 'underscore-plus'
+
 {CurrentSelection} = require './motion'
 {Select} = require './operator'
 {debug} = require './utils'
 settings = require './settings'
 
-module.exports =
 class OperationStack
   constructor: (@vimState) ->
     @stack = []
+    {@editor} = @vimState
 
   push: (op) ->
     if @isEmpty() and settings.get('debug')

        else
          throw error

    unless @peekTop().isComplete()
      if @vimState.isMode('normal') and @peekTop().isOperator?()
        @inspect()
        debug '-> @process(): activating: operator-pending-mode'


    # Use implicit Select operator as operator.
    if @vimState.isMode('visual') and _.isFunction(op.select)
      @pushToStack new Select(@vimState), message: "push IMPLICIT Operator.Select"

    @pushToStack op, message: "push <#{op.getKind()}>"

    # Operate on implicit CurrentSelection TextObject.
    if @vimState.isMode('visual') and op.isOperator()
      @pushToStack new CurrentSelection(@vimState),
        message: "push IMPLICIT Motion.CurrentSelection"

    try
      @processing = true
      @process()
    finally
      @processing = false

