Skip to content

Commit d0ff519

Browse files
committed
editor: TextEditor
1 parent 57fe8e9 commit d0ff519

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib_src/misc/blocks.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// TODO: docstrings
33

44
import { forLines } from "./scopes"
5+
import { TextEditor } from "atom"
56

6-
export function getLine(editor, l) {
7+
export function getLine(editor: TextEditor, l) {
78
return {
89
scope: editor.scopeDescriptorForBufferPosition([l, 0]).scopes,
910
line: editor.getTextInBufferRange([
@@ -43,14 +44,14 @@ function isStart(lineInfo) {
4344
return !(/^\s/.test(lineInfo.line) || isBlank(lineInfo) || isEnd(lineInfo) || isCont(lineInfo))
4445
}
4546

46-
function walkBack(editor, row) {
47+
function walkBack(editor: TextEditor, row) {
4748
while (row > 0 && !isStart(getLine(editor, row))) {
4849
row--
4950
}
5051
return row
5152
}
5253

53-
function walkForward(editor, start) {
54+
function walkForward(editor: TextEditor, start) {
5455
let end = start
5556
let mark = start
5657
while (mark < editor.getLastBufferRow()) {
@@ -74,7 +75,7 @@ function walkForward(editor, start) {
7475
return end
7576
}
7677

77-
function getRange(editor, row) {
78+
function getRange(editor: TextEditor, row) {
7879
const start = walkBack(editor, row)
7980
const end = walkForward(editor, start)
8081
if (start <= row && row <= end) {
@@ -85,7 +86,7 @@ function getRange(editor, row) {
8586
}
8687
}
8788

88-
function getSelection(editor, selection) {
89+
function getSelection(editor: TextEditor, selection) {
8990
const { start, end } = selection.getBufferRange()
9091
const range = [
9192
[start.row, start.column],
@@ -102,7 +103,7 @@ function getSelection(editor, selection) {
102103
return range
103104
}
104105

105-
export function moveNext(editor, selection, range) {
106+
export function moveNext(editor: TextEditor, selection, range) {
106107
// Ensure enough room at the end of the buffer
107108
const row = range[1][0]
108109
let last
@@ -128,7 +129,7 @@ export function moveNext(editor, selection, range) {
128129
])
129130
}
130131

131-
function getRanges(editor) {
132+
function getRanges(editor: TextEditor) {
132133
const ranges = editor.getSelections().map(selection => {
133134
return {
134135
selection: selection,
@@ -140,7 +141,7 @@ function getRanges(editor) {
140141
})
141142
}
142143

143-
export function get(editor) {
144+
export function get(editor: TextEditor) {
144145
return getRanges(editor).map(({ range, selection }) => {
145146
return {
146147
range,
@@ -151,7 +152,7 @@ export function get(editor) {
151152
})
152153
}
153154

154-
export function getLocalContext(editor, row) {
155+
export function getLocalContext(editor: TextEditor, row) {
155156
const range = getRange(editor, row)
156157
const context = range ? editor.getTextInBufferRange(range) : ""
157158
// NOTE:

0 commit comments

Comments
 (0)