Skip to content

Commit e051b05

Browse files
authored
Remove remaining vscode references (#1248)
1 parent a0ee7a6 commit e051b05

27 files changed

+114
-77
lines changed

src/actions/Find.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { showWarning } from "@cursorless/common";
12
import ide from "../libs/cursorless-engine/singletons/ide.singleton";
23
import { Target } from "../typings/target.types";
34
import { Graph } from "../typings/Types";
@@ -20,7 +21,8 @@ export class FindInWorkspace implements Action {
2021
let query: string;
2122
if (text.length > 200) {
2223
query = text.substring(0, 200);
23-
ide().messages.showWarning(
24+
showWarning(
25+
ide().messages,
2426
"truncatedSearchText",
2527
"Search text is longer than 200 characters; truncating",
2628
);

src/core/Snippets.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { showError } from "@cursorless/common";
12
import { readFile, stat } from "fs/promises";
23
import { cloneDeep, max, merge } from "lodash";
34
import { join } from "path";
4-
import { window } from "vscode";
55
import ide from "../libs/cursorless-engine/singletons/ide.singleton";
66
import { walkFiles } from "../testUtil/walkAsync";
77
import { Snippet, SnippetMap } from "../typings/snippet";
@@ -128,7 +128,7 @@ export class Snippets {
128128
this.userSnippetsDir
129129
}": ${(err as Error).message}`;
130130

131-
window.showErrorMessage(errorMessage);
131+
showError(ide().messages, "snippetsDirError", errorMessage);
132132

133133
this.directoryErrorMessage = {
134134
directory: this.userSnippetsDir!,
@@ -170,7 +170,9 @@ export class Snippets {
170170

171171
return JSON.parse(content);
172172
} catch (err) {
173-
window.showErrorMessage(
173+
showError(
174+
ide().messages,
175+
"snippetsFileError",
174176
`Error with cursorless snippets file "${path}": ${
175177
(err as Error).message
176178
}`,

src/core/commandVersionUpgrades/canonicalizeAndValidateCommand.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { upgradeV0ToV1 } from "./upgradeV0ToV1";
2121
import { upgradeV1ToV2 } from "./upgradeV1ToV2";
2222
import { upgradeV2ToV3 } from "./upgradeV2ToV3";
2323
import { upgradeV3ToV4 } from "./upgradeV3ToV4";
24+
import { showWarning } from "@cursorless/common";
2425

2526
/**
2627
* Given a command argument which comes from the client, normalize it so that it
@@ -135,7 +136,8 @@ export async function checkForOldInference(
135136
const hideInferenceWarning = globalState.get("hideInferenceWarning");
136137

137138
if (!hideInferenceWarning) {
138-
const pressed = await messages.showWarning(
139+
const pressed = await showWarning(
140+
messages,
139141
"deprecatedPositionInference",
140142
'The "past start of" / "past end of" form has changed behavior. For the old behavior, update cursorless-talon (https://www.cursorless.org/docs/user/updating/), and then you can now say "past start of its" / "past end of its". For example, "take air past end of its line". You may also consider using "head" / "tail" instead; see https://www.cursorless.org/docs/#head-and-tail',
141143
"Don't show again",

src/ide/vscode/VscodeFocusEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88
window,
99
} from "vscode";
1010
import { getCellIndex } from "../../libs/vscode-common/notebook";
11-
import { getNotebookFromCellDocument } from "../../util/notebook";
11+
import { getNotebookFromCellDocument } from "./notebook/notebook";
1212
import {
1313
focusNotebookCellLegacy,
1414
isVscodeLegacyNotebookVersion,
15-
} from "../../util/notebookLegacy";
15+
} from "./notebook/notebookLegacy";
1616
import type VscodeIDE from "./VscodeIDE";
1717
import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl";
1818

src/ide/vscode/VscodeMessages.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import { window } from "vscode";
2-
import { MessageId, Messages } from "../../libs/common/ide/types/Messages";
2+
import {
3+
MessageId,
4+
Messages,
5+
MessageType,
6+
} from "../../libs/common/ide/types/Messages";
37

48
export default class VscodeMessages implements Messages {
5-
async showWarning(
9+
async showMessage(
10+
type: MessageType,
611
_id: MessageId,
712
message: string,
813
...options: string[]
914
): Promise<string | undefined> {
10-
return await window.showWarningMessage(message, ...options);
15+
switch (type) {
16+
case MessageType.info:
17+
return await window.showInformationMessage(message, ...options);
18+
case MessageType.warning:
19+
return await window.showWarningMessage(message, ...options);
20+
case MessageType.error:
21+
return await window.showErrorMessage(message, ...options);
22+
}
1123
}
1224
}

src/ide/vscode/VscodeNotebooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Selection } from "@cursorless/common";
22
import * as vscode from "vscode";
3-
import { getNotebookFromCellDocument } from "../../util/notebook";
3+
import { getNotebookFromCellDocument } from "./notebook/notebook";
44
import { VscodeTextEditorImpl } from "./VscodeTextEditorImpl";
55

66
export async function vscodeEditNewNotebookCellAbove(

src/ide/vscode/hats/VscodeHatRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { readFileSync } from "fs";
22
import { cloneDeep, isEqual } from "lodash";
33
import { join } from "path";
44
import * as vscode from "vscode";
5-
import getHatThemeColors from "../../../core/getHatThemeColors";
5+
import getHatThemeColors from "./getHatThemeColors";
66
import {
77
defaultShapeAdjustments,
88
DEFAULT_HAT_HEIGHT_EM,
99
DEFAULT_VERTICAL_OFFSET_EM,
1010
IndividualHatAdjustmentMap,
11-
} from "../../../core/shapeAdjustments";
11+
} from "./shapeAdjustments";
1212
import { Listener, Notifier } from "../../../libs/common/util/Notifier";
1313
import FontMeasurements from "./FontMeasurements";
1414
import { HatShape, HAT_SHAPES, VscodeHatStyleName } from "../hatStyles.types";

src/core/getHatThemeColors.ts renamed to src/ide/vscode/hats/getHatThemeColors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from "vscode";
2-
import { HatColor } from "../ide/vscode/hatStyles.types";
2+
import { HatColor } from "../hatStyles.types";
33

44
interface OldDecorationColorSetting {
55
dark: string;

src/core/getStyleName.ts renamed to src/ide/vscode/hats/getStyleName.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
HatColor,
3-
HatShape,
4-
VscodeHatStyleName,
5-
} from "../ide/vscode/hatStyles.types";
1+
import { HatColor, HatShape, VscodeHatStyleName } from "../hatStyles.types";
62

73
export function getStyleName(
84
color: HatColor,

src/core/shapeAdjustments.ts renamed to src/ide/vscode/hats/shapeAdjustments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HatShape } from "../ide/vscode/hatStyles.types";
1+
import { HatShape } from "../hatStyles.types";
22

33
export interface HatAdjustments {
44
sizeAdjustment?: number;

0 commit comments

Comments
 (0)