Elffuss BraidHub

kikocis/continue public

main · 1.8 KiBRawPermalink
1import { IDE, Position } from "../..";
2import { GetLspDefinitionsFunction } from "../../autocomplete/types";
3import { ConfigHandler } from "../../config/ConfigHandler";
4import { NextEditProvider } from "../NextEditProvider";
5import { EditAggregator } from "./aggregateEdits";
6import { BeforeAfterDiff, createDiff, DiffFormatType } from "./diffFormatting";
7import { processNextEditData } from "./processNextEditData";
8
9export const processSmallEdit = async (
10 beforeAfterdiff: BeforeAfterDiff,
11 cursorPosBeforeEdit: Position,
12 cursorPosAfterPrevEdit: Position,
13 configHandler: ConfigHandler,
14 getDefsFromLspFunction: GetLspDefinitionsFunction,
15 ide: IDE,
16) => {
17 NextEditProvider.getInstance().addDiffToContext(
18 createDiff({
19 beforeContent: beforeAfterdiff.beforeContent,
20 afterContent: beforeAfterdiff.afterContent,
21 filePath: beforeAfterdiff.filePath,
22 diffType: DiffFormatType.Unified,
23 contextLines: 5, // NOTE: This can change depending on experiments!
24 }),
25 );
26
27 // Get the current context data from the most recent message
28 const currentData = (EditAggregator.getInstance() as any)
29 .latestContextData || {
30 configHandler: configHandler,
31 getDefsFromLspFunction: getDefsFromLspFunction,
32 recentlyEditedRanges: [],
33 recentlyVisitedRanges: [],
34 };
35
36 void processNextEditData({
37 filePath: beforeAfterdiff.filePath,
38 beforeContent: beforeAfterdiff.beforeContent,
39 afterContent: beforeAfterdiff.afterContent,
40 cursorPosBeforeEdit: cursorPosBeforeEdit,
41 cursorPosAfterPrevEdit: cursorPosAfterPrevEdit,
42 ide: ide,
43 configHandler: currentData.configHandler,
44 getDefinitionsFromLsp: currentData.getDefsFromLspFunction,
45 recentlyEditedRanges: currentData.recentlyEditedRanges,
46 recentlyVisitedRanges: currentData.recentlyVisitedRanges,
47 workspaceDir: currentData.workspaceDir,
48 });
49};