         type: 'keyword'
 
   isIn: (scope) ->
-    @scopes.some (s) -> s==scope
+    scope.every (s1) =>
+      @scopes.some (s) ->
+        s==s1
 
   genSpaceSearch: =>
-    r = new Range {column:0, row:@options.bufferPosition.row},
-      @options.bufferPosition
     new Promise (resolve) =>
-      @editor.backwardsScanInBufferRange /[^\s]+/, r, ({matchText,stop})->
-        resolve(matchText)
-        stop()
+      @editor.backwardsScanInBufferRange /[\w.']+/,
+        @lineRange, ({matchText,stop})->
+          resolve(matchText)
+          stop()
 
   buildSymbolSuggestion: (s, prefix) ->
-    text: s.name
+    text: s.qname ? s.name
     rightLabel: s.module.name
     type: s.symbolType
     replacementPrefix: prefix

    @prefix = @options.prefix
    @scopes = @options.scopeDescriptor.scopes
    @symbols = @controller.symbols

  genTypeSearch: =>
    unless @controller.backend

      .map (s) =>
        @buildSymbolSuggestion(s, @prefix)

  getModuleMatches: (prefix) =>
    mod=""
    @editor.backwardsScanInBufferRange /^import ([\w.]+)/, @lineRange,
      ({match,stop}) ->
        mod=match[1]
        stop()
    return [] unless mod?
    @controller.backend.listImportedSymbols @editor.getBuffer(), [{name: mod}]
      .then (symbols) =>
        symbols
          .filter (s) ->
            s.name.startsWith(prefix)
          .map (s) =>
            @buildSymbolSuggestion(s,prefix)

  getSuggestions: =>
    if @isIn(@typeScope)
      @genSpaceSearch()
        .then (prefix) =>
          @getMatches(prefix, true)
    else if @isIn(@moduleScope)
      @genSpaceSearch()
        .then(@getModule)
    else if @isIn(@exportsScope)
      @genSpaceSearch()
        .then(@getModuleMatches)
    else if @isIn(@preprocessorScope)
      @genSpaceSearch()
        .then(@getPreprocessor)
