@@ -6,21 +6,21 @@ import { getLine } from "./blocks.js"
6
6
7
7
import { Point } from "atom"
8
8
9
- export function getRange ( ed ) {
9
+ export function getRange ( editor ) {
10
10
// Cell range is:
11
11
// Start of line below top delimiter (and/or start of top row of file) to
12
12
// End of line before end delimiter
13
- const buffer = ed . getBuffer ( )
13
+ const buffer = editor . getBuffer ( )
14
14
const start = buffer . getFirstPosition ( )
15
15
const end = buffer . getEndPosition ( )
16
16
const regexString = "^(" + atom . config . get ( "julia-client.uiOptions.cellDelimiter" ) . join ( "|" ) + ")"
17
17
const regex = new RegExp ( regexString )
18
- const cursor = ed . getCursorBufferPosition ( )
18
+ const cursor = editor . getCursorBufferPosition ( )
19
19
cursor . column = Infinity // cursor on delimiter line means eval cell below
20
20
21
21
let foundDelim = false
22
- for ( let i = cursor . row + 1 ; i <= ed . getLastBufferRow ( ) ; i ++ ) {
23
- const { line, scope } = getLine ( ed , i )
22
+ for ( let i = cursor . row + 1 ; i <= editor . getLastBufferRow ( ) ; i ++ ) {
23
+ const { line, scope } = getLine ( editor , i )
24
24
foundDelim = regex . test ( line ) && scope . join ( "." ) . indexOf ( "comment.line" ) > - 1
25
25
end . row = i
26
26
if ( foundDelim ) break
@@ -35,7 +35,7 @@ export function getRange(ed) {
35
35
foundDelim = false
36
36
if ( cursor . row > 0 ) {
37
37
for ( let i = end . row ; i >= 0 ; i -- ) {
38
- const { line, scope } = getLine ( ed , i )
38
+ const { line, scope } = getLine ( editor , i )
39
39
foundDelim = regex . test ( line ) && scope . join ( "." ) . indexOf ( "comment.line" ) > - 1
40
40
start . row = i
41
41
if ( foundDelim ) {
@@ -48,66 +48,66 @@ export function getRange(ed) {
48
48
return [ start , end ]
49
49
}
50
50
51
- export function get ( ed ) {
52
- if ( ed . getGrammar ( ) . scopeName . indexOf ( "source.julia" ) > - 1 ) {
53
- return jlGet ( ed )
51
+ export function get ( editor ) {
52
+ if ( editor . getGrammar ( ) . scopeName . indexOf ( "source.julia" ) > - 1 ) {
53
+ return jlGet ( editor )
54
54
} else {
55
- return weaveGet ( ed )
55
+ return weaveGet ( editor )
56
56
}
57
57
}
58
58
59
- function jlGet ( ed ) {
60
- const range = getRange ( ed )
61
- let text = ed . getTextInBufferRange ( range )
59
+ function jlGet ( editor ) {
60
+ const range = getRange ( editor )
61
+ let text = editor . getTextInBufferRange ( range )
62
62
if ( text . trim ( ) === "" ) text = " "
63
63
const res = {
64
64
range : [
65
65
[ range [ 0 ] . row , range [ 0 ] . column ] ,
66
66
[ range [ 1 ] . row , range [ 1 ] . column ] ,
67
67
] ,
68
- selection : ed . getSelections ( ) [ 0 ] ,
68
+ selection : editor . getSelections ( ) [ 0 ] ,
69
69
line : range [ 0 ] . row ,
70
70
text : text ,
71
71
}
72
72
return [ res ]
73
73
}
74
74
75
- export function moveNext ( ed ) {
76
- if ( ed == null ) {
77
- ed = atom . workspace . getActiveTextEditor ( )
75
+ export function moveNext ( editor ) {
76
+ if ( editor == null ) {
77
+ editor = atom . workspace . getActiveTextEditor ( )
78
78
}
79
- if ( ed . getGrammar ( ) . scopeName . indexOf ( "source.julia" ) > - 1 ) {
80
- return jlMoveNext ( ed )
79
+ if ( editor . getGrammar ( ) . scopeName . indexOf ( "source.julia" ) > - 1 ) {
80
+ return jlMoveNext ( editor )
81
81
} else {
82
- return weaveMoveNext ( ed )
82
+ return weaveMoveNext ( editor )
83
83
}
84
84
}
85
85
86
- function jlMoveNext ( ed ) {
87
- const range = getRange ( ed )
88
- const sel = ed . getSelections ( ) [ 0 ]
86
+ function jlMoveNext ( editor ) {
87
+ const range = getRange ( editor )
88
+ const sel = editor . getSelections ( ) [ 0 ]
89
89
const nextRow = range [ 1 ] . row + 2 // 2 = 1 to get to delimiter line + 1 more to go past it
90
90
return sel . setBufferRange ( [
91
91
[ nextRow , 0 ] ,
92
92
[ nextRow , 0 ] ,
93
93
] )
94
94
}
95
95
96
- export function movePrev ( ed ) {
97
- if ( ed == null ) {
98
- ed = atom . workspace . getActiveTextEditor ( )
96
+ export function movePrev ( editor ) {
97
+ if ( editor == null ) {
98
+ editor = atom . workspace . getActiveTextEditor ( )
99
99
}
100
- if ( ed . getGrammar ( ) . scopeName . indexOf ( "source.weave" ) > - 1 ) {
101
- return weaveMovePrev ( ed )
100
+ if ( editor . getGrammar ( ) . scopeName . indexOf ( "source.weave" ) > - 1 ) {
101
+ return weaveMovePrev ( editor )
102
102
} else {
103
- return jlMovePrev ( ed )
103
+ return jlMovePrev ( editor )
104
104
}
105
105
}
106
106
107
- function jlMovePrev ( ed ) {
108
- const range = getRange ( ed )
107
+ function jlMovePrev ( editor ) {
108
+ const range = getRange ( editor )
109
109
const prevRow = range [ 0 ] . row - 2 // 2 = 1 to get to delimiter line + 1 more to go past it
110
- const sel = ed . getSelections ( ) [ 0 ]
110
+ const sel = editor . getSelections ( ) [ 0 ]
111
111
return sel . setBufferRange ( [
112
112
[ prevRow , 0 ] ,
113
113
[ prevRow , 0 ] ,
0 commit comments