 
     buildSuggestions: ->
         suggestions = []
-        selection = @_editor.getLastSelection()
-        prefix = @prefixOfSelection selection
+        prefix = @getPrefix()
         for item, index in suggestionsArr
             if index == maxItems
                 break

        @documentationView.show()

    cancelAutocompletion: ->
        @documentationView.hide()
        return unless @autocompleteManager
        @autocompleteManager.cancel()

        else
          @cancelAutocompletion()

    getPrefix: ->
        return @prefixOfSelection(@_editor.getLastSelection())

    preBuildSuggestions: ->
        return unless @autocompleteManager
        suggestionsArr = []
        @checkCompletion().then (data) =>
            return unless data?.length
            prefix = @getPrefix()
            if data.length is 1 and prefix is data[0].name
                @cancelAutocompletion()
                return
            for obj, index in data
                if index == maxItems
                    break
