MCPcopy Create free account
hub / github.com/arctic-cli/interface / removeIndentation

Function removeIndentation

packages/arctic/src/tool/edit.ts:432–445  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

430
431export const IndentationFlexibleReplacer: Replacer = function* (content, find) {
432 const removeIndentation = (text: string) => {
433 const lines = text.split("\n")
434 const nonEmptyLines = lines.filter((line) => line.trim().length > 0)
435 if (nonEmptyLines.length === 0) return text
436
437 const minIndent = Math.min(
438 ...nonEmptyLines.map((line) => {
439 const match = line.match(/^(\s*)/)
440 return match ? match[1].length : 0
441 }),
442 )
443
444 return lines.map((line) => (line.trim().length === 0 ? line : line.slice(minIndent))).join("\n")
445 }
446
447 const normalizedFind = removeIndentation(find)
448 const contentLines = content.split("\n")

Callers 1

edit.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected