           @deactivate()
           symbol = result['>>']
           if symbol.length > 0
-            lastInput = content.substr -1
+            lastInput = @input.substr -1
             refill = symbol[0] + lastInput
             # console.log "symbol #{symbol} lastInput #{lastInput} refill #{refill}"
             @agda.editor.getBuffer().setTextInRange range, refill

        # console.log "old range: #{@marker.bufferMarker.range.start} #{@marker.bufferMarker.range.end}"
        # console.log "new range: #{range.start} #{range.end}"

        # input content
        content = @agda.editor.getBuffer().getTextInRange(range).substr(1)

        # see if the input is in the keymap
        {valid, result} = @validate content

        if valid
          if Object.keys(result).length is 1
            # no further possible key combinations

      @decorator.hide()
      @marker.destroy()
      @activated = false
      @input = ''

  # if the input is in the keymap
  validate: ->
    valid = true
    cursor = InputMethod.trie
    for i in [0 .. @input.length - 1]
      char = @input.charAt i
      next = cursor[char]
      if next
        cursor = next
