From 6565a72d1c6edc83c9d7c320d4ab105fa1cdb394 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 31 Aug 2026 09:46:54 +0200 Subject: [PATCH] Remove deprecated code --- cursorless-talon/src/actions/actions.py | 4 + packages/app-vscode/src/createVscodeIde.ts | 2 - .../src/ide/vscode/VscodeKeyValueStore.ts | 2 - .../src/ide/vscode/hats/VscodeHatRenderer.ts | 20 +-- .../src/ide/vscode/hats/VscodeHats.ts | 6 +- .../hats/performPr1868ShapeUpdateInit.ts | 116 ------------------ .../app-vscode/src/keyboard/KeyboardConfig.ts | 25 +--- 7 files changed, 7 insertions(+), 168 deletions(-) delete mode 100644 packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts diff --git a/cursorless-talon/src/actions/actions.py b/cursorless-talon/src/actions/actions.py index deb21a699e8..6364b73e209 100644 --- a/cursorless-talon/src/actions/actions.py +++ b/cursorless-talon/src/actions/actions.py @@ -117,6 +117,10 @@ def cursorless_vscode_command(command_id: str, target: CursorlessTarget): Deprecated: prefer `cursorless_ide_command` """ + # Deprecated 2026-08-31 + actions.app.notify( + "Deprecated: cursorless_vscode_command is deprecated, prefer cursorless_ide_command" + ) return actions.user.cursorless_ide_command(command_id, target) @staticmethod diff --git a/packages/app-vscode/src/createVscodeIde.ts b/packages/app-vscode/src/createVscodeIde.ts index 9fb8f90f5bd..40673812592 100644 --- a/packages/app-vscode/src/createVscodeIde.ts +++ b/packages/app-vscode/src/createVscodeIde.ts @@ -7,14 +7,12 @@ import { FontMeasurementsImpl } from "./ide/vscode/hats/FontMeasurementsImpl"; import { VscodeHats } from "./ide/vscode/hats/VscodeHats"; import { VscodeFileSystem } from "./ide/vscode/VscodeFileSystem"; import { VscodeIDE } from "./ide/vscode/VscodeIDE"; -import { vscodeApi } from "./vscodeApi"; export async function createVscodeIde(context: ExtensionContext) { const vscodeIDE = new VscodeIDE(context); const hats = new VscodeHats( vscodeIDE, - vscodeApi, context, vscodeIDE.runMode === "test" ? new FakeFontMeasurements() diff --git a/packages/app-vscode/src/ide/vscode/VscodeKeyValueStore.ts b/packages/app-vscode/src/ide/vscode/VscodeKeyValueStore.ts index 74f38aa20ea..9fc4154b286 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeKeyValueStore.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeKeyValueStore.ts @@ -7,7 +7,6 @@ import type { import { KEY_VALUE_STORE_DEFAULTS } from "@cursorless/lib-common"; import { VERSION_KEY } from "../../ReleaseNotes"; import { DONT_SHOW_TALON_UPDATE_MESSAGE_KEY } from "../../ScopeTreeProvider"; -import { PERFORMED_PR_1868_SHAPE_UPDATE_INIT_KEY } from "./hats/performPr1868ShapeUpdateInit"; export class VscodeKeyValueStore implements KeyValueStore { constructor(private extensionContext: ExtensionContext) { @@ -15,7 +14,6 @@ export class VscodeKeyValueStore implements KeyValueStore { extensionContext.globalState.setKeysForSync([ ...Object.keys(KEY_VALUE_STORE_DEFAULTS), VERSION_KEY, - PERFORMED_PR_1868_SHAPE_UPDATE_INIT_KEY, DONT_SHOW_TALON_UPDATE_MESSAGE_KEY, ]); } diff --git a/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts b/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts index 5116c5786b1..61af7108c22 100644 --- a/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts +++ b/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts @@ -2,14 +2,9 @@ import fs from "node:fs/promises"; import path from "node:path"; import { isEqual } from "lodash-es"; import vscode from "vscode"; -import type { - Listener, - Messages, - PathChangeListener, -} from "@cursorless/lib-common"; +import type { Listener, PathChangeListener } from "@cursorless/lib-common"; import { getErrorMessage, Notifier } from "@cursorless/lib-common"; import { walkFiles } from "@cursorless/lib-node-common"; -import type { VscodeApi } from "@cursorless/lib-vscode-common"; import type { HatShape, VscodeHatStyleName } from "../hatStyles.types"; import { HAT_SHAPES } from "../hatStyles.types"; import { vscodeGetConfigurationString } from "../VscodeConfiguration"; @@ -19,7 +14,6 @@ import type { } from "../VscodeEnabledHatStyleManager"; import type { FontMeasurements } from "./FontMeasurements"; import { getHatThemeColors } from "./getHatThemeColors"; -import { performPr1868ShapeUpdateInit } from "./performPr1868ShapeUpdateInit"; import type { IndividualHatAdjustmentMap } from "./shapeAdjustments"; import { DEFAULT_HAT_HEIGHT_EM, @@ -72,9 +66,7 @@ export class VscodeHatRenderer { private decoder = new TextDecoder("utf-8"); constructor( - private vscodeApi: VscodeApi, private extensionContext: vscode.ExtensionContext, - private messages: Messages, private enabledHatStyles: VscodeEnabledHatStyleManager, private fontMeasurements: FontMeasurements, ) { @@ -206,16 +198,6 @@ export class VscodeHatRenderer { .getConfiguration("cursorless") .get("individualHatAdjustments")!; - void performPr1868ShapeUpdateInit( - this.extensionContext, - this.vscodeApi, - this.messages, - this.enabledHatStyles.hatStyleMap, - userSizeAdjustment, - userVerticalOffset, - userIndividualAdjustments, - ); - const hatSvgMap = Object.fromEntries( await Promise.all( HAT_SHAPES.map(async (shape) => { diff --git a/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts b/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts index 51f244f0001..445f7548328 100644 --- a/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts +++ b/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts @@ -1,5 +1,5 @@ -import vscode from "vscode"; import type { Disposable } from "vscode"; +import vscode from "vscode"; import type { HatRange, Hats, @@ -10,7 +10,6 @@ import type { TextEditor, } from "@cursorless/lib-common"; import { Notifier } from "@cursorless/lib-common"; -import type { VscodeApi } from "@cursorless/lib-vscode-common"; import { toVscodeRange } from "@cursorless/lib-vscode-common"; import type { VscodeHatStyleName } from "../hatStyles.types"; import { VscodeEnabledHatStyleManager } from "../VscodeEnabledHatStyleManager"; @@ -28,7 +27,6 @@ export class VscodeHats implements Hats { constructor( private ide: VscodeIDE, - vscodeApi: VscodeApi, extensionContext: vscode.ExtensionContext, fontMeasurements: FontMeasurements, ) { @@ -36,9 +34,7 @@ export class VscodeHats implements Hats { extensionContext, ); this.hatRenderer = new VscodeHatRenderer( - vscodeApi, extensionContext, - ide.messages, this.enabledHatStyleManager, fontMeasurements, ); diff --git a/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts b/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts deleted file mode 100644 index 570fe99a51f..00000000000 --- a/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts +++ /dev/null @@ -1,116 +0,0 @@ -import vscode from "vscode"; -import type { Messages } from "@cursorless/lib-common"; -import { showInfo } from "@cursorless/lib-common"; -import type { VscodeApi } from "@cursorless/lib-vscode-common"; -import type { ExtendedHatStyleMap } from "../VscodeEnabledHatStyleManager"; -import type { IndividualHatAdjustmentMap } from "./shapeAdjustments"; - -/** - * We set this key in global state the first time they user gets the new shapes from #1868. We use this to - * determine whether or not to show them messages about resetting their hat adjustments. - */ -export const PERFORMED_PR_1868_SHAPE_UPDATE_INIT_KEY = - "performedPr1868ShapeUpdateInit"; - -/** - * If this is the first time the user has gotten the new shapes from #1868, we - * show them a message about resetting their hat adjustments if they have done - * any customization. - * - * We can probably remove this after a while. - */ -export async function performPr1868ShapeUpdateInit( - extensionContext: vscode.ExtensionContext, - vscodeApi: VscodeApi, - messages: Messages, - hatStyleMap: ExtendedHatStyleMap, - userSizeAdjustment: number, - userVerticalOffset: number, - userIndividualAdjustments: IndividualHatAdjustmentMap, -) { - if ( - // Only show in focused window - !vscodeApi.window.state.focused || - // Only run on initial update to new hat shapes - extensionContext.globalState.get( - PERFORMED_PR_1868_SHAPE_UPDATE_INIT_KEY, - ) - ) { - return; - } - - // Whether or not we end up showing anything, we don't want to show this - // message after the first time they get the new hats. If they make adjustments - // in the future, they've done so with the new hats in mind. - await extensionContext.globalState.update( - PERFORMED_PR_1868_SHAPE_UPDATE_INIT_KEY, - true, - ); - - let shownMessage = false; - - // If they have any individual adjustments, we should tell them to reset them - if ( - Object.values(userIndividualAdjustments) - .flatMap((entry) => Object.values(entry)) - .some((value) => value != null && value !== 0) - ) { - shownMessage = true; - const PERFORM_RESET = "Perform reset"; - const TAKE_ME_THERE = "Take me there"; - const result = await showInfo( - messages, - "maybeUpdateIndividualHatSettings", - "The hat shapes have been updated; you probably want to reset your individual hat adjustments.", - PERFORM_RESET, - TAKE_ME_THERE, - ); - - if (result === TAKE_ME_THERE) { - await vscode.commands.executeCommand( - "workbench.action.openSettingsJson", - { - revealSetting: { key: "cursorless.individualHatAdjustments" }, - }, - ); - } else if (result === PERFORM_RESET) { - await vscode.workspace - .getConfiguration("cursorless") - .update("individualHatAdjustments", undefined, true); - } - } - - // If they have any global adjustments, they may want to tweak them - if ( - (userSizeAdjustment !== 0 || userVerticalOffset !== 0) && - // Don't bother if they have no shapes enabled, as the default shape - // is similar enough in size / offset to the old default shape - hasAnyShapesEnabled(hatStyleMap) - ) { - const TAKE_ME_THERE = "Take me there"; - const message = shownMessage - ? "You may also want to tweak your global hat settings." - : "The hat shapes have been updated; you may want to tweak your hat settings."; - - const result = await showInfo( - messages, - "maybeUpdateGlobalHatSettings", - message, - TAKE_ME_THERE, - ); - - if (result === TAKE_ME_THERE) { - await vscode.commands.executeCommand( - "workbench.action.openSettings", - `@ext:${extensionContext.extension.id}`, - ); - } - } -} - -function hasAnyShapesEnabled(hatStyleMap: ExtendedHatStyleMap) { - // A bit of a hack, but if they have any shapes enabled, they'll have keys - // like `blue-fox`, which contain a `-`. If they don't have any shapes - // enabled, they'll only have keys like `blue`, `default, etc. - return Object.keys(hatStyleMap).some((key) => key.includes("-")); -} diff --git a/packages/app-vscode/src/keyboard/KeyboardConfig.ts b/packages/app-vscode/src/keyboard/KeyboardConfig.ts index 10ecee0ab2d..b13598a1682 100644 --- a/packages/app-vscode/src/keyboard/KeyboardConfig.ts +++ b/packages/app-vscode/src/keyboard/KeyboardConfig.ts @@ -4,14 +4,6 @@ import type { VscodeApi } from "@cursorless/lib-vscode-common"; import type { KeyMap, SectionName, TokenType } from "./TokenTypeHelpers"; import type { SectionTypes, TokenTypeValueMap } from "./TokenTypes"; -const LEGACY_PLURAL_SECTION_NAMES: Record = { - action: "actions", - color: "colors", - shape: "shapes", - vscodeCommand: "vscodeCommands", - scope: "scopes", -}; - /** * Maps from the raw cursor style config value to the corresponding * TextEditorCursorStyle enum value. @@ -56,22 +48,7 @@ export class KeyboardConfig { .getConfiguration("cursorless.experimental.keyboard.modal.keybindings") .get>(sectionName); - let section = getSection(sectionName); - - if (section == null || Object.keys(section).length === 0) { - const legacySectionName = LEGACY_PLURAL_SECTION_NAMES[sectionName]; - - if (legacySectionName != null) { - section = getSection(legacySectionName); - if (section != null && Object.keys(section).length > 0) { - void this.vscodeApi.window.showWarningMessage( - `The config section "cursorless.experimental.keyboard.modal.keybindings.${legacySectionName}" is deprecated. Please rename it to "cursorless.experimental.keyboard.modal.keybindings.${sectionName}".`, - ); - } - } - } - - return section ?? {}; + return getSection(sectionName) ?? {}; } /**