From a0e39b445338a015e6ed09c69f2b697420667e1c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 30 Jan 2025 17:32:39 +0100 Subject: [PATCH] Clean up targets (#2791) ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Phil Cohen --- .../src/processTargets/targets/BaseTarget.ts | 2 ++ .../processTargets/targets/DocumentTarget.ts | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts b/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts index 3b8e5f99f8..3bd17ddbbb 100644 --- a/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts @@ -69,6 +69,7 @@ export abstract class BaseTarget< get editor() { return this.state.editor; } + get isReversed() { return this.state.isReversed; } @@ -114,6 +115,7 @@ export abstract class BaseTarget< getInterior(): Target[] | undefined { return undefined; } + getBoundary(): Target[] | undefined { return undefined; } diff --git a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts index 7773de4afe..ae3a6163f7 100644 --- a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts @@ -1,7 +1,6 @@ import type { Range } from "@cursorless/common"; import { shrinkRangeToFitContent } from "../../util/selectionUtils"; -import type { CommonTargetParameters } from "./BaseTarget"; -import { BaseTarget } from "./BaseTarget"; +import { BaseTarget, type CommonTargetParameters } from "./BaseTarget"; import { PlainTarget } from "./PlainTarget"; export class DocumentTarget extends BaseTarget { @@ -13,16 +12,6 @@ export class DocumentTarget extends BaseTarget { super(parameters); } - getLeadingDelimiterTarget() { - return undefined; - } - getTrailingDelimiterTarget() { - return undefined; - } - getRemovalRange(): Range { - return this.contentRange; - } - getInterior() { return [ // Use plain target instead of interior target since we want the same content and removal range for a document interior. @@ -34,6 +23,18 @@ export class DocumentTarget extends BaseTarget { ]; } + getRemovalRange(): Range { + return this.contentRange; + } + + getLeadingDelimiterTarget() { + return undefined; + } + + getTrailingDelimiterTarget() { + return undefined; + } + protected getCloneParameters() { return this.state; }