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

Function removeIndentation

packages/opencode/src/tool/edit.ts:472–485  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

470
471export const IndentationFlexibleReplacer: Replacer = function* (content, find) {
472 const removeIndentation = (text: string) => {
473 const lines = text.split("\n")
474 const nonEmptyLines = lines.filter((line) => line.trim().length > 0)
475 if (nonEmptyLines.length === 0) return text
476
477 const minIndent = Math.min(
478 ...nonEmptyLines.map((line) => {
479 const match = line.match(/^(\s*)/)
480 return match ? match[1].length : 0
481 }),
482 )
483
484 return lines.map((line) => (line.trim().length === 0 ? line : line.slice(minIndent))).join("\n")
485 }
486
487 const normalizedFind = removeIndentation(find)
488 const contentLines = content.split("\n")

Callers 1

edit.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected