chore: move quick pick instantiation (#1723)
This commit is contained in:
parent
21d1b0c16d
commit
7182bc75ac
3 changed files with 26 additions and 19 deletions
|
|
@ -169,6 +169,7 @@ const commandsMap: (
|
|||
verticalDiffManager: VerticalPerLineDiffManager,
|
||||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
battery: Battery,
|
||||
quickEdit: QuickEdit,
|
||||
) => { [command: string]: (...args: any) => any } = (
|
||||
ide,
|
||||
extensionContext,
|
||||
|
|
@ -178,6 +179,7 @@ const commandsMap: (
|
|||
verticalDiffManager,
|
||||
continueServerClientPromise,
|
||||
battery,
|
||||
quickEdit,
|
||||
) => {
|
||||
/**
|
||||
* Streams an inline edit to the vertical diff manager.
|
||||
|
|
@ -346,17 +348,6 @@ const commandsMap: (
|
|||
},
|
||||
"continue.quickEdit": async (initialPrompt?: string) => {
|
||||
captureCommandTelemetry("quickEdit");
|
||||
|
||||
const config = await configHandler.loadConfig();
|
||||
|
||||
const quickEdit = new QuickEdit(
|
||||
verticalDiffManager,
|
||||
config,
|
||||
sidebar.webviewProtocol,
|
||||
ide,
|
||||
extensionContext,
|
||||
);
|
||||
|
||||
quickEdit.show(initialPrompt);
|
||||
},
|
||||
"continue.writeCommentsForCode": async () => {
|
||||
|
|
@ -693,6 +684,7 @@ export function registerAllCommands(
|
|||
verticalDiffManager: VerticalPerLineDiffManager,
|
||||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
battery: Battery,
|
||||
quickEdit: QuickEdit,
|
||||
) {
|
||||
for (const [command, callback] of Object.entries(
|
||||
commandsMap(
|
||||
|
|
@ -704,6 +696,7 @@ export function registerAllCommands(
|
|||
verticalDiffManager,
|
||||
continueServerClientPromise,
|
||||
battery,
|
||||
quickEdit,
|
||||
),
|
||||
)) {
|
||||
context.subscriptions.push(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import { Battery } from "../util/battery";
|
|||
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
import { QuickEdit } from "../quickEdit/QuickEditQuickPick";
|
||||
|
||||
export class VsCodeExtension {
|
||||
// Currently some of these are public so they can be used in testing (test/test-suites)
|
||||
|
|
@ -54,8 +55,6 @@ export class VsCodeExtension {
|
|||
this.extensionContext = context;
|
||||
this.windowId = uuidv4();
|
||||
|
||||
const ideSettings = this.ide.getIdeSettingsSync();
|
||||
|
||||
// Dependencies of core
|
||||
let resolveVerticalDiffManager: any = undefined;
|
||||
const verticalDiffManagerPromise = new Promise<VerticalPerLineDiffManager>(
|
||||
|
|
@ -177,6 +176,14 @@ export class VsCodeExtension {
|
|||
context.subscriptions.push(this.battery);
|
||||
context.subscriptions.push(monitorBatteryChanges(this.battery));
|
||||
|
||||
const quickEdit = new QuickEdit(
|
||||
this.verticalDiffManager,
|
||||
this.configHandler,
|
||||
this.sidebar.webviewProtocol,
|
||||
this.ide,
|
||||
context,
|
||||
);
|
||||
|
||||
// Commands
|
||||
registerAllCommands(
|
||||
context,
|
||||
|
|
@ -188,6 +195,7 @@ export class VsCodeExtension {
|
|||
this.verticalDiffManager,
|
||||
this.core.continueServerClientPromise,
|
||||
this.battery,
|
||||
quickEdit,
|
||||
);
|
||||
|
||||
registerDebugTracker(this.sidebar.webviewProtocol, this.ide);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { ContinueConfig, IDE } from "core";
|
||||
import { IDE } from "core";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
|
@ -11,6 +11,7 @@ import { getModelQuickPickVal } from "./ModelSelectionQuickPick";
|
|||
|
||||
// @ts-ignore - error finding typings
|
||||
import MiniSearch from "minisearch";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
|
||||
/**
|
||||
* Used to track what action to take after a user interacts
|
||||
|
|
@ -71,7 +72,7 @@ export class QuickEdit {
|
|||
|
||||
constructor(
|
||||
private readonly verticalDiffManager: VerticalPerLineDiffManager,
|
||||
private readonly config: ContinueConfig,
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
private readonly ide: IDE,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
|
|
@ -108,16 +109,18 @@ export class QuickEdit {
|
|||
* Gets the model title the user has chosen, or their default model
|
||||
*/
|
||||
private async _getCurModelTitle() {
|
||||
const config = await this.configHandler.loadConfig();
|
||||
|
||||
if (this._curModelTitle) {
|
||||
return this._curModelTitle;
|
||||
}
|
||||
|
||||
let defaultModelTitle =
|
||||
this.config.experimental?.modelRoles?.inlineEdit ??
|
||||
config.experimental?.modelRoles?.inlineEdit ??
|
||||
(await this.webviewProtocol.request("getDefaultModelTitle", undefined));
|
||||
|
||||
if (!defaultModelTitle) {
|
||||
defaultModelTitle = this.config.models[0]?.title!;
|
||||
defaultModelTitle = config.models[0]?.title!;
|
||||
}
|
||||
|
||||
return defaultModelTitle;
|
||||
|
|
@ -345,6 +348,8 @@ export class QuickEdit {
|
|||
* Appends the entered prompt to the history and streams the edit with input and context.
|
||||
*/
|
||||
async show(initialPrompt?: string) {
|
||||
const config = await this.configHandler.loadConfig();
|
||||
|
||||
const selectedLabelOrInputVal = await this._getInitialQuickPickVal(
|
||||
initialPrompt,
|
||||
);
|
||||
|
|
@ -363,7 +368,7 @@ export class QuickEdit {
|
|||
|
||||
case QuickEditInitialItemLabels.ContextProviders:
|
||||
const contextProviderVal = await getContextProviderQuickPickVal(
|
||||
this.config,
|
||||
config,
|
||||
this.ide,
|
||||
);
|
||||
this.contextProviderStr = contextProviderVal ?? "";
|
||||
|
|
@ -375,9 +380,10 @@ export class QuickEdit {
|
|||
|
||||
case QuickEditInitialItemLabels.Model:
|
||||
const curModelTitle = await this._getCurModelTitle();
|
||||
|
||||
const selectedModelTitle = await getModelQuickPickVal(
|
||||
curModelTitle,
|
||||
this.config,
|
||||
config,
|
||||
);
|
||||
|
||||
if (selectedModelTitle) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue