From dd760dbd4f815859bb6ba709d35a4d5b568ae458 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 14:36:13 -0500 Subject: [PATCH 01/18] Remove index imports. --- .../src/processTargets/targets/DocumentTarget.ts | 3 ++- .../src/processTargets/targets/ImplicitTarget.ts | 2 +- .../src/processTargets/targets/InteriorTarget.ts | 2 +- .../src/processTargets/targets/LineTarget.ts | 2 +- .../src/processTargets/targets/NotebookCellTarget.ts | 2 +- .../src/processTargets/targets/ParagraphTarget.ts | 3 ++- .../src/processTargets/targets/PlainTarget.ts | 2 +- .../src/processTargets/targets/RawSelectionTarget.ts | 2 +- .../src/processTargets/targets/SubTokenWordTarget.ts | 2 +- .../src/processTargets/targets/SurroundingPairTarget.ts | 6 +++++- .../src/processTargets/targets/TokenTarget.ts | 2 +- .../src/processTargets/targets/UntypedTarget.ts | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts index ce73bb4480..d411375e0f 100644 --- a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts @@ -1,6 +1,7 @@ import { Range } from "@cursorless/common"; import { shrinkRangeToFitContent } from "../../util/selectionUtils"; -import { BaseTarget, CommonTargetParameters, PlainTarget } from "./"; +import { BaseTarget, CommonTargetParameters, PlainTarget } from "./BaseTarget"; +import { PlainTarget } from "./PlainTarget"; export class DocumentTarget extends BaseTarget { type = "DocumentTarget"; diff --git a/packages/cursorless-engine/src/processTargets/targets/ImplicitTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ImplicitTarget.ts index 21c00526ac..103fa29e23 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ImplicitTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ImplicitTarget.ts @@ -1,4 +1,4 @@ -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; /** * A target that was not explicitly spoken by the user. For example: diff --git a/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts b/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts index f220a81276..c7cbd4771a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts @@ -1,5 +1,5 @@ import { Range } from "@cursorless/common"; -import { BaseTarget, MinimumTargetParameters } from "."; +import { BaseTarget, MinimumTargetParameters } from "./BaseTarget"; import { shrinkRangeToFitContent } from "../../util/selectionUtils"; import { createContinuousRangeFromRanges } from "../targetUtil/createContinuousRange"; diff --git a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts index 862868dfa6..1601d7b843 100644 --- a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts @@ -1,5 +1,5 @@ import { Position, Range, TextEditor } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import { tryConstructPlainTarget } from "../../util/tryConstructTarget"; import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; diff --git a/packages/cursorless-engine/src/processTargets/targets/NotebookCellTarget.ts b/packages/cursorless-engine/src/processTargets/targets/NotebookCellTarget.ts index 0f1790bee5..ffdae50712 100644 --- a/packages/cursorless-engine/src/processTargets/targets/NotebookCellTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/NotebookCellTarget.ts @@ -1,5 +1,5 @@ import { InsertionMode } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { Destination } from "../../typings/target.types"; import { NotebookCellDestination } from "./NotebookCellDestination"; diff --git a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts index d6cd18f25b..78b5e0ad13 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts @@ -5,7 +5,8 @@ import { TextEditor, TextLine, } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters, LineTarget } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; +import { BaseTarget, CommonTargetParameters, LineTarget } from "./LineTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import { constructLineTarget } from "../../util/tryConstructTarget"; import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; diff --git a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts index 8df13b5cc3..c78e53822a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts @@ -1,4 +1,4 @@ -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; interface PlainTargetParameters extends CommonTargetParameters { readonly isToken?: boolean; diff --git a/packages/cursorless-engine/src/processTargets/targets/RawSelectionTarget.ts b/packages/cursorless-engine/src/processTargets/targets/RawSelectionTarget.ts index 9270f431a5..cfd7c495ae 100644 --- a/packages/cursorless-engine/src/processTargets/targets/RawSelectionTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/RawSelectionTarget.ts @@ -1,4 +1,4 @@ -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; /** * A target that has no leading or trailing delimiters so it's removal range diff --git a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts index 9659edc11a..759322d3bc 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts @@ -1,5 +1,5 @@ import { Range } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { tryConstructPlainTarget } from "../../util/tryConstructTarget"; import { createContinuousRange } from "../targetUtil/createContinuousRange"; import { getDelimitedSequenceRemovalRange } from "../targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; diff --git a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts index ba78eefc25..103489cbe4 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts @@ -2,9 +2,13 @@ import { Range } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters, +} from "./BaseTarget"; +import { InteriorTarget, + } from "./InteriorTarget"; +import { TokenTarget, -} from "."; +} from "./TokenTarget"; import { Target } from "../../typings/target.types"; import { getTokenLeadingDelimiterTarget, diff --git a/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts b/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts index cda03520cb..bf54175f95 100644 --- a/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts @@ -1,5 +1,5 @@ import { Range } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { Target } from "../../typings/target.types"; import { getTokenLeadingDelimiterTarget, diff --git a/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts b/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts index 570ba619e1..cbd432860c 100644 --- a/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts @@ -1,5 +1,5 @@ import { Range } from "@cursorless/common"; -import { BaseTarget, CommonTargetParameters } from "."; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import type { Target } from "../../typings/target.types"; import { getTokenLeadingDelimiterTarget, From f61232a89e12d78f94bc3e14b4f0d03e81f9bab6 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 15:27:22 -0500 Subject: [PATCH 02/18] Remove index imports. --- packages/common/src/util/toPlainObject.ts | 5 ++-- .../cursorless-engine/src/actions/Actions.ts | 2 +- .../src/actions/ShowParseTree.ts | 2 +- .../cursorless-engine/src/cursorlessEngine.ts | 3 +- .../CustomSpokenFormGeneratorImpl.ts | 4 +-- .../src/languages/LanguageDefinitions.ts | 2 +- .../ModifierStageFactoryImpl.ts | 2 +- .../processTargets/marks/TargetMarkStage.ts | 2 +- .../scopeHandlers/CharacterScopeHandler.ts | 2 +- .../scopeHandlers/IdentifierScopeHandler.ts | 2 +- .../scopeHandlers/RegexScopeHandler.ts | 3 +- .../scopeHandlers/ScopeHandlerFactoryImpl.ts | 28 +++++++++---------- .../SentenceScopeHandler.ts | 2 +- .../scopeHandlers/TokenScopeHandler.ts | 2 +- .../WordScopeHandler/WordScopeHandler.ts | 2 +- .../processTargets/targets/ScopeTypeTarget.ts | 6 +++- .../src/testUtil/openNewEditor.ts | 2 +- 17 files changed, 38 insertions(+), 33 deletions(-) diff --git a/packages/common/src/util/toPlainObject.ts b/packages/common/src/util/toPlainObject.ts index 86ac47b549..56d0e48cc7 100644 --- a/packages/common/src/util/toPlainObject.ts +++ b/packages/common/src/util/toPlainObject.ts @@ -1,5 +1,6 @@ -import type { CharacterRange, GeneralizedRange, LineRange } from ".."; -import { FlashStyle, isLineRange } from ".."; +import type { CharacterRange, GeneralizedRange, LineRange } from "../types/GeneralizedRange"; +import { isLineRange } from "../types/GeneralizedRange"; +import { FlashStyle } from "../ide/types/FlashDescriptor"; import { Token } from "../types/Token"; import { Selection } from "../types/Selection"; diff --git a/packages/cursorless-engine/src/actions/Actions.ts b/packages/cursorless-engine/src/actions/Actions.ts index c338a82d6e..aef630945e 100644 --- a/packages/cursorless-engine/src/actions/Actions.ts +++ b/packages/cursorless-engine/src/actions/Actions.ts @@ -1,4 +1,4 @@ -import { TreeSitter } from ".."; +import { TreeSitter } from "../typings/TreeSitter"; import { Snippets } from "../core/Snippets"; import { RangeUpdater } from "../core/updateSelections/RangeUpdater"; import { ModifierStageFactory } from "../processTargets/ModifierStageFactory"; diff --git a/packages/cursorless-engine/src/actions/ShowParseTree.ts b/packages/cursorless-engine/src/actions/ShowParseTree.ts index 0c7db86232..f535f05121 100644 --- a/packages/cursorless-engine/src/actions/ShowParseTree.ts +++ b/packages/cursorless-engine/src/actions/ShowParseTree.ts @@ -1,7 +1,7 @@ import { FlashStyle, Range, TextDocument } from "@cursorless/common"; import * as path from "node:path"; import type { Tree, TreeCursor } from "web-tree-sitter"; -import type { TreeSitter } from ".."; +import type { TreeSitter } from "../typings/TreeSitter"; import { ide } from "../singletons/ide.singleton"; import type { Target } from "../typings/target.types"; import { flashTargets } from "../util/targetUtils"; diff --git a/packages/cursorless-engine/src/cursorlessEngine.ts b/packages/cursorless-engine/src/cursorlessEngine.ts index c7b22ecd43..cee5a2aa85 100644 --- a/packages/cursorless-engine/src/cursorlessEngine.ts +++ b/packages/cursorless-engine/src/cursorlessEngine.ts @@ -6,7 +6,8 @@ import { IDE, ScopeProvider, } from "@cursorless/common"; -import { StoredTargetMap, TreeSitter } from "."; +import { StoredTargetMap } from "./core/StoredTargets"; +import { TreeSitter } from "./typings/TreeSitter"; import { CommandRunnerDecorator, CursorlessEngine, diff --git a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts index bfb146a87b..ab31439115 100644 --- a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts +++ b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts @@ -4,8 +4,8 @@ import { Listener, ScopeType, } from "@cursorless/common"; -import { SpokenFormGenerator } from "."; -import { CustomSpokenFormGenerator } from ".."; +import { SpokenFormGenerator } from "./generateSpokenForm/SpokenFormGenerator"; +import { CustomSpokenFormGenerator } from "./generateSpokenForm/CustomSpokenFormGenerator"; import { CustomSpokenForms } from "../spokenForms/CustomSpokenForms"; import { TalonSpokenForms } from "../scopeProviders/TalonSpokenForms"; diff --git a/packages/cursorless-engine/src/languages/LanguageDefinitions.ts b/packages/cursorless-engine/src/languages/LanguageDefinitions.ts index 4632f3473c..51f8781e2f 100644 --- a/packages/cursorless-engine/src/languages/LanguageDefinitions.ts +++ b/packages/cursorless-engine/src/languages/LanguageDefinitions.ts @@ -8,7 +8,7 @@ import { } from "@cursorless/common"; import { join } from "path"; import { SyntaxNode } from "web-tree-sitter"; -import { TreeSitter } from ".."; +import { TreeSitter } from "../typings/TreeSitter"; import { ide } from "../singletons/ide.singleton"; import { LanguageDefinition } from "./LanguageDefinition"; diff --git a/packages/cursorless-engine/src/processTargets/ModifierStageFactoryImpl.ts b/packages/cursorless-engine/src/processTargets/ModifierStageFactoryImpl.ts index f3a6dfad3d..7f8c7ae2f5 100644 --- a/packages/cursorless-engine/src/processTargets/ModifierStageFactoryImpl.ts +++ b/packages/cursorless-engine/src/processTargets/ModifierStageFactoryImpl.ts @@ -4,7 +4,7 @@ import { Modifier, SurroundingPairModifier, } from "@cursorless/common"; -import { StoredTargetMap } from ".."; +import { StoredTargetMap } from "../core/StoredTargets"; import { LanguageDefinitions } from "../languages/LanguageDefinitions"; import { ModifierStageFactory } from "./ModifierStageFactory"; import { ModifierStage } from "./PipelineStages.types"; diff --git a/packages/cursorless-engine/src/processTargets/marks/TargetMarkStage.ts b/packages/cursorless-engine/src/processTargets/marks/TargetMarkStage.ts index f9190b518d..7a96b64746 100644 --- a/packages/cursorless-engine/src/processTargets/marks/TargetMarkStage.ts +++ b/packages/cursorless-engine/src/processTargets/marks/TargetMarkStage.ts @@ -1,4 +1,4 @@ -import { TargetPipelineRunner } from ".."; +import { TargetPipelineRunner } from "../TargetPipelineRunner"; import { TargetMark } from "../../typings/TargetDescriptor"; import { Target } from "../../typings/target.types"; import { MarkStage } from "../PipelineStages.types"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/CharacterScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/CharacterScopeHandler.ts index c864357cc8..96d2b52627 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/CharacterScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/CharacterScopeHandler.ts @@ -1,6 +1,6 @@ import { Direction, ScopeType } from "@cursorless/common"; import { imap } from "itertools"; -import { NestedScopeHandler } from "."; +import { NestedScopeHandler } from "./NestedScopeHandler"; import { getMatcher } from "../../../tokenizer"; import { generateMatchesInRange } from "../../../util/getMatchesInRange"; import { PlainTarget } from "../../targets"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/IdentifierScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/IdentifierScopeHandler.ts index dad5698168..08c8967bb6 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/IdentifierScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/IdentifierScopeHandler.ts @@ -1,5 +1,5 @@ import { imap } from "itertools"; -import { NestedScopeHandler } from "."; +import { NestedScopeHandler } from "./NestedScopeHandler"; import { getMatcher } from "../../../tokenizer"; import { Direction } from "@cursorless/common"; import { generateMatchesInRange } from "../../../util/getMatchesInRange"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/RegexScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/RegexScopeHandler.ts index 209ede051c..6b17995529 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/RegexScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/RegexScopeHandler.ts @@ -1,6 +1,7 @@ import { CustomRegexScopeType, Direction, ScopeType } from "@cursorless/common"; import { imap } from "itertools"; -import { NestedScopeHandler, ScopeHandlerFactory } from "."; +import { NestedScopeHandler } from "./NestedScopeHandler"; +import { ScopeHandlerFactory } from "./ScopeHandlerFactory"; import { generateMatchesInRange } from "../../../util/getMatchesInRange"; import { TokenTarget } from "../../targets"; import { TargetScope } from "./scope.types"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts index 3efd7f8770..b9a87fd865 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts @@ -1,19 +1,17 @@ import type { ScopeType } from "@cursorless/common"; -import { - CharacterScopeHandler, - CustomRegexScopeHandler, - DocumentScopeHandler, - IdentifierScopeHandler, - LineScopeHandler, - NonWhitespaceSequenceScopeHandler, - OneOfScopeHandler, - ParagraphScopeHandler, - ScopeHandlerFactory, - SentenceScopeHandler, - TokenScopeHandler, - UrlScopeHandler, - WordScopeHandler, -} from "."; +import { CharacterScopeHandler } from "./CharacterScopeHandler"; +import { CustomRegexScopeHandler } from "./RegexScopeHandler"; +import { DocumentScopeHandler } from "./DocumentScopeHandler"; +import { IdentifierScopeHandler } from "./IdentifierScopeHandler"; +import { LineScopeHandler } from "./LineScopeHandler"; +import { NonWhitespaceSequenceScopeHandler } from "./RegexScopeHandler"; +import { OneOfScopeHandler } from "./OneOfScopeHandler"; +import { ParagraphScopeHandler } from "./ParagraphScopeHandler"; +import { ScopeHandlerFactory } from "./ScopeHandlerFactory"; +import { SentenceScopeHandler } from "./SentenceScopeHandler/SentenceScopeHandler"; +import { TokenScopeHandler } from "./TokenScopeHandler"; +import { UrlScopeHandler } from "./RegexScopeHandler"; +import { WordScopeHandler } from "./WordScopeHandler/WordScopeHandler"; import { LanguageDefinitions } from "../../../languages/LanguageDefinitions"; import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SentenceScopeHandler/SentenceScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SentenceScopeHandler/SentenceScopeHandler.ts index b9b3cb770b..e4ba5ae2b8 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SentenceScopeHandler/SentenceScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SentenceScopeHandler/SentenceScopeHandler.ts @@ -1,6 +1,6 @@ import { Direction, Range } from "@cursorless/common"; import { imap } from "itertools"; -import { NestedScopeHandler } from ".."; +import { NestedScopeHandler } from "../NestedScopeHandler"; import { TokenTarget } from "../../../targets"; import type { TargetScope } from "../scope.types"; import { SentenceSegmenter } from "./SentenceSegmenter"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/TokenScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/TokenScopeHandler.ts index 9b49df4c2b..12b4893816 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/TokenScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/TokenScopeHandler.ts @@ -1,6 +1,6 @@ import { Direction } from "@cursorless/common"; import { imap } from "itertools"; -import { NestedScopeHandler } from "."; +import { NestedScopeHandler } from "./NestedScopeHandler"; import { getMatcher } from "../../../tokenizer"; import { generateMatchesInRange } from "../../../util/getMatchesInRange"; import { TokenTarget } from "../../targets"; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/WordScopeHandler/WordScopeHandler.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/WordScopeHandler/WordScopeHandler.ts index b9fd509158..9e4c25b946 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/WordScopeHandler/WordScopeHandler.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/WordScopeHandler/WordScopeHandler.ts @@ -1,5 +1,5 @@ import { Range, TextEditor } from "@cursorless/common"; -import { NestedScopeHandler } from ".."; +import { NestedScopeHandler } from "../NestedScopeHandler"; import { WordTokenizer } from "./WordTokenizer"; import { Direction } from "@cursorless/common"; import { SubTokenWordTarget } from "../../../targets"; diff --git a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts index 1a724e2377..85008bce94 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts @@ -2,9 +2,13 @@ import { Range, SimpleScopeTypeType } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters, +} from "./BaseTarget"; +import { InteriorTarget, +} from "./InteriorTarget"; +import { PlainTarget, -} from "."; +} from "./PlainTarget"; import { Target } from "../../typings/target.types"; import { createContinuousRange, diff --git a/packages/vscode-common/src/testUtil/openNewEditor.ts b/packages/vscode-common/src/testUtil/openNewEditor.ts index c83e9b4a1d..daf35b894b 100644 --- a/packages/vscode-common/src/testUtil/openNewEditor.ts +++ b/packages/vscode-common/src/testUtil/openNewEditor.ts @@ -1,4 +1,4 @@ -import { getParseTreeApi } from ".."; +import { getParseTreeApi } from "../getExtensionApi"; import * as vscode from "vscode"; interface NewEditorOptions { From 5158d234281c1a55e8222990188dcb13db6b5e04 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:03:53 -0500 Subject: [PATCH 03/18] Remove index imports. --- .../src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts | 2 +- .../src/processTargets/targets/DocumentTarget.ts | 2 +- .../src/processTargets/targets/ParagraphTarget.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts index ab31439115..e9732212a3 100644 --- a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts +++ b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts @@ -4,7 +4,7 @@ import { Listener, ScopeType, } from "@cursorless/common"; -import { SpokenFormGenerator } from "./generateSpokenForm/SpokenFormGenerator"; +import { SpokenFormGenerator } from "./generateSpokenForm/generateSpokenForm"; import { CustomSpokenFormGenerator } from "./generateSpokenForm/CustomSpokenFormGenerator"; import { CustomSpokenForms } from "../spokenForms/CustomSpokenForms"; import { TalonSpokenForms } from "../scopeProviders/TalonSpokenForms"; diff --git a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts index d411375e0f..ae933bbea2 100644 --- a/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/DocumentTarget.ts @@ -1,6 +1,6 @@ import { Range } from "@cursorless/common"; import { shrinkRangeToFitContent } from "../../util/selectionUtils"; -import { BaseTarget, CommonTargetParameters, PlainTarget } from "./BaseTarget"; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { PlainTarget } from "./PlainTarget"; export class DocumentTarget extends BaseTarget { diff --git a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts index 78b5e0ad13..2f048ce2a1 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts @@ -6,7 +6,7 @@ import { TextLine, } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; -import { BaseTarget, CommonTargetParameters, LineTarget } from "./LineTarget"; +import { LineTarget } from "./LineTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import { constructLineTarget } from "../../util/tryConstructTarget"; import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; From aa2543b6f5f46ebfab9792617e0a727e9fc306ad Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:10:29 -0500 Subject: [PATCH 04/18] Remove index imports. --- .../src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts index e9732212a3..a9c0877098 100644 --- a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts +++ b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts @@ -4,8 +4,8 @@ import { Listener, ScopeType, } from "@cursorless/common"; -import { SpokenFormGenerator } from "./generateSpokenForm/generateSpokenForm"; -import { CustomSpokenFormGenerator } from "./generateSpokenForm/CustomSpokenFormGenerator"; +import { SpokenFormGenerator } from "./generateSpokenForm"; +import { CustomSpokenFormGenerator } from "./api/CursorlessEngineApi"; import { CustomSpokenForms } from "../spokenForms/CustomSpokenForms"; import { TalonSpokenForms } from "../scopeProviders/TalonSpokenForms"; From 9e90a47f38cd79679e85c1dd1deaab73bc00747f Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:12:04 -0500 Subject: [PATCH 05/18] Remove index imports. --- .../src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts index a9c0877098..481a69818d 100644 --- a/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts +++ b/packages/cursorless-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.ts @@ -5,7 +5,7 @@ import { ScopeType, } from "@cursorless/common"; import { SpokenFormGenerator } from "./generateSpokenForm"; -import { CustomSpokenFormGenerator } from "./api/CursorlessEngineApi"; +import { CustomSpokenFormGenerator } from "../api/CursorlessEngineApi"; import { CustomSpokenForms } from "../spokenForms/CustomSpokenForms"; import { TalonSpokenForms } from "../scopeProviders/TalonSpokenForms"; From b6a15c14544deb51a585e14f3da8782db72d5d4a Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:24:03 -0500 Subject: [PATCH 06/18] Move tryConstructTarget constructors to their files. --- .../src/processTargets/targets/LineTarget.ts | 24 +++++++++++-- .../processTargets/targets/ParagraphTarget.ts | 2 +- .../src/processTargets/targets/PlainTarget.ts | 20 +++++++++++ .../targets/SubTokenWordTarget.ts | 2 +- .../src/util/tryConstructTarget.ts | 36 ------------------- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts index 1601d7b843..681c14952d 100644 --- a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts @@ -1,8 +1,9 @@ -import { Position, Range, TextEditor } from "@cursorless/common"; +import { Position, Range, Range, TextEditor, TextEditor } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { expandToFullLine } from "../../util/rangeUtils"; -import { tryConstructPlainTarget } from "../../util/tryConstructTarget"; +import {tryConstructPlainTarget} from "./PlainTarget"; import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; +import {tryConstructTarget} from "../../util/tryConstructTarget"; export class LineTarget extends BaseTarget { type = "LineTarget"; @@ -70,3 +71,22 @@ function getTrailingDelimiterRange(editor: TextEditor, range: Range) { ? new Range(range.end, new Position(end.line + 1, 0)) : undefined; } + +/** + * Constructs a {@link LineTarget} from the given range, or returns undefined + * if the range is undefined + * @param editor The editor containing the range + * @param range The range to convert into a target + * @param isReversed Whether the rain should be backward + * @returns A new {@link LineTarget} constructed from the given range, or null + * if the range is undefined + */ + +export function constructLineTarget( + editor: TextEditor, + range: Range | undefined, + isReversed: boolean +): LineTarget | undefined { + return tryConstructTarget(LineTarget, editor, range, isReversed); +} + diff --git a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts index 2f048ce2a1..7a4f84115a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts @@ -8,7 +8,7 @@ import { import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { LineTarget } from "./LineTarget"; import { expandToFullLine } from "../../util/rangeUtils"; -import { constructLineTarget } from "../../util/tryConstructTarget"; +import {constructLineTarget} from "./LineTarget"; import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; export class ParagraphTarget extends BaseTarget { diff --git a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts index c78e53822a..a5cc948ff1 100644 --- a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts @@ -1,3 +1,5 @@ +import {tryConstructTarget} from "../../util/tryConstructTarget"; +import {TextEditor, Range} from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; interface PlainTargetParameters extends CommonTargetParameters { @@ -32,3 +34,21 @@ export class PlainTarget extends BaseTarget { }; } } + +/** + * Constructs a {@link PlainTarget} from the given range, or returns undefined + * if the range is undefined + * @param editor The editor containing the range + * @param range The range to convert into a target + * @param isReversed Whether the rain should be backward + * @returns A new {@link PlainTarget} constructed from the given range, or null + * if the range is undefined + */ +export function tryConstructPlainTarget( + editor: TextEditor, + range: Range | undefined, + isReversed: boolean +): PlainTarget | undefined { + return tryConstructTarget(PlainTarget, editor, range, isReversed); +} + diff --git a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts index 759322d3bc..14d5f4ac47 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts @@ -1,6 +1,6 @@ import { Range } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; -import { tryConstructPlainTarget } from "../../util/tryConstructTarget"; +import {tryConstructPlainTarget} from "./PlainTarget"; import { createContinuousRange } from "../targetUtil/createContinuousRange"; import { getDelimitedSequenceRemovalRange } from "../targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; diff --git a/packages/cursorless-engine/src/util/tryConstructTarget.ts b/packages/cursorless-engine/src/util/tryConstructTarget.ts index c9ca286450..7b721ac5f6 100644 --- a/packages/cursorless-engine/src/util/tryConstructTarget.ts +++ b/packages/cursorless-engine/src/util/tryConstructTarget.ts @@ -1,8 +1,6 @@ import { Range, TextEditor } from "@cursorless/common"; import { CommonTargetParameters, - LineTarget, - PlainTarget, } from "../processTargets/targets"; import { Target } from "../typings/target.types"; @@ -34,37 +32,3 @@ export function tryConstructTarget( contentRange: range, }); } - -/** - * Constructs a {@link PlainTarget} from the given range, or returns undefined - * if the range is undefined - * @param editor The editor containing the range - * @param range The range to convert into a target - * @param isReversed Whether the rain should be backward - * @returns A new {@link PlainTarget} constructed from the given range, or null - * if the range is undefined - */ -export function tryConstructPlainTarget( - editor: TextEditor, - range: Range | undefined, - isReversed: boolean, -): PlainTarget | undefined { - return tryConstructTarget(PlainTarget, editor, range, isReversed); -} - -/** - * Constructs a {@link LineTarget} from the given range, or returns undefined - * if the range is undefined - * @param editor The editor containing the range - * @param range The range to convert into a target - * @param isReversed Whether the rain should be backward - * @returns A new {@link LineTarget} constructed from the given range, or null - * if the range is undefined - */ -export function constructLineTarget( - editor: TextEditor, - range: Range | undefined, - isReversed: boolean, -): LineTarget | undefined { - return tryConstructTarget(LineTarget, editor, range, isReversed); -} From 24bf37fd79900af1603a00339e04824e39c6bb3a Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:30:30 -0500 Subject: [PATCH 07/18] Move tryConstructTarget constructors to their files. --- .../cursorless-engine/src/processTargets/targets/LineTarget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts index 681c14952d..9432816dd5 100644 --- a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts @@ -1,4 +1,4 @@ -import { Position, Range, Range, TextEditor, TextEditor } from "@cursorless/common"; +import { Position, Range, TextEditor } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import {tryConstructPlainTarget} from "./PlainTarget"; From f4f11f0fed48e73b2fe76cdcbb2b353e237a7900 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:41:07 -0500 Subject: [PATCH 08/18] Moved processTargets/targetUtil to processTargets/targets/util. --- .../src/processTargets/createContinuousRangeTarget.ts | 2 +- .../src/processTargets/targets/BaseTarget.ts | 2 +- .../src/processTargets/targets/InteriorTarget.ts | 2 +- .../src/processTargets/targets/LineTarget.ts | 2 +- .../src/processTargets/targets/ParagraphTarget.ts | 2 +- .../src/processTargets/targets/ScopeTypeTarget.ts | 6 +++--- .../src/processTargets/targets/SubTokenWordTarget.ts | 4 ++-- .../src/processTargets/targets/SurroundingPairTarget.ts | 2 +- .../src/processTargets/targets/TokenTarget.ts | 2 +- .../src/processTargets/targets/UntypedTarget.ts | 2 +- .../{targetUtil => targets/util}/createContinuousRange.ts | 2 +- .../DelimitedSequenceInsertionRemovalBehavior.ts | 2 +- .../TokenInsertionRemovalBehavior.ts | 6 +++--- .../insertionRemovalBehavior.types.ts | 0 14 files changed, 18 insertions(+), 18 deletions(-) rename packages/cursorless-engine/src/processTargets/{targetUtil => targets/util}/createContinuousRange.ts (94%) rename packages/cursorless-engine/src/processTargets/{targetUtil => targets/util}/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts (90%) rename packages/cursorless-engine/src/processTargets/{targetUtil => targets/util}/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts (96%) rename packages/cursorless-engine/src/processTargets/{targetUtil => targets/util}/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts (100%) diff --git a/packages/cursorless-engine/src/processTargets/createContinuousRangeTarget.ts b/packages/cursorless-engine/src/processTargets/createContinuousRangeTarget.ts index d6b08a9acd..70dd63bbf7 100644 --- a/packages/cursorless-engine/src/processTargets/createContinuousRangeTarget.ts +++ b/packages/cursorless-engine/src/processTargets/createContinuousRangeTarget.ts @@ -3,7 +3,7 @@ import { isSameType } from "../util/typeUtils"; import { createContinuousLineRange, createContinuousRange, -} from "./targetUtil/createContinuousRange"; +} from "./targets/util/createContinuousRange"; import { LineTarget, UntypedTarget } from "./targets"; /** diff --git a/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts b/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts index 20307fbbfe..53cb2c8cd6 100644 --- a/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/BaseTarget.ts @@ -14,7 +14,7 @@ import { isEqual } from "lodash"; import type { EditWithRangeUpdater } from "../../typings/Types"; import type { Destination, Target } from "../../typings/target.types"; import { DestinationImpl } from "./DestinationImpl"; -import { createContinuousRange } from "../targetUtil/createContinuousRange"; +import { createContinuousRange } from "./util/createContinuousRange"; /** Parameters supported by all target classes */ export interface MinimumTargetParameters { diff --git a/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts b/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts index c7cbd4771a..68d2755921 100644 --- a/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/InteriorTarget.ts @@ -1,7 +1,7 @@ import { Range } from "@cursorless/common"; import { BaseTarget, MinimumTargetParameters } from "./BaseTarget"; import { shrinkRangeToFitContent } from "../../util/selectionUtils"; -import { createContinuousRangeFromRanges } from "../targetUtil/createContinuousRange"; +import { createContinuousRangeFromRanges } from "./util/createContinuousRange"; export interface InteriorTargetParameters extends MinimumTargetParameters { readonly fullInteriorRange: Range; diff --git a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts index 9432816dd5..e19ef0ef1a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts @@ -2,7 +2,7 @@ import { Position, Range, TextEditor } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import {tryConstructPlainTarget} from "./PlainTarget"; -import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; +import { createContinuousLineRange } from "./util/createContinuousRange"; import {tryConstructTarget} from "../../util/tryConstructTarget"; export class LineTarget extends BaseTarget { diff --git a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts index 7a4f84115a..8304e16756 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts @@ -9,7 +9,7 @@ import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { LineTarget } from "./LineTarget"; import { expandToFullLine } from "../../util/rangeUtils"; import {constructLineTarget} from "./LineTarget"; -import { createContinuousLineRange } from "../targetUtil/createContinuousRange"; +import { createContinuousLineRange } from "./util/createContinuousRange"; export class ParagraphTarget extends BaseTarget { type = "ParagraphTarget"; diff --git a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts index 85008bce94..5d5068fa1f 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts @@ -13,13 +13,13 @@ import { Target } from "../../typings/target.types"; import { createContinuousRange, createContinuousRangeFromRanges, -} from "../targetUtil/createContinuousRange"; -import { getDelimitedSequenceRemovalRange } from "../targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; +} from "./util/createContinuousRange"; +import { getDelimitedSequenceRemovalRange } from "./util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; import { getTokenLeadingDelimiterTarget, getTokenRemovalRange, getTokenTrailingDelimiterTarget, -} from "../targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; +} from "./util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; export interface ScopeTypeTargetParameters extends CommonTargetParameters { readonly scopeTypeType: SimpleScopeTypeType; diff --git a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts index 14d5f4ac47..e1e9b9aa0a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts @@ -1,8 +1,8 @@ import { Range } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import {tryConstructPlainTarget} from "./PlainTarget"; -import { createContinuousRange } from "../targetUtil/createContinuousRange"; -import { getDelimitedSequenceRemovalRange } from "../targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; +import { createContinuousRange } from "./util/createContinuousRange"; +import { getDelimitedSequenceRemovalRange } from "./util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; export interface SubTokenTargetParameters extends CommonTargetParameters { readonly insertionDelimiter: string; diff --git a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts index 103489cbe4..bcf93a2789 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts @@ -14,7 +14,7 @@ import { getTokenLeadingDelimiterTarget, getTokenRemovalRange, getTokenTrailingDelimiterTarget, -} from "../targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; +} from "./util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; interface SurroundingPairTargetParameters extends CommonTargetParameters { /** diff --git a/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts b/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts index bf54175f95..0d4d64e720 100644 --- a/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/TokenTarget.ts @@ -5,7 +5,7 @@ import { getTokenLeadingDelimiterTarget, getTokenRemovalRange, getTokenTrailingDelimiterTarget, -} from "../targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; +} from "./util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; export class TokenTarget extends BaseTarget { type = "TokenTarget"; diff --git a/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts b/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts index cbd432860c..06aab15997 100644 --- a/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/UntypedTarget.ts @@ -5,7 +5,7 @@ import { getTokenLeadingDelimiterTarget, getTokenRemovalRange, getTokenTrailingDelimiterTarget, -} from "../targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; +} from "./util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior"; interface UntypedTargetParameters extends CommonTargetParameters { readonly hasExplicitRange: boolean; diff --git a/packages/cursorless-engine/src/processTargets/targetUtil/createContinuousRange.ts b/packages/cursorless-engine/src/processTargets/targets/util/createContinuousRange.ts similarity index 94% rename from packages/cursorless-engine/src/processTargets/targetUtil/createContinuousRange.ts rename to packages/cursorless-engine/src/processTargets/targets/util/createContinuousRange.ts index c41434aa90..02a2777f34 100644 --- a/packages/cursorless-engine/src/processTargets/targetUtil/createContinuousRange.ts +++ b/packages/cursorless-engine/src/processTargets/targets/util/createContinuousRange.ts @@ -1,5 +1,5 @@ import { Position, Range } from "@cursorless/common"; -import type { Target } from "../../typings/target.types"; +import type { Target } from "../../../typings/target.types"; export function createContinuousRange( startTarget: Target, diff --git a/packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts similarity index 90% rename from packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts rename to packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts index a6f3cb7b40..6132a78512 100644 --- a/packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts +++ b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior.ts @@ -1,5 +1,5 @@ import { Range } from "@cursorless/common"; -import { Target } from "../../../typings/target.types"; +import { Target } from "../../../../typings/target.types"; /** * Constructs a removal range for the given target that includes either the diff --git a/packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts similarity index 96% rename from packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts rename to packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts index 004f8fe1da..160cab6351 100644 --- a/packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts +++ b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/TokenInsertionRemovalBehavior.ts @@ -1,7 +1,7 @@ import { Range, TextEditor } from "@cursorless/common"; -import type { Target } from "../../../typings/target.types"; -import { expandToFullLine } from "../../../util/rangeUtils"; -import { PlainTarget } from "../../targets"; +import type { Target } from "../../../../typings/target.types"; +import { expandToFullLine } from "../../../../util/rangeUtils"; +import { PlainTarget } from "../../PlainTarget"; const leadingDelimiters = ['"', "'", "(", "[", "{", "<"]; const trailingDelimiters = ['"', "'", ")", "]", "}", ">", ",", ";", ":"]; diff --git a/packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts similarity index 100% rename from packages/cursorless-engine/src/processTargets/targetUtil/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts rename to packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts From c7f06088760fccceff997c403851dc0589888f62 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 16:45:00 -0500 Subject: [PATCH 09/18] Moved processTargets/targetUtil to processTargets/targets/util. --- .../insertionRemovalBehaviors/insertionRemovalBehavior.types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts index 8968d69000..4690c3235a 100644 --- a/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts +++ b/packages/cursorless-engine/src/processTargets/targets/util/insertionRemovalBehaviors/insertionRemovalBehavior.types.ts @@ -1,5 +1,5 @@ import type { Range } from "@cursorless/common"; -import type { Target } from "../../../typings/target.types"; +import type { Target } from "../../../../typings/target.types"; export interface InsertionRemovalBehavior { getLeadingDelimiterTarget(): Target | undefined; From 1dcb3aa9a5fb3faae644b898bb5a56acea860c7b Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 19:09:11 -0500 Subject: [PATCH 10/18] Break cycle between notebook.ts and notebookLegacy.ts. --- .../src/ide/vscode/VscodeFocusEditor.ts | 6 +-- .../src/ide/vscode/VscodeNotebooks.ts | 4 +- .../src/ide/vscode/notebook/notebook.ts | 44 +++++-------------- .../ide/vscode/notebook/notebookCurrent.ts | 30 +++++++++++++ .../src/ide/vscode/notebook/notebookLegacy.ts | 13 ++---- 5 files changed, 51 insertions(+), 46 deletions(-) create mode 100644 packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts index fdc847274a..a7c64f5c53 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts @@ -8,11 +8,11 @@ import { window, } from "vscode"; import { getCellIndex } from "@cursorless/vscode-common"; -import { getNotebookFromCellDocument } from "./notebook/notebook"; +import { getNotebookFromCellDocumentCurrent } from "./notebook/notebookCurrent"; import { focusNotebookCellLegacy, - isVscodeLegacyNotebookVersion, } from "./notebook/notebookLegacy"; +import {isVscodeLegacyNotebookVersion} from "./notebook/notebook"; import type { VscodeIDE } from "./VscodeIDE"; import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl"; @@ -69,7 +69,7 @@ function getViewColumn(editor: TextEditor): ViewColumn | undefined { } async function focusNotebookCell(editor: VscodeTextEditorImpl) { - const desiredNotebookEditor = getNotebookFromCellDocument( + const desiredNotebookEditor = getNotebookFromCellDocumentCurrent( editor.vscodeEditor.document, ); if (desiredNotebookEditor == null) { diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts index b4c8d0fcf9..4c5d5e3a47 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts @@ -1,6 +1,6 @@ import { Selection } from "@cursorless/common"; import * as vscode from "vscode"; -import { getNotebookFromCellDocument } from "./notebook/notebook"; +import { getNotebookFromCellDocumentCurrent } from "./notebook/notebookCurrent"; import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl"; export async function vscodeEditNewNotebookCellAbove( @@ -40,5 +40,5 @@ export async function vscodeEditNewNotebookCellBelow( } function isNotebookEditor(editor: VscodeTextEditorImpl) { - return getNotebookFromCellDocument(editor.vscodeEditor.document) != null; + return getNotebookFromCellDocumentCurrent(editor.vscodeEditor.document) != null; } diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts index ddb0563682..98fe091b8b 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts @@ -1,38 +1,18 @@ -import { NotebookCell, TextDocument, window } from "vscode"; -import { - getNotebookFromCellDocumentLegacy, - isVscodeLegacyNotebookVersion, -} from "./notebookLegacy"; +import * as semver from "semver"; +import {version} from "vscode"; +import { TextDocument } from "vscode"; +import { getNotebookFromCellDocumentLegacy } from "./notebookLegacy"; +import { getNotebookFromCellDocumentCurrent } from "./notebookCurrent"; + + +export function isVscodeLegacyNotebookVersion() { + return semver.lt(version, "1.68.0"); +} -/** - * Given a document corresponding to a single cell, retrieve the notebook - * document for the entire notebook - * @param document The document corresponding to the given cell - * @returns The notebook document corresponding to the notebook containing the - * given cell - */ export function getNotebookFromCellDocument(document: TextDocument) { if (isVscodeLegacyNotebookVersion()) { return getNotebookFromCellDocumentLegacy(document); + } else { + return getNotebookFromCellDocumentCurrent(document); } - - // FIXME: All these type casts are necessary because we've pinned VSCode - // version type defs. Can remove them once we are using more recent type defs - const { notebookEditor } = - ((window as any).visibleNotebookEditors as any[]) - .flatMap((notebookEditor: any) => - ( - ( - notebookEditor.document ?? notebookEditor.notebook - ).getCells() as NotebookCell[] - ).map((cell) => ({ - notebookEditor, - cell, - })), - ) - .find( - ({ cell }) => cell.document.uri.toString() === document.uri.toString(), - ) ?? {}; - - return notebookEditor; } diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts new file mode 100644 index 0000000000..a138d1f2da --- /dev/null +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts @@ -0,0 +1,30 @@ +import { NotebookCell, TextDocument, window } from "vscode"; + +/** + * Given a document corresponding to a single cell, retrieve the notebook + * document for the entire notebook + * @param document The document corresponding to the given cell + * @returns The notebook document corresponding to the notebook containing the + * given cell + */ +export function getNotebookFromCellDocumentCurrent(document: TextDocument) { + // FIXME: All these type casts are necessary because we've pinned VSCode + // version type defs. Can remove them once we are using more recent type defs + const { notebookEditor } = + ((window as any).visibleNotebookEditors as any[]) + .flatMap((notebookEditor: any) => + ( + ( + notebookEditor.document ?? notebookEditor.notebook + ).getCells() as NotebookCell[] + ).map((cell) => ({ + notebookEditor, + cell, + })), + ) + .find( + ({ cell }) => cell.document.uri.toString() === document.uri.toString(), + ) ?? {}; + + return notebookEditor; +} diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts index 610c13b269..f87b63642e 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts @@ -1,15 +1,10 @@ import { getCellIndex } from "@cursorless/vscode-common"; import { range } from "lodash"; -import * as semver from "semver"; -import { commands, NotebookDocument, TextDocument, version } from "vscode"; +import { commands, NotebookDocument, TextDocument } from "vscode"; import { toVscodeEditor } from "../toVscodeEditor"; import type { VscodeIDE } from "../VscodeIDE"; import type { VscodeTextEditorImpl } from "../VscodeTextEditorImpl"; -import { getNotebookFromCellDocument } from "./notebook"; - -export function isVscodeLegacyNotebookVersion() { - return semver.lt(version, "1.68.0"); -} +import { getNotebookFromCellDocumentCurrent } from "./notebookCurrent"; export async function focusNotebookCellLegacy( ide: VscodeIDE, @@ -23,10 +18,10 @@ export async function focusNotebookCellLegacy( const vscodeActiveEditor = toVscodeEditor(activeTextEditor); - const editorNotebook = getNotebookFromCellDocument( + const editorNotebook = getNotebookFromCellDocumentCurrent( editor.vscodeEditor.document, ); - const activeEditorNotebook = getNotebookFromCellDocument( + const activeEditorNotebook = getNotebookFromCellDocumentCurrent( vscodeActiveEditor.document, ); From 2b2e4a457f52a924bf99d6ff200daaf368591c7c Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Thu, 30 Nov 2023 20:21:31 -0500 Subject: [PATCH 11/18] Remove index imports. --- .../vscode/VSCodeScopeVisualizer/VscodeScopeTargetVisualizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/VSCodeScopeVisualizer/VscodeScopeTargetVisualizer.ts b/packages/cursorless-vscode/src/ide/vscode/VSCodeScopeVisualizer/VscodeScopeTargetVisualizer.ts index f52862a400..ae5c4eb216 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VSCodeScopeVisualizer/VscodeScopeTargetVisualizer.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VSCodeScopeVisualizer/VscodeScopeTargetVisualizer.ts @@ -6,7 +6,7 @@ import { TextEditor, toCharacterRange, } from "@cursorless/common"; -import { VscodeScopeVisualizer } from "."; +import { VscodeScopeVisualizer } from "./VscodeScopeVisualizer"; import { VscodeTextEditorImpl } from "../VscodeTextEditorImpl"; abstract class VscodeScopeTargetVisualizer extends VscodeScopeVisualizer { From 94ab05b5a4affeb0d9aad2c737e251d94e8540f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 03:08:27 +0000 Subject: [PATCH 12/18] [pre-commit.ci lite] apply automatic fixes --- packages/common/src/util/toPlainObject.ts | 6 +++++- .../src/processTargets/targets/LineTarget.ts | 7 +++---- .../src/processTargets/targets/ParagraphTarget.ts | 2 +- .../src/processTargets/targets/PlainTarget.ts | 7 +++---- .../src/processTargets/targets/ScopeTypeTarget.ts | 13 +++---------- .../processTargets/targets/SubTokenWordTarget.ts | 2 +- .../processTargets/targets/SurroundingPairTarget.ts | 13 +++---------- .../src/util/tryConstructTarget.ts | 4 +--- .../src/ide/vscode/VscodeFocusEditor.ts | 6 ++---- .../src/ide/vscode/VscodeNotebooks.ts | 4 +++- .../src/ide/vscode/notebook/notebook.ts | 3 +-- 11 files changed, 26 insertions(+), 41 deletions(-) diff --git a/packages/common/src/util/toPlainObject.ts b/packages/common/src/util/toPlainObject.ts index 56d0e48cc7..2b3b6598e6 100644 --- a/packages/common/src/util/toPlainObject.ts +++ b/packages/common/src/util/toPlainObject.ts @@ -1,4 +1,8 @@ -import type { CharacterRange, GeneralizedRange, LineRange } from "../types/GeneralizedRange"; +import type { + CharacterRange, + GeneralizedRange, + LineRange, +} from "../types/GeneralizedRange"; import { isLineRange } from "../types/GeneralizedRange"; import { FlashStyle } from "../ide/types/FlashDescriptor"; import { Token } from "../types/Token"; diff --git a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts index e19ef0ef1a..ab5c798a72 100644 --- a/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/LineTarget.ts @@ -1,9 +1,9 @@ import { Position, Range, TextEditor } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { expandToFullLine } from "../../util/rangeUtils"; -import {tryConstructPlainTarget} from "./PlainTarget"; +import { tryConstructPlainTarget } from "./PlainTarget"; import { createContinuousLineRange } from "./util/createContinuousRange"; -import {tryConstructTarget} from "../../util/tryConstructTarget"; +import { tryConstructTarget } from "../../util/tryConstructTarget"; export class LineTarget extends BaseTarget { type = "LineTarget"; @@ -85,8 +85,7 @@ function getTrailingDelimiterRange(editor: TextEditor, range: Range) { export function constructLineTarget( editor: TextEditor, range: Range | undefined, - isReversed: boolean + isReversed: boolean, ): LineTarget | undefined { return tryConstructTarget(LineTarget, editor, range, isReversed); } - diff --git a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts index 8304e16756..09e02adda7 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts @@ -8,7 +8,7 @@ import { import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; import { LineTarget } from "./LineTarget"; import { expandToFullLine } from "../../util/rangeUtils"; -import {constructLineTarget} from "./LineTarget"; +import { constructLineTarget } from "./LineTarget"; import { createContinuousLineRange } from "./util/createContinuousRange"; export class ParagraphTarget extends BaseTarget { diff --git a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts index a5cc948ff1..65bd31fe59 100644 --- a/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/PlainTarget.ts @@ -1,5 +1,5 @@ -import {tryConstructTarget} from "../../util/tryConstructTarget"; -import {TextEditor, Range} from "@cursorless/common"; +import { tryConstructTarget } from "../../util/tryConstructTarget"; +import { TextEditor, Range } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; interface PlainTargetParameters extends CommonTargetParameters { @@ -47,8 +47,7 @@ export class PlainTarget extends BaseTarget { export function tryConstructPlainTarget( editor: TextEditor, range: Range | undefined, - isReversed: boolean + isReversed: boolean, ): PlainTarget | undefined { return tryConstructTarget(PlainTarget, editor, range, isReversed); } - diff --git a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts index 5d5068fa1f..02bf7814f4 100644 --- a/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/ScopeTypeTarget.ts @@ -1,14 +1,7 @@ import { Range, SimpleScopeTypeType } from "@cursorless/common"; -import { - BaseTarget, - CommonTargetParameters, -} from "./BaseTarget"; -import { - InteriorTarget, -} from "./InteriorTarget"; -import { - PlainTarget, -} from "./PlainTarget"; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; +import { InteriorTarget } from "./InteriorTarget"; +import { PlainTarget } from "./PlainTarget"; import { Target } from "../../typings/target.types"; import { createContinuousRange, diff --git a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts index e1e9b9aa0a..5931758f2d 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SubTokenWordTarget.ts @@ -1,6 +1,6 @@ import { Range } from "@cursorless/common"; import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; -import {tryConstructPlainTarget} from "./PlainTarget"; +import { tryConstructPlainTarget } from "./PlainTarget"; import { createContinuousRange } from "./util/createContinuousRange"; import { getDelimitedSequenceRemovalRange } from "./util/insertionRemovalBehaviors/DelimitedSequenceInsertionRemovalBehavior"; diff --git a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts index bcf93a2789..ea58749919 100644 --- a/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts +++ b/packages/cursorless-engine/src/processTargets/targets/SurroundingPairTarget.ts @@ -1,14 +1,7 @@ import { Range } from "@cursorless/common"; -import { - BaseTarget, - CommonTargetParameters, -} from "./BaseTarget"; -import { - InteriorTarget, - } from "./InteriorTarget"; -import { - TokenTarget, -} from "./TokenTarget"; +import { BaseTarget, CommonTargetParameters } from "./BaseTarget"; +import { InteriorTarget } from "./InteriorTarget"; +import { TokenTarget } from "./TokenTarget"; import { Target } from "../../typings/target.types"; import { getTokenLeadingDelimiterTarget, diff --git a/packages/cursorless-engine/src/util/tryConstructTarget.ts b/packages/cursorless-engine/src/util/tryConstructTarget.ts index 7b721ac5f6..a0670b7deb 100644 --- a/packages/cursorless-engine/src/util/tryConstructTarget.ts +++ b/packages/cursorless-engine/src/util/tryConstructTarget.ts @@ -1,7 +1,5 @@ import { Range, TextEditor } from "@cursorless/common"; -import { - CommonTargetParameters, -} from "../processTargets/targets"; +import { CommonTargetParameters } from "../processTargets/targets"; import { Target } from "../typings/target.types"; type TargetConstructor = new ( diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts index a7c64f5c53..547a2d2561 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts @@ -9,10 +9,8 @@ import { } from "vscode"; import { getCellIndex } from "@cursorless/vscode-common"; import { getNotebookFromCellDocumentCurrent } from "./notebook/notebookCurrent"; -import { - focusNotebookCellLegacy, -} from "./notebook/notebookLegacy"; -import {isVscodeLegacyNotebookVersion} from "./notebook/notebook"; +import { focusNotebookCellLegacy } from "./notebook/notebookLegacy"; +import { isVscodeLegacyNotebookVersion } from "./notebook/notebook"; import type { VscodeIDE } from "./VscodeIDE"; import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl"; diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts index 4c5d5e3a47..7face6409d 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts @@ -40,5 +40,7 @@ export async function vscodeEditNewNotebookCellBelow( } function isNotebookEditor(editor: VscodeTextEditorImpl) { - return getNotebookFromCellDocumentCurrent(editor.vscodeEditor.document) != null; + return ( + getNotebookFromCellDocumentCurrent(editor.vscodeEditor.document) != null + ); } diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts index 98fe091b8b..788017a41a 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts @@ -1,10 +1,9 @@ import * as semver from "semver"; -import {version} from "vscode"; +import { version } from "vscode"; import { TextDocument } from "vscode"; import { getNotebookFromCellDocumentLegacy } from "./notebookLegacy"; import { getNotebookFromCellDocumentCurrent } from "./notebookCurrent"; - export function isVscodeLegacyNotebookVersion() { return semver.lt(version, "1.68.0"); } From a00191540a7992547185642f7a9a2920ad358a5e Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Fri, 1 Dec 2023 09:25:04 -0500 Subject: [PATCH 13/18] Fix focusNotebookCellLegacy --- .../cursorless-vscode/src/ide/vscode/notebook/notebook.ts | 7 +++++++ .../src/ide/vscode/notebook/notebookCurrent.ts | 7 ------- .../src/ide/vscode/notebook/notebookLegacy.ts | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts index 788017a41a..8ebbb01664 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebook.ts @@ -8,6 +8,13 @@ export function isVscodeLegacyNotebookVersion() { return semver.lt(version, "1.68.0"); } +/** + * Given a document corresponding to a single cell, retrieve the notebook + * document for the entire notebook + * @param document The document corresponding to the given cell + * @returns The notebook document corresponding to the notebook containing the + * given cell + */ export function getNotebookFromCellDocument(document: TextDocument) { if (isVscodeLegacyNotebookVersion()) { return getNotebookFromCellDocumentLegacy(document); diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts index a138d1f2da..9f0bc0eee2 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts @@ -1,12 +1,5 @@ import { NotebookCell, TextDocument, window } from "vscode"; -/** - * Given a document corresponding to a single cell, retrieve the notebook - * document for the entire notebook - * @param document The document corresponding to the given cell - * @returns The notebook document corresponding to the notebook containing the - * given cell - */ export function getNotebookFromCellDocumentCurrent(document: TextDocument) { // FIXME: All these type casts are necessary because we've pinned VSCode // version type defs. Can remove them once we are using more recent type defs diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts index f87b63642e..e5599929d8 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts @@ -4,7 +4,7 @@ import { commands, NotebookDocument, TextDocument } from "vscode"; import { toVscodeEditor } from "../toVscodeEditor"; import type { VscodeIDE } from "../VscodeIDE"; import type { VscodeTextEditorImpl } from "../VscodeTextEditorImpl"; -import { getNotebookFromCellDocumentCurrent } from "./notebookCurrent"; +import { getNotebookFromCellDocument } from "./notebook"; export async function focusNotebookCellLegacy( ide: VscodeIDE, @@ -18,10 +18,10 @@ export async function focusNotebookCellLegacy( const vscodeActiveEditor = toVscodeEditor(activeTextEditor); - const editorNotebook = getNotebookFromCellDocumentCurrent( + const editorNotebook = getNotebookFromCellDocument( editor.vscodeEditor.document, ); - const activeEditorNotebook = getNotebookFromCellDocumentCurrent( + const activeEditorNotebook = getNotebookFromCellDocument( vscodeActiveEditor.document, ); From f957a69135da2afffa97d1c9d1e980823e4d53e9 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Fri, 1 Dec 2023 12:03:11 -0500 Subject: [PATCH 14/18] Fix all calls to getNotebookFromCellDocument* --- .../cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts | 4 ++-- .../cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts | 4 ++-- .../src/ide/vscode/notebook/notebookLegacy.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts index 547a2d2561..7b0153dadb 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts @@ -8,7 +8,7 @@ import { window, } from "vscode"; import { getCellIndex } from "@cursorless/vscode-common"; -import { getNotebookFromCellDocumentCurrent } from "./notebook/notebookCurrent"; +import { getNotebookFromCellDocument } from "./notebook/notebook"; import { focusNotebookCellLegacy } from "./notebook/notebookLegacy"; import { isVscodeLegacyNotebookVersion } from "./notebook/notebook"; import type { VscodeIDE } from "./VscodeIDE"; @@ -67,7 +67,7 @@ function getViewColumn(editor: TextEditor): ViewColumn | undefined { } async function focusNotebookCell(editor: VscodeTextEditorImpl) { - const desiredNotebookEditor = getNotebookFromCellDocumentCurrent( + const desiredNotebookEditor = getNotebookFromCellDocument( editor.vscodeEditor.document, ); if (desiredNotebookEditor == null) { diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts index 7face6409d..2cb05b16f2 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts @@ -1,6 +1,6 @@ import { Selection } from "@cursorless/common"; import * as vscode from "vscode"; -import { getNotebookFromCellDocumentCurrent } from "./notebook/notebookCurrent"; +import { getNotebookFromCellDocument } from "./notebook/notebook"; import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl"; export async function vscodeEditNewNotebookCellAbove( @@ -41,6 +41,6 @@ export async function vscodeEditNewNotebookCellBelow( function isNotebookEditor(editor: VscodeTextEditorImpl) { return ( - getNotebookFromCellDocumentCurrent(editor.vscodeEditor.document) != null + getNotebookFromCellDocument(editor.vscodeEditor.document) != null ); } diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts index f87b63642e..e5599929d8 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookLegacy.ts @@ -4,7 +4,7 @@ import { commands, NotebookDocument, TextDocument } from "vscode"; import { toVscodeEditor } from "../toVscodeEditor"; import type { VscodeIDE } from "../VscodeIDE"; import type { VscodeTextEditorImpl } from "../VscodeTextEditorImpl"; -import { getNotebookFromCellDocumentCurrent } from "./notebookCurrent"; +import { getNotebookFromCellDocument } from "./notebook"; export async function focusNotebookCellLegacy( ide: VscodeIDE, @@ -18,10 +18,10 @@ export async function focusNotebookCellLegacy( const vscodeActiveEditor = toVscodeEditor(activeTextEditor); - const editorNotebook = getNotebookFromCellDocumentCurrent( + const editorNotebook = getNotebookFromCellDocument( editor.vscodeEditor.document, ); - const activeEditorNotebook = getNotebookFromCellDocumentCurrent( + const activeEditorNotebook = getNotebookFromCellDocument( vscodeActiveEditor.document, ); From 889597c97dad8ca5583180623c137d2443bfeb5c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:04:57 +0000 Subject: [PATCH 15/18] [pre-commit.ci lite] apply automatic fixes --- packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts index 2cb05b16f2..b4c8d0fcf9 100644 --- a/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts +++ b/packages/cursorless-vscode/src/ide/vscode/VscodeNotebooks.ts @@ -40,7 +40,5 @@ export async function vscodeEditNewNotebookCellBelow( } function isNotebookEditor(editor: VscodeTextEditorImpl) { - return ( - getNotebookFromCellDocument(editor.vscodeEditor.document) != null - ); + return getNotebookFromCellDocument(editor.vscodeEditor.document) != null; } From c6f82777cf85f4ac64a127c5c2d9b509462b5deb Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:43:37 +0000 Subject: [PATCH 16/18] Update notebookCurrent.ts --- .../cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts index 9f0bc0eee2..b99ebac4a1 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts @@ -1,5 +1,6 @@ import { NotebookCell, TextDocument, window } from "vscode"; +/** Gets the notebook containing a text document using >1.68.0 VSCode notebook api **/ export function getNotebookFromCellDocumentCurrent(document: TextDocument) { // FIXME: All these type casts are necessary because we've pinned VSCode // version type defs. Can remove them once we are using more recent type defs From 19c2a31adb9c6454cb5750e54bf847ccd537edff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:45:00 +0000 Subject: [PATCH 17/18] [pre-commit.ci lite] apply automatic fixes --- .../src/ide/vscode/notebook/notebookCurrent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts index b99ebac4a1..1a3a24698b 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts @@ -1,6 +1,6 @@ import { NotebookCell, TextDocument, window } from "vscode"; -/** Gets the notebook containing a text document using >1.68.0 VSCode notebook api **/ +/** Gets the notebook containing a text document using >1.68.0 VSCode notebook api **/ export function getNotebookFromCellDocumentCurrent(document: TextDocument) { // FIXME: All these type casts are necessary because we've pinned VSCode // version type defs. Can remove them once we are using more recent type defs From 29a903c1f4aa86547a5c2bc3f86fe336ea391aa6 Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:53:24 +0000 Subject: [PATCH 18/18] Update notebookCurrent.ts --- .../src/ide/vscode/notebook/notebookCurrent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts index 1a3a24698b..fb4e7d3edf 100644 --- a/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts +++ b/packages/cursorless-vscode/src/ide/vscode/notebook/notebookCurrent.ts @@ -1,6 +1,6 @@ import { NotebookCell, TextDocument, window } from "vscode"; -/** Gets the notebook containing a text document using >1.68.0 VSCode notebook api **/ +/** Gets the notebook containing a text document using >=1.68.0 VSCode notebook api **/ export function getNotebookFromCellDocumentCurrent(document: TextDocument) { // FIXME: All these type casts are necessary because we've pinned VSCode // version type defs. Can remove them once we are using more recent type defs