Skip to content
This repository was archived by the owner on Jan 11, 2026. It is now read-only.
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions lib/autocompletion/class-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ class ClassProvider extends AbstractProvider
prefix: prefix,
replacementPrefix: prefix

suggestions = suggestions.sort (a, b) ->
if a.text.includes prefix
return -1

if b.text.includes prefix
return 1

return 0

return suggestions

###*
Expand Down
9 changes: 9 additions & 0 deletions lib/autocompletion/constant-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ class ConstantProvider extends AbstractProvider
type: 'constant',
description: 'Built-in PHP constant.'

suggestions = suggestions.sort (a, b) ->
if a.text.includes prefix
return -1

if b.text.includes prefix
return 1

return 0

return suggestions
8 changes: 8 additions & 0 deletions lib/autocompletion/function-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,13 @@ class FunctionProvider extends AbstractProvider

suggestions.push suggestion

suggestions = suggestions.sort (a, b) ->
if a.text.includes prefix
return -1

if b.text.includes prefix
return 1

return 0

return suggestions
9 changes: 9 additions & 0 deletions lib/autocompletion/member-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,13 @@ class MemberProvider extends AbstractProvider
description : if ele.args.descriptions.short? then ele.args.descriptions.short else ''
className : if ele.args.deprecated then 'php-atom-autocomplete-strike' else ''

suggestions = suggestions.sort (a, b) ->
if a.text.includes prefix
return -1

if b.text.includes prefix
return 1

return 0

return suggestions
9 changes: 9 additions & 0 deletions lib/autocompletion/variable-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ class VariableProvider extends AbstractProvider
type: 'variable',
replacementPrefix: prefix

suggestions = suggestions.sort (a, b) ->
if a.text.includes prefix
return -1

if b.text.includes prefix
return 1

return 0

return suggestions
17 changes: 10 additions & 7 deletions lib/services/php-file-parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module.exports =
if isInFunction
matches.push "$this"

matches = matches.filter (match, index) -> matches.indexOf(match) == index

return matches

###*
Expand Down Expand Up @@ -334,6 +336,7 @@ module.exports =
character = 0
lineLength = line.length
lastChain = null
inFunction = false

# Scan the entire line, fetching the scope for each character position as one line can contain both a scope start
# and end such as "} elseif (true) {". Here the scope descriptor will differ for different character positions on
Expand All @@ -346,20 +349,20 @@ module.exports =
# scanning line.length as sometimes line.length - 1 does not return a scope descriptor at all.
if not (character == line.length and chain == lastChain)
# }
if chain.indexOf("scope.end") != -1
if chain.indexOf("punctuation.definition.end.bracket.curly.php") != -1
closedBlocks++
# {
else if chain.indexOf("scope.begin") != -1
else if chain.indexOf("punctuation.definition.begin.bracket.curly.php") != -1
openedBlocks++

if chain.indexOf(".entity.name.function.php") != -1
inFunction = true

lastChain = chain
character++

# Get chain of all scopes
chain = editor.scopeDescriptorForBufferPosition([row, line.length]).getScopeChain()

# function
if chain.indexOf("function") != -1
if inFunction
# If more openedblocks than closedblocks, we are in a function. Otherwise, could be a closure, continue looking.
if openedBlocks > closedBlocks
result = true
Expand Down Expand Up @@ -800,7 +803,7 @@ module.exports =
foundEnd = false
startBufferPosition = []
endBufferPosition = []
forwardRegex = /-|(?:\()[\w\[\$\(\\]|\s|\)|;|'|,|"|\|/
forwardRegex = /-|(?:\()[\w\[\$\(\\]|\s|\)|;|'|,|"|:|\|/
backwardRegex = /\(|\s|\)|;|'|,|"|\|/
index = -1
previousText = ''
Expand Down