Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ exec = require 'child_process'
fs = require 'fs'
path = require 'path'

String.prototype.fuzzy = (search) ->

return true unless search

str = @toLowerCase()
search = search.toLowerCase()
i = 0
n = 0
l = undefined
while l = search[i++]
if ((n = str.indexOf(l, n)) == -1)
return false

true

module.exports =
executablePath: 'php'

Expand Down Expand Up @@ -167,12 +182,15 @@ module.exports =
for userFunc in @userSuggestions.user_functions when userFunc.text.toLowerCase().indexOf(lowerCasePrefix) is 0
completions.push(@buildCompletion(userFunc))

for func in @funtions.functions when func.text.toLowerCase().indexOf(lowerCasePrefix) is 0
for func in @funtions.functions when func.text.toLowerCase().fuzzy(lowerCasePrefix) is true
completions.push(@buildCompletion(func))

for methods in @methods.methods when methods.text.toLowerCase().indexOf(lowerCasePrefix) is 0
completions.push(@buildCompletion(methods))

completions.sort (a, b) ->
a.text.length - b.text.length

completions

getVarsCompletions: ({editor, prefix}) ->
Expand Down