       @history.getPrevious @prefix.text
     else
       @history.getNext @prefix.text
+    @prefix.listener?.dispose()
     editor.setText next.input
+    @prefix.listener = editor.onDidChange => @resetPrefix()
     @setMode @getInput(), next.mode
     editor.setCursorBufferPosition @prefix.pos or [0, 0]
 

      'core:move-down': (e) ->
        getConsole(this).keyDown e, this
      'core:move-left': (e) ->
        delete getConsole(this).prefix
      'core:move-right': (e) ->
        delete getConsole(this).prefix
      'core:backspace': (e) ->
        getConsole(this).cancelMode this


      input: editor.getText()
      mode: mode?.name

  resetPrefix: ->
    @prefix?.listener?.dispose()
    delete @prefix

  moveHistory: (up) ->
    {editor} = @getInput()
    if (editor.getText() or not @prefix?) and @prefix?.pos?[0] isnt Infinity
      @resetPrefix()
      pos = editor.getCursorBufferPosition()
      text = editor.getTextInRange [[0,0], pos]
      pos = [Infinity, Infinity] if text is ''
