diff --git a/packages/common/src/cursorlessCommandIds.ts b/packages/common/src/cursorlessCommandIds.ts index 51930a9e83..6a6dbc9a3e 100644 --- a/packages/common/src/cursorlessCommandIds.ts +++ b/packages/common/src/cursorlessCommandIds.ts @@ -95,6 +95,9 @@ export const cursorlessCommandDescriptions: Record< ["cursorless.showInstallationDependencies"]: new VisibleCommand( "Show installation dependencies", ), + // showScopeVisualizer can't be called from the command palatte because it + // requires an argument, but it still needs to be visible or the scope buttons + // will be disabled in the sidebar ["cursorless.showScopeVisualizer"]: new VisibleCommand( "Show the scope visualizer", ), diff --git a/packages/common/src/util/disposableFrom.ts b/packages/common/src/util/disposableFrom.ts index bf1a6cc422..62c2804567 100644 --- a/packages/common/src/util/disposableFrom.ts +++ b/packages/common/src/util/disposableFrom.ts @@ -9,9 +9,9 @@ import type { Disposable } from "../ide/types/ide.types"; export function disposableFrom(...disposables: Disposable[]): Disposable { return { dispose(): void { - disposables.forEach(({ dispose }) => { + disposables.forEach((disposable) => { try { - dispose(); + disposable.dispose(); } catch (e) { // just log, but don't throw; some of the VSCode disposables misbehave, // and we don't want that to prevent us from disposing the rest of the diff --git a/packages/cursorless-vscode/src/registerCommands.ts b/packages/cursorless-vscode/src/registerCommands.ts index 8e0a5f8c13..4f0c8d8e03 100644 --- a/packages/cursorless-vscode/src/registerCommands.ts +++ b/packages/cursorless-vscode/src/registerCommands.ts @@ -1,6 +1,7 @@ import type { CommandHistoryStorage, CursorlessCommandId, + ScopeType, } from "@cursorless/common"; import { CURSORLESS_COMMAND_ID } from "@cursorless/common"; import { @@ -18,7 +19,10 @@ import type { } from "@cursorless/test-case-recorder"; import * as vscode from "vscode"; import type { InstallationDependencies } from "./InstallationDependencies"; -import type { ScopeVisualizer } from "./ScopeVisualizerCommandApi"; +import type { + ScopeVisualizer, + VisualizationType, +} from "./ScopeVisualizerCommandApi"; import type { VscodeSnippets } from "./VscodeSnippets"; import type { VscodeTutorial } from "./VscodeTutorial"; import { @@ -102,7 +106,15 @@ export function registerCommands( ["cursorless.recomputeDecorationStyles"]: hats.recomputeDecorationStyles, // Scope visualizer - ["cursorless.showScopeVisualizer"]: scopeVisualizer.start, + ["cursorless.showScopeVisualizer"]: ( + scopeType?: ScopeType, + visualizationType?: VisualizationType, + ) => { + if (scopeType == null || visualizationType == null) { + throw new Error("Missing arguments. Only for internal use."); + } + scopeVisualizer.start(scopeType, visualizationType); + }, ["cursorless.hideScopeVisualizer"]: scopeVisualizer.stop, ["cursorless.scopeVisualizer.openUrl"]: showScopeVisualizerItemDocumentation,