consolidate logic
This commit is contained in:
parent
ba777edf47
commit
7ab7bb3040
6 changed files with 21 additions and 30 deletions
|
|
@ -176,7 +176,7 @@ export class Core {
|
|||
message: err.message,
|
||||
stack: err.stack,
|
||||
});
|
||||
this.messenger.request("showToast", ["error", err.message]);
|
||||
this.ide.showToast("error", err.message);
|
||||
});
|
||||
|
||||
// New
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import * as vscode from "vscode";
|
|||
import { executeGotoProvider } from "./autocomplete/lsp";
|
||||
import { DiffManager } from "./diff/horizontal";
|
||||
import { Repository } from "./otherExtensions/git";
|
||||
import { TOAST_FN_BY_TYPE, VsCodeIdeUtils } from "./util/ideUtils";
|
||||
import { VsCodeIdeUtils } from "./util/ideUtils";
|
||||
import {
|
||||
getExtensionUri,
|
||||
openEditorAndRevealRange,
|
||||
|
|
@ -195,8 +195,21 @@ class VsCodeIde implements IDE {
|
|||
|
||||
showToast: IDE["showToast"] = async (...params) => {
|
||||
const [type, message, ...otherParams] = params;
|
||||
const toastFn = TOAST_FN_BY_TYPE[type];
|
||||
return toastFn(message, ...otherParams);
|
||||
const { showErrorMessage, showWarningMessage, showInformationMessage } =
|
||||
vscode.window;
|
||||
|
||||
switch (type) {
|
||||
case "error":
|
||||
return showErrorMessage(message, "Show logs").then((selection) => {
|
||||
if (selection === "Show logs") {
|
||||
vscode.commands.executeCommand("workbench.action.toggleDevTools");
|
||||
}
|
||||
});
|
||||
case "info":
|
||||
return showInformationMessage(message, ...otherParams);
|
||||
case "warning":
|
||||
return showWarningMessage(message, ...otherParams);
|
||||
}
|
||||
};
|
||||
|
||||
async getRepoName(dir: string): Promise<string | undefined> {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import * as vscode from "vscode";
|
||||
import type { VsCodeIde } from "../ideProtocol";
|
||||
import type { VsCodeIde } from "../VsCodeIde";
|
||||
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
export const threadStopped: Map<number, boolean> = new Map();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvide
|
|||
import { registerDebugTracker } from "../debug/debug";
|
||||
import { DiffManager } from "../diff/horizontal";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeIde } from "../ideProtocol";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { registerAllCodeLensProviders } from "../lang-server/codeLens";
|
||||
import { QuickEdit } from "../quickEdit/QuickEditQuickPick";
|
||||
import { setupRemoteConfigSync } from "../stubs/activation";
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import * as fs from "node:fs";
|
|||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeIde } from "../ideProtocol";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import {
|
||||
getControlPlaneSessionInfo,
|
||||
WorkOsAuthProvider,
|
||||
|
|
@ -284,18 +284,7 @@ export class VsCodeMessenger {
|
|||
return ide.showLines(filepath, startLine, endLine);
|
||||
});
|
||||
this.onWebviewOrCore("showToast", (msg) => {
|
||||
const [type, message, ...otherParams] = msg.data;
|
||||
const toastFn = TOAST_FN_BY_TYPE[type];
|
||||
|
||||
if (type === "error") {
|
||||
toastFn(message, "Show Logs").then((selection) => {
|
||||
if (selection === "Show Logs") {
|
||||
vscode.commands.executeCommand("workbench.action.toggleDevTools");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastFn(message, ...otherParams);
|
||||
}
|
||||
this.ide.showToast(...msg.data);
|
||||
});
|
||||
this.onWebviewOrCore("getGitHubAuthToken", (msg) =>
|
||||
ide.getGitHubAuthToken(),
|
||||
|
|
|
|||
|
|
@ -651,14 +651,3 @@ export class VsCodeIdeUtils {
|
|||
return rangeInFiles;
|
||||
}
|
||||
}
|
||||
|
||||
export const TOAST_FN_BY_TYPE: {
|
||||
[type in ToastType]:
|
||||
| typeof vscode.window.showInformationMessage
|
||||
| typeof vscode.window.showWarningMessage
|
||||
| typeof vscode.window.showInformationMessage;
|
||||
} = {
|
||||
info: vscode.window.showInformationMessage,
|
||||
warning: vscode.window.showWarningMessage,
|
||||
error: vscode.window.showErrorMessage,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue