MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / showCodeActionsMenu

Function showCodeActionsMenu

src/cm/lsp/codeActions.ts:372–409  ·  view source on GitHub ↗
(view: EditorView)

Source from the content-addressed store, hash-verified

370}
371
372export async function showCodeActionsMenu(view: EditorView): Promise<boolean> {
373 if (!supportsCodeActions(view)) return false;
374
375 const items = await fetchCodeActions(view);
376 if (!items.length) {
377 toast("No code actions available");
378 return false;
379 }
380
381 const selectItems = items.map((item, i) => ({
382 value: String(i),
383 text: item.title,
384 icon: item.icon,
385 disabled: item.disabled,
386 }));
387
388 try {
389 const result = await select(
390 strings["code actions"] || "Code Actions",
391 selectItems as unknown as string[],
392 { hideOnSelect: true },
393 );
394
395 if (result !== null && result !== undefined) {
396 const index = Number.parseInt(String(result), 10);
397 if (!Number.isNaN(index) && index >= 0 && index < items.length) {
398 await executeCodeAction(view, items[index]);
399 view.focus();
400 return true;
401 }
402 }
403 } catch {
404 // User cancelled selection
405 }
406
407 view.focus();
408 return false;
409}
410
411export async function performQuickFix(view: EditorView): Promise<boolean> {
412 const items = await fetchCodeActions(view);

Callers 2

showCodeActionsFunction · 0.85
performQuickFixFunction · 0.85

Calls 6

supportsCodeActionsFunction · 0.85
fetchCodeActionsFunction · 0.85
StringInterface · 0.85
executeCodeActionFunction · 0.85
focusMethod · 0.80
selectFunction · 0.70

Tested by

no test coverage detected