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

Function take

packages/opencode/src/cli/cmd/run/session.shared.ts:74–90  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

72 const used: Array<{ start: number; end: number }> = []
73
74 const take = (value: string): { start: number; end: number; value: string } | undefined => {
75 let from = 0
76 while (true) {
77 const idx = text.indexOf(value, from)
78 if (idx === -1) {
79 return undefined
80 }
81
82 const start = Bun.stringWidth(text.slice(0, idx))
83 const end = start + Bun.stringWidth(value)
84 if (!used.some((item) => item.start < end && start < item.end)) {
85 return { start, end, value }
86 }
87
88 from = idx + value.length
89 }
90 }
91
92 const add = (value: string) => {
93 const gap = text ? " " : ""

Callers 1

messagePromptFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected