MCPcopy Create free account
hub / github.com/anomalyco/opencode / extractLineRange

Function extractLineRange

packages/opencode/src/cli/cmd/run/footer.prompt.tsx:124–140  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

122}
123
124function extractLineRange(input: string) {
125 const hash = input.lastIndexOf("#")
126 if (hash === -1) {
127 return { base: input }
128 }
129
130 const base = input.slice(0, hash)
131 const line = input.slice(hash + 1)
132 const match = line.match(/^(\d+)(?:-(\d*))?$/)
133 if (!match) {
134 return { base }
135 }
136
137 const start = Number(match[1])
138 const end = match[2] && start < Number(match[2]) ? Number(match[2]) : undefined
139 return { base, line: { start, end } }
140}
141
142function slashHead(text: string) {
143 if (!text.startsWith("/")) {

Callers 1

createPromptStateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected