MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / acceptCompletion

Method acceptCompletion

src/codemirror.ts:274–306  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272 }
273
274 acceptCompletion(): boolean {
275 const completion = this.currentCompletion;
276 if (completion === undefined) {
277 return false;
278 }
279 this.clearCompletion('about to accept completions');
280 const completionProto = completion.completionItem.completion;
281 if (completionProto === undefined) {
282 console.error('Empty completion');
283 return true;
284 }
285 const doc = completion.doc;
286 // This is a hack since we have the fake typing as completed logic.
287 doc.setCursor(completion.start);
288 doc.replaceRange(completionProto.text, completion.start, completion.end);
289 if (
290 completion.completionItem.suffix !== undefined &&
291 completion.completionItem.suffix.text.length > 0
292 ) {
293 doc.replaceRange(completion.completionItem.suffix.text, doc.getCursor());
294 const currentCursor = doc.getCursor();
295 const newOffset =
296 doc.indexFromPos(currentCursor) +
297 Number(completion.completionItem.suffix.deltaCursorOffset);
298 doc.setCursor(doc.posFromIndex(newOffset));
299 }
300 this.client.acceptedLastCompletion(
301 this.ideInfo,
302 completion.apiKey,
303 completionProto.completionId
304 );
305 return true;
306 }
307
308 // If this returns false, don't consume the event.
309 // If true, consume the event.

Callers 3

beforeMainKeyHandlerMethod · 0.95
constructorMethod · 0.80

Calls 2

clearCompletionMethod · 0.95

Tested by

no test coverage detected