Skip to content

Commit 33d9a44

Browse files
author
Carlos García
committed
fix undefined array length and sort context vars
1 parent 08fd85d commit 33d9a44

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/context/context-variable-view.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ContextVariableView extends View
4242
when 'null'
4343
@variableView.append(@renderScalar({label: label, value: "null"}))
4444
when 'array'
45-
summary ="array["+@variable.length+"]"
45+
summary ="array["+(@variable.length || @variable.value.length)+"]"
4646
@variableView.append(new ContextVariableListView({name: label, summary: summary, variables: @variable.value, autoopen: openChildren,parent:@parent,openpaths:@openpaths}))
4747
when 'object'
4848
summary ="object"

lib/context/context-view.coffee

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,19 @@ class ContextView extends View
2020
openChildren = true
2121
break
2222

23+
cbDeepSort = (a,b) ->
24+
if (a.fullname < b.fullname)
25+
return -1
26+
if (a.fullname > b.fullname)
27+
return 1
28+
return 0
29+
30+
fnWalkVar = (contextVar) ->
31+
if Array.isArray(contextVar)
32+
for item in contextVar
33+
if Array.isArray(item.value)
34+
fnWalkVar(item.value)
35+
contextVar.sort(cbDeepSort)
36+
37+
fnWalkVar(@context.context.variables)
2338
@contextListView.append(new ContextVariableListView( {name: @context.name, summary: null, variables: @context.context.variables, autoopen: openChildren, openpaths:@autoopen, parent:null}))

0 commit comments

Comments
 (0)