Elffuss BraidHub

kikocis/continue public

91054b807bf2 · 1.7 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 beforeAfterdiff.beforeContent,
20 beforeAfterdiff.afterContent,
21 beforeAfterdiff.filePath,
22 DiffFormatType.Unified,
23 ),
24 );
25
26 // Get the current context data from the most recent message
27 const currentData = (EditAggregator.getInstance() as any)
28 .latestContextData || {
29 configHandler: configHandler,
30 getDefsFromLspFunction: getDefsFromLspFunction,
31 recentlyEditedRanges: [],
32 recentlyVisitedRanges: [],
33 };
34
35 void processNextEditData({
36 filePath: beforeAfterdiff.filePath,
37 beforeContent: beforeAfterdiff.beforeContent,
38 afterContent: beforeAfterdiff.afterContent,
39 cursorPosBeforeEdit: cursorPosBeforeEdit,
40 cursorPosAfterPrevEdit: cursorPosAfterPrevEdit,
41 ide: ide,
42 configHandler: currentData.configHandler,
43 getDefinitionsFromLsp: currentData.getDefsFromLspFunction,
44 recentlyEditedRanges: currentData.recentlyEditedRanges,
45 recentlyVisitedRanges: currentData.recentlyVisitedRanges,
46 workspaceDir: currentData.workspaceDir,
47 });
48};