Merge branch 'feature/nextEdit' of github.com:continuedev/continue into jacob/feature/next-edit-mvp
This commit is contained in:
commit
7d1c5b09a3
5 changed files with 70 additions and 31 deletions
43
core/core.ts
43
core/core.ts
|
|
@ -729,31 +729,30 @@ export class Core {
|
|||
contextSize: 5,
|
||||
};
|
||||
|
||||
if (!global._editAggregator) {
|
||||
global._editAggregator = new EditAggregator(
|
||||
EDIT_AGGREGATION_OPTIONS,
|
||||
(
|
||||
beforeAfterdiff: BeforeAfterDiff,
|
||||
cursorPosBeforeEdit: Position,
|
||||
cursorPosAfterPrevEdit: Position,
|
||||
) => {
|
||||
void processSmallEdit(
|
||||
beforeAfterdiff,
|
||||
cursorPosBeforeEdit,
|
||||
cursorPosAfterPrevEdit,
|
||||
data.configHandler,
|
||||
data.getDefsFromLspFunction,
|
||||
this.ide,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
EditAggregator.getInstance(
|
||||
EDIT_AGGREGATION_OPTIONS,
|
||||
(
|
||||
beforeAfterdiff: BeforeAfterDiff,
|
||||
cursorPosBeforeEdit: Position,
|
||||
cursorPosAfterPrevEdit: Position,
|
||||
) => {
|
||||
void processSmallEdit(
|
||||
beforeAfterdiff,
|
||||
cursorPosBeforeEdit,
|
||||
cursorPosAfterPrevEdit,
|
||||
data.configHandler,
|
||||
data.getDefsFromLspFunction,
|
||||
this.ide,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
const workspaceDir =
|
||||
data.actions.length > 0 ? data.actions[0].workspaceDir : undefined;
|
||||
|
||||
// Store the latest context data on the aggregator
|
||||
(global._editAggregator as any).latestContextData = {
|
||||
// Store the latest context data
|
||||
const instance = EditAggregator.getInstance();
|
||||
(instance as any).latestContextData = {
|
||||
configHandler: data.configHandler,
|
||||
getDefsFromLspFunction: data.getDefsFromLspFunction,
|
||||
recentlyEditedRanges: data.recentlyEditedRanges,
|
||||
|
|
@ -763,7 +762,7 @@ export class Core {
|
|||
|
||||
// queueMicrotask prevents blocking the UI thread during typing
|
||||
queueMicrotask(() => {
|
||||
void global._editAggregator.processEdits(data.actions);
|
||||
void EditAggregator.getInstance().processEdits(data.actions);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -28,8 +28,6 @@ declare global {
|
|||
messageIde: string,
|
||||
) => void;
|
||||
}
|
||||
|
||||
var _editAggregator: EditAggregator | undefined;
|
||||
}
|
||||
|
||||
export interface ChunkWithoutID {
|
||||
|
|
|
|||
|
|
@ -37,15 +37,56 @@ export interface EditClusterConfig {
|
|||
|
||||
export class EditAggregator {
|
||||
private fileStates: Map<string, FileState> = new Map();
|
||||
private config: EditClusterConfig;
|
||||
public config: EditClusterConfig;
|
||||
private previousEditFinalCursorPosition: Position;
|
||||
private lastProcessedFilePath: string | null = null;
|
||||
private onComparisonFinalized: (
|
||||
public onComparisonFinalized: (
|
||||
diff: BeforeAfterDiff,
|
||||
beforeCursorPos: Position,
|
||||
afterPrevEditCursorPos: Position,
|
||||
) => void;
|
||||
|
||||
private static _instance: EditAggregator | null = null;
|
||||
|
||||
public static getInstance(
|
||||
config?: Partial<EditClusterConfig>,
|
||||
onComparisonFinalized?: (
|
||||
diff: BeforeAfterDiff,
|
||||
beforeCursorPos: Position,
|
||||
afterPrevEditCursorPos: Position,
|
||||
) => void,
|
||||
): EditAggregator {
|
||||
// Create instance if it doesn't exist
|
||||
if (!EditAggregator._instance) {
|
||||
EditAggregator._instance = new EditAggregator(
|
||||
config,
|
||||
onComparisonFinalized,
|
||||
);
|
||||
}
|
||||
// Update instance if new parameters are provided
|
||||
else if (config || onComparisonFinalized) {
|
||||
if (config) {
|
||||
EditAggregator._instance.config = {
|
||||
deltaT: config.deltaT ?? EditAggregator._instance.config.deltaT,
|
||||
deltaL: config.deltaL ?? EditAggregator._instance.config.deltaL,
|
||||
maxEdits: config.maxEdits ?? EditAggregator._instance.config.maxEdits,
|
||||
maxDuration:
|
||||
config.maxDuration ?? EditAggregator._instance.config.maxDuration,
|
||||
contextSize:
|
||||
config.contextSize ?? EditAggregator._instance.config.contextSize,
|
||||
contextLines:
|
||||
config.contextLines ?? EditAggregator._instance.config.contextLines,
|
||||
};
|
||||
}
|
||||
|
||||
if (onComparisonFinalized) {
|
||||
EditAggregator._instance.onComparisonFinalized = onComparisonFinalized;
|
||||
}
|
||||
}
|
||||
|
||||
return EditAggregator._instance;
|
||||
}
|
||||
|
||||
constructor(
|
||||
config: Partial<EditClusterConfig> = {},
|
||||
onComparisonFinalized: (
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { ConfigHandler } from "../../config/ConfigHandler";
|
|||
import { DataLogger } from "../../data/log";
|
||||
import { RecentlyEditedRange } from "../types";
|
||||
import { getAutocompleteContext } from "./autocompleteContextFetching";
|
||||
import { createDiff, DiffFormatType } from "./diffFormatting";
|
||||
|
||||
const randomNumberBetween = (min: number, max: number) => {
|
||||
min = Math.ceil(min); // Ensure min is an integer
|
||||
|
|
@ -65,9 +64,9 @@ export const processNextEditData = async ({
|
|||
modelName,
|
||||
);
|
||||
|
||||
console.log(
|
||||
createDiff(beforeContent, afterContent, filePath, DiffFormatType.Unified),
|
||||
);
|
||||
// console.log(
|
||||
// createDiff(beforeContent, afterContent, filePath, DiffFormatType.Unified),
|
||||
// );
|
||||
|
||||
void DataLogger.getInstance().logDevData({
|
||||
name: "nextEdit",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { IDE, Position } from "../..";
|
|||
import { GetLspDefinitionsFunction } from "../../autocomplete/types";
|
||||
import { ConfigHandler } from "../../config/ConfigHandler";
|
||||
import { NextEditProvider } from "../NextEditProvider";
|
||||
import { EditAggregator } from "./aggregateEdits";
|
||||
import { BeforeAfterDiff, createDiff, DiffFormatType } from "./diffFormatting";
|
||||
import { processNextEditData } from "./processNextEditData";
|
||||
|
||||
|
|
@ -23,7 +24,8 @@ export const processSmallEdit = async (
|
|||
);
|
||||
|
||||
// Get the current context data from the most recent message
|
||||
const currentData = (global._editAggregator as any).latestContextData || {
|
||||
const currentData = (EditAggregator.getInstance() as any)
|
||||
.latestContextData || {
|
||||
configHandler: configHandler,
|
||||
getDefsFromLspFunction: getDefsFromLspFunction,
|
||||
recentlyEditedRanges: [],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue