Skip to content

Commit 658cb35

Browse files
authored
Merge pull request #231 from takker99:range
refactor: Use `range` exported from `@core/iterutil/range`
2 parents 49b4a1d + 81037e5 commit 658cb35

File tree

4 files changed

+20
-47
lines changed

4 files changed

+20
-47
lines changed

browser/dom/edit.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { goHead, goLine } from "./motion.ts";
22
import { press } from "./press.ts";
33
import { getLineCount } from "./node.ts";
4-
import { range } from "../../range.ts";
4+
import { range } from "@core/iterutil/range";
55
import { textInput } from "./dom.ts";
66
import { isArray } from "@core/unknownutil/is/array";
77
import { isNumber } from "@core/unknownutil/is/number";
@@ -10,24 +10,24 @@ import type { Scrapbox } from "@cosense/types/userscript";
1010
declare const scrapbox: Scrapbox;
1111

1212
export const undo = (count = 1): void => {
13-
for (const _ of range(0, count)) {
13+
for (const _ of range(1, count)) {
1414
press("z", { ctrlKey: true });
1515
}
1616
};
1717
export const redo = (count = 1): void => {
18-
for (const _ of range(0, count)) {
18+
for (const _ of range(1, count)) {
1919
press("z", { shiftKey: true, ctrlKey: true });
2020
}
2121
};
2222

2323
export const insertIcon = (count = 1): void => {
24-
for (const _ of range(0, count)) {
24+
for (const _ of range(1, count)) {
2525
press("i", { ctrlKey: true });
2626
}
2727
};
2828

2929
export const insertTimestamp = (index = 1): void => {
30-
for (const _ of range(0, index)) {
30+
for (const _ of range(1, index)) {
3131
press("t", { altKey: true });
3232
}
3333
};
@@ -94,12 +94,12 @@ export const deleteLines = async (
9494
};
9595

9696
export const indentLines = (count = 1): void => {
97-
for (const _ of range(0, count)) {
97+
for (const _ of range(1, count)) {
9898
press("ArrowRight", { ctrlKey: true });
9999
}
100100
};
101101
export const outdentLines = (count = 1): void => {
102-
for (const _ of range(0, count)) {
102+
for (const _ of range(1, count)) {
103103
press("ArrowLeft", { ctrlKey: true });
104104
}
105105
};
@@ -120,23 +120,23 @@ export const moveLinesBefore = (from: number, to: number): void => {
120120
}
121121
};
122122
export const upLines = (count = 1): void => {
123-
for (const _ of range(0, count)) {
123+
for (const _ of range(1, count)) {
124124
press("ArrowUp", { ctrlKey: true });
125125
}
126126
};
127127
export const downLines = (count = 1): void => {
128-
for (const _ of range(0, count)) {
128+
for (const _ of range(1, count)) {
129129
press("ArrowDown", { ctrlKey: true });
130130
}
131131
};
132132

133133
export const indentBlocks = (count = 1): void => {
134-
for (const _ of range(0, count)) {
134+
for (const _ of range(1, count)) {
135135
press("ArrowRight", { altKey: true });
136136
}
137137
};
138138
export const outdentBlocks = (count = 1): void => {
139-
for (const _ of range(0, count)) {
139+
for (const _ of range(1, count)) {
140140
press("ArrowLeft", { altKey: true });
141141
}
142142
};
@@ -148,12 +148,12 @@ export const moveBlocks = (count: number): void => {
148148
}
149149
};
150150
export const upBlocks = (count = 1): void => {
151-
for (const _ of range(0, count)) {
151+
for (const _ of range(1, count)) {
152152
press("ArrowUp", { altKey: true });
153153
}
154154
};
155155
export const downBlocks = (count = 1): void => {
156-
for (const _ of range(0, count)) {
156+
for (const _ of range(1, count)) {
157157
press("ArrowDown", { altKey: true });
158158
}
159159
};

browser/dom/motion.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "./node.ts";
1313
import { caret } from "./caret.ts";
1414
import { isHeightViewable } from "./isHeightViewable.ts";
15-
import { range } from "../../range.ts";
15+
import { range } from "@core/iterutil/range";
1616

1717
/** @deprecated
1818
* Long press at the end of cursor line to gain focus
@@ -38,7 +38,7 @@ export const focusEnd = async (holding = 1000): Promise<void> => {
3838
* @param [count=1] - Number of moves to perform
3939
*/
4040
export const moveLeft = (count = 1): void => {
41-
for (const _ of range(0, count)) {
41+
for (const _ of range(1, count)) {
4242
press("ArrowLeft");
4343
}
4444
};
@@ -47,7 +47,7 @@ export const moveLeft = (count = 1): void => {
4747
* @param [count=1] - Number of moves to perform
4848
*/
4949
export const moveUp = (count = 1): void => {
50-
for (const _ of range(0, count)) {
50+
for (const _ of range(1, count)) {
5151
press("ArrowUp");
5252
}
5353
};
@@ -56,7 +56,7 @@ export const moveUp = (count = 1): void => {
5656
* @param [count=1] - Number of moves to perform
5757
*/
5858
export const moveDown = (count = 1): void => {
59-
for (const _ of range(0, count)) {
59+
for (const _ of range(1, count)) {
6060
press("ArrowDown");
6161
}
6262
};
@@ -65,7 +65,7 @@ export const moveDown = (count = 1): void => {
6565
* @param [count=1] - Number of moves to perform
6666
*/
6767
export const moveRight = (count = 1): void => {
68-
for (const _ of range(0, count)) {
68+
for (const _ of range(1, count)) {
6969
press("ArrowRight");
7070
}
7171
};
@@ -193,7 +193,7 @@ export const scrollHalfDown = async (count = 1): Promise<void> => {
193193
* @param [count=1] - Number of scroll operations to perform
194194
*/
195195
export const scrollUp = (count = 1): void => {
196-
for (const _ of range(0, count)) {
196+
for (const _ of range(1, count)) {
197197
press("PageUp");
198198
}
199199
};
@@ -202,7 +202,7 @@ export const scrollUp = (count = 1): void => {
202202
* @param [count=1] - Number of scroll operations to perform
203203
*/
204204
export const scrollDown = (count = 1): void => {
205-
for (const _ of range(0, count)) {
205+
for (const _ of range(1, count)) {
206206
press("PageDown");
207207
}
208208
};

range.test.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

range.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)