MCPcopy
hub / github.com/srcbookdev/srcbook / gotoDefCallback

Function gotoDefCallback

packages/web/src/components/cells/code.tsx:336–358  ·  view source on GitHub ↗
({ response }: TsServerDefinitionLocationResponsePayloadType)

Source from the content-addressed store, hash-verified

334 }
335
336 async function gotoDefCallback({ response }: TsServerDefinitionLocationResponsePayloadType) {
337 if (!channel) {
338 return;
339 }
340
341 channel.off('tsserver:cell:definition_location:response', gotoDefCallback);
342 if (response === null) {
343 reject(new Error(`Error fetching file content: no response!`));
344 return;
345 }
346 const file_response = await getFileContent(response.file);
347 if (file_response.result.type === 'cell') {
348 document
349 .getElementById(file_response.result.filename)
350 ?.scrollIntoView({ behavior: 'smooth' });
351 } else {
352 if (file_response.error) {
353 reject(new Error(`Error fetching file content: ${file_response.result}`));
354 } else {
355 resolve(file_response.result.content);
356 }
357 }
358 }
359
360 channel.on('tsserver:cell:definition_location:response', gotoDefCallback);
361 channel.push('tsserver:cell:definition_location:request', {

Callers

nothing calls this directly

Calls 2

getFileContentFunction · 0.90
offMethod · 0.45

Tested by

no test coverage detected