continue-custom/core/nextEdit/context/processSmallEdit.ts
Nate Sesti f56d2b0a7b
fix: improvements to next edit (#8129)
* refactor: autocomplete feedback

* fix: don't hardcode outcome to false on aborted completion

* fix: correctly parse out backticks

* fix: correctly parse out backticks

* fix: next edit diff formatting

* fix: reduce context lines

* improv: track profile type for autocomplete

* fix: lint err

* fix: test
2025-10-08 13:09:50 -07:00

50 lines
1.9 KiB
TypeScript

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";
export const processSmallEdit = async (
beforeAfterdiff: BeforeAfterDiff,
cursorPosBeforeEdit: Position,
cursorPosAfterPrevEdit: Position,
configHandler: ConfigHandler,
getDefsFromLspFunction: GetLspDefinitionsFunction,
ide: IDE,
) => {
// Get the current context data from the most recent message
const currentData = (EditAggregator.getInstance() as any)
.latestContextData || {
configHandler: configHandler,
getDefsFromLspFunction: getDefsFromLspFunction,
recentlyEditedRanges: [],
recentlyVisitedRanges: [],
};
NextEditProvider.getInstance().addDiffToContext(
createDiff({
beforeContent: beforeAfterdiff.beforeContent,
afterContent: beforeAfterdiff.afterContent,
filePath: beforeAfterdiff.filePath,
diffType: DiffFormatType.Unified,
contextLines: 3, // NOTE: This can change depending on experiments!
workspaceDir: currentData.workspaceDir,
}),
);
void processNextEditData({
filePath: beforeAfterdiff.filePath,
beforeContent: beforeAfterdiff.beforeContent,
afterContent: beforeAfterdiff.afterContent,
cursorPosBeforeEdit: cursorPosBeforeEdit,
cursorPosAfterPrevEdit: cursorPosAfterPrevEdit,
ide: ide,
configHandler: currentData.configHandler,
getDefinitionsFromLsp: currentData.getDefsFromLspFunction,
recentlyEditedRanges: currentData.recentlyEditedRanges,
recentlyVisitedRanges: currentData.recentlyVisitedRanges,
workspaceDir: currentData.workspaceDir,
});
};