Skip to content

Commit bd14779

Browse files
More fixes
1 parent b1957b3 commit bd14779

29 files changed

+94
-108
lines changed

packages/cursorless-engine/src/actions/CutToClipboard.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { ide } from "../singletons/ide.singleton";
99
import type { Target } from "../typings/target.types";
1010
import type { Actions } from "./Actions";
11-
import type { SimpleAction, ActionReturnValue } from "./actions.types";
11+
import type { ActionReturnValue, SimpleAction } from "./actions.types";
1212

1313
export class CutToClipboard implements SimpleAction {
1414
constructor(private actions: Actions) {
@@ -21,7 +21,7 @@ export class CutToClipboard implements SimpleAction {
2121
const { editor, contentRange } = target;
2222
const removalHighlightRange = target.getRemovalHighlightRange();
2323

24-
if (isLine(target)) {
24+
if (target.behavesLikeLine) {
2525
return [
2626
{
2727
editor,
@@ -63,11 +63,6 @@ export class CutToClipboard implements SimpleAction {
6363
}
6464
}
6565

66-
function isLine(target: Target): boolean {
67-
const { type } = target;
68-
return type === "line" || type === "paragraph" || type === "document";
69-
}
70-
7166
/** Get the possible leading and trailing overflow ranges of the outside range compared to the inside range */
7267
function getOutsideOverflow(insideRange: Range, outsideRange: Range): Range[] {
7368
const { start: insideStart, end: insideEnd } = insideRange;

packages/cursorless-engine/src/actions/EditNew/EditNew.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export class EditNew {
1818
}
1919

2020
async run(destinations: Destination[]): Promise<ActionReturnValue> {
21-
if (destinations.some(({ target }) => target.type === "notebookCell")) {
21+
if (
22+
destinations.some(({ target }) => target.textualType === "notebookCell")
23+
) {
2224
// It is not possible to "pour" a notebook cell and something else,
2325
// because each notebook cell is its own editor, and you can't have
2426
// cursors in multiple editors.

packages/cursorless-engine/src/actions/Highlight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class Highlight {
3333
ide().setHighlightRanges(
3434
highlightId,
3535
editor,
36-
targets.map(toGeneralizedRange),
36+
targets.map((t) => toGeneralizedRange(t, t.contentRange)),
3737
),
3838
);
3939
}

packages/cursorless-engine/src/actions/InsertEmptyLines.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ function constructChangeEdit(
142142
): EditWithFlashType {
143143
return {
144144
...target.toDestination(insertionMode).constructChangeEdit("", true),
145-
isLine: isLine(target),
145+
isLine: target.behavesLikeLine,
146146
};
147147
}
148-
149-
function isLine(target: Target): boolean {
150-
const { type } = target;
151-
return type === "line" || type === "paragraph" || type === "document";
152-
}

packages/cursorless-engine/src/actions/ToggleBreakpoint.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { containingLineIfUntypedModifier } from "../processTargets/modifiers/com
55
import { ide } from "../singletons/ide.singleton";
66
import type { Target } from "../typings/target.types";
77
import { flashTargets, runOnTargetsForEachEditor } from "../util/targetUtils";
8-
import type { SimpleAction, ActionReturnValue } from "./actions.types";
8+
import type { ActionReturnValue, SimpleAction } from "./actions.types";
99

1010
export default class ToggleBreakpoint implements SimpleAction {
1111
getFinalStages = () => [
@@ -25,7 +25,7 @@ export default class ToggleBreakpoint implements SimpleAction {
2525
const breakpointDescriptors: BreakpointDescriptor[] = targets.map(
2626
(target) => {
2727
const range = target.contentRange;
28-
return isLine(target)
28+
return target.behavesLikeLine
2929
? {
3030
type: "line",
3131
startLine: range.start.line,
@@ -48,8 +48,3 @@ export default class ToggleBreakpoint implements SimpleAction {
4848
};
4949
}
5050
}
51-
52-
function isLine(target: Target): boolean {
53-
const { type } = target;
54-
return type === "line" || type === "paragraph" || type === "document";
55-
}

packages/cursorless-engine/src/processTargets/createContinuousRangeTarget.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Target } from "../typings/target.types";
22
import { isSameType } from "../util/typeUtils";
3+
import { LineTarget, UntypedTarget } from "./targets";
34
import {
45
createContinuousLineRange,
56
createContinuousRange,
67
} from "./targets/util/createContinuousRange";
7-
import { LineTarget, UntypedTarget } from "./targets";
88

99
/**
1010
* Creates a target consisting of a range between two targets. If the targets
@@ -48,7 +48,7 @@ export function createContinuousRangeTarget(
4848
}
4949
}
5050

51-
if (isLine(startTarget) && isLine(endTarget)) {
51+
if (startTarget.behavesLikeLine && endTarget.behavesLikeLine) {
5252
return new LineTarget({
5353
editor: startTarget.editor,
5454
isReversed,
@@ -71,17 +71,12 @@ export function createContinuousRangeTarget(
7171
includeStart,
7272
includeEnd,
7373
),
74-
type:
74+
textualType:
7575
includeStart &&
7676
includeEnd &&
77-
startTarget.type === "token" &&
78-
endTarget.type === "token"
77+
startTarget.textualType === "token" &&
78+
endTarget.textualType === "token"
7979
? "token"
8080
: "character",
8181
});
8282
}
83-
84-
function isLine(target: Target): boolean {
85-
const { type } = target;
86-
return type === "line" || type === "paragraph" || type === "document";
87-
}

packages/cursorless-engine/src/processTargets/marks/CursorStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class CursorStage implements MarkStage {
1313
isReversed: selection.selection.isReversed,
1414
contentRange: selection.selection,
1515
hasExplicitRange: !selection.selection.isEmpty,
16-
type: "character",
16+
textualType: "character",
1717
}),
1818
);
1919
}

packages/cursorless-engine/src/processTargets/modifiers/InstanceStage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class InstanceStage implements ModifierStage {
135135
contentRange: range,
136136
editor,
137137
isReversed: false,
138-
type: "character",
138+
textualType: "character",
139139
}),
140140
);
141141

@@ -182,11 +182,11 @@ export class InstanceStage implements ModifierStage {
182182
}
183183

184184
function getFilterScopeType(target: Target): ScopeType | null {
185-
switch (target.type) {
185+
switch (target.textualType) {
186186
case "line":
187187
case "token":
188188
case "word":
189-
return { type: target.type };
189+
return { type: target.textualType };
190190
default:
191191
return null;
192192
}

packages/cursorless-engine/src/processTargets/modifiers/PositionStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class PositionStage implements ModifierStage {
1515
return [
1616
target.isRaw
1717
? new RawSelectionTarget(parameters)
18-
: new PlainTarget({ ...parameters, type: "character" }),
18+
: new PlainTarget({ ...parameters, textualType: "character" }),
1919
];
2020
}
2121

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/CharacterScopeHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class CharacterScopeHandler extends NestedScopeHandler {
3939
editor,
4040
contentRange: range,
4141
isReversed,
42-
type: "character",
42+
textualType: "character",
4343
}),
4444
],
4545
}),

0 commit comments

Comments
 (0)