 
   extractParams: (type) ->
     return [] unless type
-    start = 0
+    start = type.indexOf('(') + 1
     params = []
     inside = 0
-    for i in [0..type.length - 1]
+    for i in [start..type.length - 1]
+      if type[i] is ':' and inside is -1
+        params.push type.substring(start, i - 2)
+        break
       if i is type.length - 1
-        params.push type.substring(start, i + 1)
+        params.push type.substring(start, i)
         break
       if type[i] is ',' and inside is 0
         params.push type.substring(start, i)

      else
        obj.leftLabel = obj.type.replace(/fn\(.{0,}\)/, '').replace(' : ', '')

    if !obj.type.endsWith(')') or obj.type.match(/\(\)$/)
      obj.rightLabel = obj.type.replace(/( : .+)/, '')
    else
      obj.rightLabel = obj.type

    if obj.rightLabel.startsWith('fn')
      if atom.config.get('atom-ternjs.useSnippets')
        params = @extractParams(obj.rightLabel.replace(/^fn\(/, '').replace(/\)$/, ''))
        obj._snippet = @buildSnippet(params, obj.name)
      else
        obj._snippet = "#{obj.name}"

  prepareType: (data) ->
    return unless data.type
    type = data.type.replace(/->/g, ':').replace('<top>', 'window')

  formatTypeCompletion: (obj) ->
    if obj.isKeyword
