MCPcopy Index your code
hub / github.com/anomalyco/opencode / createLineCallbacks

Function createLineCallbacks

packages/session-ui/src/components/file.tsx:424–452  ·  view source on GitHub ↗
(opts: {
  viewer: Viewer
  normalize?: (range: SelectedLineRange | null) => SelectedLineRange | null | undefined
  onLineSelected?: (range: SelectedLineRange | null) => void
  onLineSelectionEnd?: (range: SelectedLineRange | null) => void
  onLineNumberSelectionEnd?: (selection: SelectedLineRange | null) => void
})

Source from the content-addressed store, hash-verified

422}
423
424function createLineCallbacks(opts: {
425 viewer: Viewer
426 normalize?: (range: SelectedLineRange | null) => SelectedLineRange | null | undefined
427 onLineSelected?: (range: SelectedLineRange | null) => void
428 onLineSelectionEnd?: (range: SelectedLineRange | null) => void
429 onLineNumberSelectionEnd?: (selection: SelectedLineRange | null) => void
430}) {
431 const select = (range: SelectedLineRange | null) => {
432 if (!opts.normalize) return range
433 const next = opts.normalize(range)
434 if (next !== undefined) return next
435 return range
436 }
437
438 return {
439 onLineSelected: (range: SelectedLineRange | null) => {
440 const next = select(range)
441 opts.viewer.lastSelection = next
442 opts.onLineSelected?.(next)
443 },
444 onLineSelectionEnd: (range: SelectedLineRange | null) => {
445 const next = select(range)
446 opts.viewer.lastSelection = next
447 opts.onLineSelectionEnd?.(next)
448 if (!opts.viewer.bridge.consume(next)) return
449 requestAnimationFrame(() => opts.onLineNumberSelectionEnd?.(next))
450 },
451 }
452}
453
454function useAnnotationRerender<A>(opts: {
455 viewer: Viewer

Callers 2

TextViewerFunction · 0.85
DiffViewerFunction · 0.85

Calls 2

consumeMethod · 0.80
selectFunction · 0.70

Tested by

no test coverage detected