@@ -19,18 +19,10 @@ const prefixContainerProp = props.prefixContainer
19
19
const startEdgeProp = NodeProp . closedBy
20
20
const endEdgeProp = NodeProp . openedBy
21
21
const sameEdgeProp = props . sameEdge
22
-
23
22
const up = ( node ) => node . parent ;
24
-
25
23
const isTopType = ( nodeType ) => nodeType . isTop
26
-
27
- function isTop ( node ) {
28
- return isTopType ( node . type ) ;
29
- }
30
-
31
- function mainSelection ( state ) {
32
- return state . selection . asSingle ( ) . ranges [ 0 ]
33
- }
24
+ const isTop = ( node ) => isTopType ( node . type )
25
+ const mainSelection = ( state ) => state . selection . asSingle ( ) . ranges [ 0 ]
34
26
35
27
function tree ( state , pos , dir ) {
36
28
switch ( arguments [ "length" ] ) {
@@ -43,24 +35,19 @@ function tree(state, pos, dir) {
43
35
}
44
36
}
45
37
46
- function nearestTouching ( state , pos ) {
47
- const L = tree ( state , pos , - 1 )
48
- const R = tree ( state , pos , 1 )
49
- const mid = tree ( state , pos )
50
- return L
51
- }
38
+ const nearestTouching = ( state , pos ) => tree ( state , pos , - 1 )
52
39
53
- function isTerminalType ( nodeType ) {
40
+ const isTerminalType = ( nodeType ) => {
54
41
if ( isTopType ( nodeType || nodeType . prefixCollProp . prop ( ) ||
55
- nodeType . collProp . prop ( ) || nodeType . name == "Meta" ||
56
- nodeType . name == "TaggedLiteral" || nodeType . name == "ConstructorCall" ) ) {
42
+ nodeType . collProp . prop ( ) || nodeType . name == "Meta" ||
43
+ nodeType . name == "TaggedLiteral" || nodeType . name == "ConstructorCall" ) ) {
57
44
return false
58
45
} else {
59
46
return true
60
47
}
61
48
}
62
49
63
- function children ( parent , from , dir ) {
50
+ const children = ( parent , from , dir ) => {
64
51
let child = parent . childBefore ( from )
65
52
return children ( parent , child . from ) . unshift ( child )
66
53
}
@@ -70,12 +57,10 @@ function parents(node, p) {
70
57
return parents ( up ( node ) , p . concat ( node ) ) ;
71
58
}
72
59
73
- function rangeStr ( state , selection ) {
74
- return state . doc . slice ( selection . from , selection . to ) . toString ( )
75
- }
60
+ const rangeStr = ( state , selection ) => state . doc . slice ( selection . from , selection . to ) . toString ( )
76
61
77
62
// Return node or its highest parent that ends at the cursor position
78
- function uppermostEdge ( pos , node ) {
63
+ function uppermostEdge ( pos , node ) {
79
64
const p = parents ( node , [ ] ) . filter ( n => pos == n . to && pos == node . to ) ;
80
65
return p [ p . length - 1 ] || node
81
66
}
@@ -103,13 +88,8 @@ function topLevelNode(state) {
103
88
}
104
89
}
105
90
106
- function cursorNodeString ( state ) {
107
- return rangeStr ( state , nodeAtCursor ( state ) )
108
- }
109
-
110
- function topLevelString ( state ) {
111
- return rangeStr ( state , topLevelNode ( state ) )
112
- }
91
+ const cursorNodeString = ( state ) => rangeStr ( state , nodeAtCursor ( state ) )
92
+ const topLevelString = ( state ) => rangeStr ( state , topLevelNode ( state ) )
113
93
114
94
let evalResult = ""
115
95
let codeBeforeEval = ""
@@ -172,7 +152,6 @@ function evalCell(view) {
172
152
evalResult = tryEval ( view . state . doc . text . join ( " " ) )
173
153
const codeWithResult = doc + "\n" + " => " + evalResult
174
154
updateEditor ( view , codeWithResult , posBeforeEval )
175
- //console.log("evalCell>", evalString(ctx, view.state.doc.text.join(" ")))
176
155
return true
177
156
}
178
157
0 commit comments