 
     # keys must be String or Array
     # Not support Object for keys to avoid ambiguity.
-    element ?= @editorElement
+    target = @editorElement
     mocked = null
     keys = [keys] unless _.isArray(keys)
 
     for k in keys
       if _.isString(k)
-        _keystroke(k, {element})
+        _keystroke(k, {target})
+        continue
       else
         switch
           when k.platform?
-            mockPlatform(element, k.platform)
+            mockPlatform(target, k.platform)
             mocked = true
           when k.char?
             chars =

            {editor, editorElement} = @vimState.searchInput
            editor.insertText(k.search)
            atom.commands.dispatch(editorElement, 'core:confirm')
          when k.ctrl? then _keystroke(k.ctrl, {ctrl: true, element})
          when k.cmd? then _keystroke(k.cmd, {meta: true, element})
          when k.raw? then _keystroke(k.raw, {raw: true, element})
    if mocked
      unmockPlatform(element)

module.exports = {getVimState, getView, dispatch, TextData}

    when 2 then [file, callback] = args

  waitsForPromise ->
    atom.packages.activatePackage('vim-mode-plus')

  waitsForPromise ->
    file = atom.project.resolvePath(file) if file
    atom.workspace.open(file).then (e) -> editor = e

  runs ->
    main = atom.packages.getActivePackage('vim-mode-plus').mainModule
    vimState = main.getEditorState(editor)
    callback(vimState, new VimEditor(vimState))

class TextData
