MCPcopy
hub / github.com/continuedev/continue / processNextEditData

Function processNextEditData

core/nextEdit/context/processNextEditData.ts:43–151  ·  view source on GitHub ↗
({
  filePath,
  beforeContent,
  afterContent,
  cursorPosBeforeEdit,
  cursorPosAfterPrevEdit,
  ide,
  configHandler,
  getDefinitionsFromLsp,
  recentlyEditedRanges,
  recentlyVisitedRanges,
  workspaceDir,
  modelNameOrInstance,
}: ProcessNextEditDataParams)

Source from the content-addressed store, hash-verified

41}
42
43export const processNextEditData = async ({
44 filePath,
45 beforeContent,
46 afterContent,
47 cursorPosBeforeEdit,
48 cursorPosAfterPrevEdit,
49 ide,
50 configHandler,
51 getDefinitionsFromLsp,
52 recentlyEditedRanges,
53 recentlyVisitedRanges,
54 workspaceDir,
55 modelNameOrInstance,
56}: ProcessNextEditDataParams) => {
57 // To switch to the user's autocomplete model, uncomment the following lines
58 // const { config } = await configHandler.loadConfig();
59 // const autocompleteModel =
60 // (modelNameOrInstance || config?.selectedModelByRole.autocomplete) ??
61 // undefined;
62
63 const modelName = "Codestral";
64 const modelProvider = "mistral";
65 const maxPromptTokens = randomNumberBetween(500, 12000);
66
67 const autocompleteContext = await getAutocompleteContext(
68 filePath,
69 cursorPosBeforeEdit,
70 ide,
71 configHandler,
72 getDefinitionsFromLsp,
73 recentlyEditedRanges,
74 recentlyVisitedRanges,
75 maxPromptTokens,
76 beforeContent,
77 modelName,
78 );
79
80 NextEditProvider.getInstance().addAutocompleteContext(autocompleteContext);
81
82 // console.log(
83 // createDiff(beforeContent, afterContent, filePath, DiffFormatType.Unified),
84 // );
85
86 let filenamesAndDiffs: filenameAndDiff[] = [];
87
88 const timestamp = Date.now();
89 let prevEdits: prevEdit[] = getPrevEditsDescending(); // edits from most to least recent
90 if (prevEdits.length > 0) {
91 // if last edit was 10+ minutes ago or the workspace changed, forget previous edits
92 if (
93 timestamp - prevEdits[0].timestamp >= 1000 * 60 * 10 ||
94 workspaceDir !== prevEdits[0].workspaceUri
95 ) {
96 prevEditLruCache.clear();
97 prevEdits = [];
98 }
99
100 // extract filenames and diffs for logging

Callers 1

processSmallEditFunction · 0.90

Calls 10

getAutocompleteContextFunction · 0.90
getPrevEditsDescendingFunction · 0.90
createDiffFunction · 0.90
setPrevEditFunction · 0.90
randomNumberBetweenFunction · 0.85
logDevDataMethod · 0.80
getInstanceMethod · 0.45
clearMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected