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

Function navigateToReference

src/components/referencesPanel/utils.js:110–135  ·  view source on GitHub ↗
(ref)

Source from the content-addressed store, hash-verified

108}
109
110export async function navigateToReference(ref) {
111 Sidebar.hide();
112
113 try {
114 await openFile(ref.uri, { render: true });
115 const { editor } = editorManager;
116 if (!editor) return;
117
118 const doc = editor.state.doc;
119 const startLine = doc.line(ref.range.start.line + 1);
120 const endLine = doc.line(ref.range.end.line + 1);
121 const from = Math.min(
122 startLine.from + ref.range.start.character,
123 startLine.to,
124 );
125 const to = Math.min(endLine.from + ref.range.end.character, endLine.to);
126
127 editor.dispatch({
128 selection: { anchor: from, head: to },
129 effects: EditorView.scrollIntoView(from, { y: "center" }),
130 });
131 editor.focus();
132 } catch (error) {
133 console.error("Failed to navigate to reference:", error);
134 }
135}
136
137export function getReferencesStats(references) {
138 const fileCount = new Set(references.map((r) => r.uri)).size;

Callers 1

renderReferencesListFunction · 0.90

Calls 3

focusMethod · 0.80
hideMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected