(ref)
| 108 | } |
| 109 | |
| 110 | export 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 | |
| 137 | export function getReferencesStats(references) { |
| 138 | const fileCount = new Set(references.map((r) => r.uri)).size; |
no test coverage detected