Skip to content

Commit 4467c47

Browse files
Show error message when show scope visualizer is called without arguments (#3094)
1 parent 7d87503 commit 4467c47

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

packages/common/src/cursorlessCommandIds.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export const cursorlessCommandDescriptions: Record<
9595
["cursorless.showInstallationDependencies"]: new VisibleCommand(
9696
"Show installation dependencies",
9797
),
98+
// showScopeVisualizer can't be called from the command palatte because it
99+
// requires an argument, but it still needs to be visible or the scope buttons
100+
// will be disabled in the sidebar
98101
["cursorless.showScopeVisualizer"]: new VisibleCommand(
99102
"Show the scope visualizer",
100103
),

packages/common/src/util/disposableFrom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import type { Disposable } from "../ide/types/ide.types";
99
export function disposableFrom(...disposables: Disposable[]): Disposable {
1010
return {
1111
dispose(): void {
12-
disposables.forEach(({ dispose }) => {
12+
disposables.forEach((disposable) => {
1313
try {
14-
dispose();
14+
disposable.dispose();
1515
} catch (e) {
1616
// just log, but don't throw; some of the VSCode disposables misbehave,
1717
// and we don't want that to prevent us from disposing the rest of the

packages/cursorless-vscode/src/registerCommands.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {
22
CommandHistoryStorage,
33
CursorlessCommandId,
4+
ScopeType,
45
} from "@cursorless/common";
56
import { CURSORLESS_COMMAND_ID } from "@cursorless/common";
67
import {
@@ -18,7 +19,10 @@ import type {
1819
} from "@cursorless/test-case-recorder";
1920
import * as vscode from "vscode";
2021
import type { InstallationDependencies } from "./InstallationDependencies";
21-
import type { ScopeVisualizer } from "./ScopeVisualizerCommandApi";
22+
import type {
23+
ScopeVisualizer,
24+
VisualizationType,
25+
} from "./ScopeVisualizerCommandApi";
2226
import type { VscodeSnippets } from "./VscodeSnippets";
2327
import type { VscodeTutorial } from "./VscodeTutorial";
2428
import {
@@ -102,7 +106,15 @@ export function registerCommands(
102106
["cursorless.recomputeDecorationStyles"]: hats.recomputeDecorationStyles,
103107

104108
// Scope visualizer
105-
["cursorless.showScopeVisualizer"]: scopeVisualizer.start,
109+
["cursorless.showScopeVisualizer"]: (
110+
scopeType?: ScopeType,
111+
visualizationType?: VisualizationType,
112+
) => {
113+
if (scopeType == null || visualizationType == null) {
114+
throw new Error("Missing arguments. Only for internal use.");
115+
}
116+
scopeVisualizer.start(scopeType, visualizationType);
117+
},
106118
["cursorless.hideScopeVisualizer"]: scopeVisualizer.stop,
107119
["cursorless.scopeVisualizer.openUrl"]:
108120
showScopeVisualizerItemDocumentation,

0 commit comments

Comments
 (0)