     super
     false
 
+  getReplacementRange: =>
+    {replacementOffset, replacementLength} = @autocompleteInfo.params
+    {buffer} = @editor
+    startPos      = buffer.positionForCharacterIndex(replacementOffset)
+    endPos        = buffer.positionForCharacterIndex(replacementOffset + replacementLength)
+
+    new Range(startPos, endPos)
+
   insertMatch: (item) =>
-    {replacementOffset} = @autocompleteInfo.params
-    {buffer} = @editor
-    {selectionOffset} = item
-
-    pos = @editor.getCursorBufferPosition()
-
-    cursorOffset  = buffer.characterIndexForPosition(pos)
-    startPos      = buffer.positionForCharacterIndex(replacementOffset)
-    # endPos        = buffer.positionForCharacterIndex(replacementOffset + selectionOffset)
-    endPos        = @editor.getCursorBufferPosition()
-    range         = new Range(startPos, endPos)
+    range = @getReplacementRange()
 
     @editor.setSelectedBufferRange(range)
     @editor.insertText(item.completion)
-    
-    console.log 'replacementOffset', replacementOffset, 'for item', item
-    console.log 'Range is', range

      path = @editor.getPath()
      pos = @editor.getCursorBufferPosition()
      offset = @editor.buffer.characterIndexForPosition(pos)

      console.log 'autocompleting at', offset

      @showFetchingResults()
      @api.updateFile @editor.getPath(), @editor.getText()

  selectItemView: (item) =>
    super

    # if match = @getSelectedItem()
      # @insertMatch(match)

  selectNextItemView: ->
    super
