2
2
// TODO: docstrings
3
3
4
4
import { forLines } from "./scopes"
5
+ import { TextEditor } from "atom"
5
6
6
- export function getLine ( editor , l ) {
7
+ export function getLine ( editor : TextEditor , l ) {
7
8
return {
8
9
scope : editor . scopeDescriptorForBufferPosition ( [ l , 0 ] ) . scopes ,
9
10
line : editor . getTextInBufferRange ( [
@@ -43,14 +44,14 @@ function isStart(lineInfo) {
43
44
return ! ( / ^ \s / . test ( lineInfo . line ) || isBlank ( lineInfo ) || isEnd ( lineInfo ) || isCont ( lineInfo ) )
44
45
}
45
46
46
- function walkBack ( editor , row ) {
47
+ function walkBack ( editor : TextEditor , row ) {
47
48
while ( row > 0 && ! isStart ( getLine ( editor , row ) ) ) {
48
49
row --
49
50
}
50
51
return row
51
52
}
52
53
53
- function walkForward ( editor , start ) {
54
+ function walkForward ( editor : TextEditor , start ) {
54
55
let end = start
55
56
let mark = start
56
57
while ( mark < editor . getLastBufferRow ( ) ) {
@@ -74,7 +75,7 @@ function walkForward(editor, start) {
74
75
return end
75
76
}
76
77
77
- function getRange ( editor , row ) {
78
+ function getRange ( editor : TextEditor , row ) {
78
79
const start = walkBack ( editor , row )
79
80
const end = walkForward ( editor , start )
80
81
if ( start <= row && row <= end ) {
@@ -85,7 +86,7 @@ function getRange(editor, row) {
85
86
}
86
87
}
87
88
88
- function getSelection ( editor , selection ) {
89
+ function getSelection ( editor : TextEditor , selection ) {
89
90
const { start, end } = selection . getBufferRange ( )
90
91
const range = [
91
92
[ start . row , start . column ] ,
@@ -102,7 +103,7 @@ function getSelection(editor, selection) {
102
103
return range
103
104
}
104
105
105
- export function moveNext ( editor , selection , range ) {
106
+ export function moveNext ( editor : TextEditor , selection , range ) {
106
107
// Ensure enough room at the end of the buffer
107
108
const row = range [ 1 ] [ 0 ]
108
109
let last
@@ -128,7 +129,7 @@ export function moveNext(editor, selection, range) {
128
129
] )
129
130
}
130
131
131
- function getRanges ( editor ) {
132
+ function getRanges ( editor : TextEditor ) {
132
133
const ranges = editor . getSelections ( ) . map ( selection => {
133
134
return {
134
135
selection : selection ,
@@ -140,7 +141,7 @@ function getRanges(editor) {
140
141
} )
141
142
}
142
143
143
- export function get ( editor ) {
144
+ export function get ( editor : TextEditor ) {
144
145
return getRanges ( editor ) . map ( ( { range, selection } ) => {
145
146
return {
146
147
range,
@@ -151,7 +152,7 @@ export function get(editor) {
151
152
} )
152
153
}
153
154
154
- export function getLocalContext ( editor , row ) {
155
+ export function getLocalContext ( editor : TextEditor , row ) {
155
156
const range = getRange ( editor , row )
156
157
const context = range ? editor . getTextInBufferRange ( range ) : ""
157
158
// NOTE:
0 commit comments