Skip to content
Merged
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
19 changes: 19 additions & 0 deletions lib/context/context-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,23 @@ class ContextView extends View
openChildren = true
break

cbDeepNaturalSort = (a,b) ->
aIsNumeric = /^\d+$/.test(a.name)
bIsNumeric = /^\d+$/.test(b.name)
# cannot exist two equal keys, so skip case of returning 0
if aIsNumeric && bIsNumeric # order numbers
return if (parseInt(a.name, 10) < parseInt(b.name, 10)) then -1 else 1
else if !aIsNumeric && !bIsNumeric # order strings
return if (a.name < b.name) then -1 else 1
else # string first (same behavior that PHP's `ksort`)
return if aIsNumeric then 1 else -1

fnWalkVar = (contextVar) ->
if Array.isArray(contextVar)
for item in contextVar
if Array.isArray(item.value)
fnWalkVar(item.value)
contextVar.sort(cbDeepNaturalSort)
if (atom.config.get('php-debug.SortArray'))
fnWalkVar(@context.context.variables)
@contextListView.append(new ContextVariableListView( {name: @context.name, summary: null, variables: @context.context.variables, autoopen: openChildren, openpaths:@autoopen, parent:null}))
6 changes: 5 additions & 1 deletion lib/php-debug.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ module.exports = PhpDebug =
UnknownError:
type: 'boolean'
default: true
SortArray:
title: "Sort Array/Object Elements Alphabetically"
type: 'boolean'
default: true

activate: (state) ->
if state
Expand Down Expand Up @@ -318,7 +322,7 @@ module.exports = PhpDebug =
atom.focus()
@GlobalContext.getCurrentDebugContext().syncCurrentContext(point.getStackDepth())


addBreakpointMarker: (line, editor) ->
gutter = editor.gutterWithName("php-debug-gutter")
range = [[line-1, 0], [line-1, 0]]
Expand Down