From 62f091656c306dd686f975a4156957e00af11b63 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 7 Jul 2026 10:58:03 +0200 Subject: [PATCH 1/4] Add interior scope to visualize sidebar --- .../command/PartialTargetDescriptor.types.ts | 5 ++--- .../languages/TreeSitterQuery/captureNames.ts | 10 ++++------ .../InteriorScopeHandler.ts | 20 +++---------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts index da47dab585..bcaa3b6742 100644 --- a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts @@ -215,9 +215,8 @@ const simpleScopeTypeTypesSet = new Set(simpleScopeTypeTypes); export type SimpleScopeTypeType = (typeof simpleScopeTypeTypes)[number]; -export const pseudoScopes = new Set([ +export const pseudoScopeTypes = new Set([ "instance", - "interior", "className", "functionName", ]); @@ -229,7 +228,7 @@ export function isSimpleScopeType( } export function isPseudoScope(scopeType: ScopeType): boolean { - return isSimpleScopeType(scopeType) && pseudoScopes.has(scopeType.type); + return isSimpleScopeType(scopeType) && pseudoScopeTypes.has(scopeType.type); } export interface SimpleScopeType { diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts b/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts index a7c68ecf52..970f7c29ae 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts @@ -1,10 +1,8 @@ -import { pseudoScopes, simpleScopeTypeTypes } from "@cursorless/lib-common"; +import { pseudoScopeTypes, simpleScopeTypeTypes } from "@cursorless/lib-common"; -const scopeCaptureNames = [ - ...simpleScopeTypeTypes.filter((s) => !pseudoScopes.has(s)), - // Interior is a pseudo scope, but it's implemented with an actual internal scope - "interior", -] as const; +const scopeCaptureNames = simpleScopeTypeTypes.filter( + (s) => !pseudoScopeTypes.has(s), +); export type ScopeCaptureName = (typeof scopeCaptureNames)[number]; diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts index e8b4878043..75d73a8a90 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts @@ -1,23 +1,15 @@ -import type { - Direction, - Position, - ScopeType, - TextEditor, -} from "@cursorless/lib-common"; -import { NoContainingScopeError } from "@cursorless/lib-common"; +import type { Direction, Position, TextEditor } from "@cursorless/lib-common"; import type { LanguageDefinitions } from "../../../../languages/LanguageDefinitions"; import type { Target } from "../../../../typings/target.types"; import { InteriorTarget } from "../../../targets"; import { BaseScopeHandler } from "../BaseScopeHandler"; import type { TargetScope } from "../scope.types"; -import type { - ComplexScopeType, - ScopeIteratorRequirements, -} from "../scopeHandler.types"; +import type { ScopeIteratorRequirements } from "../scopeHandler.types"; import type { TreeSitterScopeHandler } from "../TreeSitterScopeHandler"; export class InteriorScopeHandler extends BaseScopeHandler { public readonly scopeType = { type: "interior" } as const; + public readonly iterationScopeType = { type: "document" } as const; protected isHierarchical = true; static maybeCreate( @@ -39,12 +31,6 @@ export class InteriorScopeHandler extends BaseScopeHandler { super(); } - get iterationScopeType(): ScopeType | ComplexScopeType { - throw new NoContainingScopeError( - "Iteration scope for InteriorScopeHandler", - ); - } - *generateScopeCandidates( editor: TextEditor, position: Position, From 258590f56950b9abea0abedbcb1deeeb10f88137 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 7 Jul 2026 11:01:42 +0200 Subject: [PATCH 2/4] Name fix --- .../src/types/command/PartialTargetDescriptor.types.ts | 6 ++++-- .../src/languages/TreeSitterQuery/captureNames.ts | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts index bcaa3b6742..0ce43a61b2 100644 --- a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts @@ -215,7 +215,7 @@ const simpleScopeTypeTypesSet = new Set(simpleScopeTypeTypes); export type SimpleScopeTypeType = (typeof simpleScopeTypeTypes)[number]; -export const pseudoScopeTypes = new Set([ +export const pseudoScopeTypeTypes = new Set([ "instance", "className", "functionName", @@ -228,7 +228,9 @@ export function isSimpleScopeType( } export function isPseudoScope(scopeType: ScopeType): boolean { - return isSimpleScopeType(scopeType) && pseudoScopeTypes.has(scopeType.type); + return ( + isSimpleScopeType(scopeType) && pseudoScopeTypeTypes.has(scopeType.type) + ); } export interface SimpleScopeType { diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts b/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts index 970f7c29ae..12f0b203ce 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/captureNames.ts @@ -1,7 +1,10 @@ -import { pseudoScopeTypes, simpleScopeTypeTypes } from "@cursorless/lib-common"; +import { + pseudoScopeTypeTypes, + simpleScopeTypeTypes, +} from "@cursorless/lib-common"; const scopeCaptureNames = simpleScopeTypeTypes.filter( - (s) => !pseudoScopeTypes.has(s), + (s) => !pseudoScopeTypeTypes.has(s), ); export type ScopeCaptureName = (typeof scopeCaptureNames)[number]; From 041ce1dfdbe20c83afed794ae1a84a7c216d4905 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 7 Jul 2026 11:04:51 +0200 Subject: [PATCH 3/4] Another name change --- .../src/types/command/PartialTargetDescriptor.types.ts | 2 +- .../modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts | 7 +++++-- .../lib-engine/src/scopeProviders/ScopeInfoProvider.ts | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts index 0ce43a61b2..8d627abcdc 100644 --- a/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/lib-common/src/types/command/PartialTargetDescriptor.types.ts @@ -227,7 +227,7 @@ export function isSimpleScopeType( return (simpleScopeTypeTypesSet as Set).has(scopeType.type); } -export function isPseudoScope(scopeType: ScopeType): boolean { +export function isPseudoScopeType(scopeType: ScopeType): boolean { return ( isSimpleScopeType(scopeType) && pseudoScopeTypeTypes.has(scopeType.type) ); diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts index 7fd0eaebf0..5769ea0d53 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts @@ -1,5 +1,8 @@ import type { IDE, ScopeType } from "@cursorless/lib-common"; -import { isPseudoScope, UnsupportedScopeError } from "@cursorless/lib-common"; +import { + isPseudoScopeType, + UnsupportedScopeError, +} from "@cursorless/lib-common"; import type { LanguageDefinitions } from "../../../languages/LanguageDefinitions"; import { BoundedNonWhitespaceSequenceScopeHandler, @@ -139,7 +142,7 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory { return ConditionalScopeHandler.maybeCreate(this, scopeType, languageId); default: // Pseudoscopes are handled separately in their own modifiers. - if (isPseudoScope(scopeType)) { + if (isPseudoScopeType(scopeType)) { throw new Error(`Unexpected pseudo scope type '${scopeType.type}'`); } return this.languageDefinitions diff --git a/packages/lib-engine/src/scopeProviders/ScopeInfoProvider.ts b/packages/lib-engine/src/scopeProviders/ScopeInfoProvider.ts index a10fd436e4..55709e15ca 100644 --- a/packages/lib-engine/src/scopeProviders/ScopeInfoProvider.ts +++ b/packages/lib-engine/src/scopeProviders/ScopeInfoProvider.ts @@ -7,7 +7,7 @@ import type { SurroundingPairScopeType, } from "@cursorless/lib-common"; import { - isPseudoScope, + isPseudoScopeType, simpleScopeTypeTypes, surroundingPairNames, } from "@cursorless/lib-common"; @@ -70,7 +70,7 @@ export class ScopeInfoProvider { // Create simple scope types from simple scope type types .map((scopeTypeType) => ({ type: scopeTypeType })) // Ignore pseudo-scope because it's not really a scope - .filter((scopeType) => !isPseudoScope(scopeType)), + .filter((scopeType) => !isPseudoScopeType(scopeType)), ...surroundingPairNames.map( (surroundingPairName): SurroundingPairScopeType => ({ From b236ecc5422a2a60a3e13021d23f67d80234b857 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 7 Jul 2026 11:08:41 +0200 Subject: [PATCH 4/4] name fix --- packages/app-vscode/src/createScopeVisualizer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app-vscode/src/createScopeVisualizer.ts b/packages/app-vscode/src/createScopeVisualizer.ts index d5d788aea1..f953393910 100644 --- a/packages/app-vscode/src/createScopeVisualizer.ts +++ b/packages/app-vscode/src/createScopeVisualizer.ts @@ -5,7 +5,7 @@ import type { ScopeProvider, ScopeType, } from "@cursorless/lib-common"; -import { isPseudoScope } from "@cursorless/lib-common"; +import { isPseudoScopeType } from "@cursorless/lib-common"; import type { VscodeScopeVisualizer } from "./ide/vscode/VSCodeScopeVisualizer"; import { createVscodeScopeVisualizer } from "./ide/vscode/VSCodeScopeVisualizer"; import type { @@ -25,7 +25,7 @@ export function createScopeVisualizer( return { start(scopeType: ScopeType, visualizationType: VisualizationType) { - if (isPseudoScope(scopeType)) { + if (isPseudoScopeType(scopeType)) { throw new Error( `Can't visualize pseudo scopes like '${scopeType.type}'`, );