MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / apply_line_with_indent

Function apply_line_with_indent

src/sandbox_vm/tools/code/patch.py:442–458  ·  view source on GitHub ↗

Apply proper indentation to a line based on its relative indent in patch.

(line: str)

Source from the content-addressed store, hash-verified

440 replacement = []
441
442 def apply_line_with_indent(line: str) -> str:
443 """Apply proper indentation to a line based on its relative indent in patch."""
444 if not line.strip():
445 # Empty line - preserve as-is
446 return line
447
448 # Calculate relative indentation beyond patch base
449 relative_indent = _calculate_relative_indent(
450 line=line,
451 base_indent=patch_base_indent,
452 target_style=indent_style,
453 target_unit=indent_unit,
454 )
455
456 # Final indentation = file base + relative indent
457 final_indent = file_base_indent + relative_indent
458 return final_indent + _strip_indentation(line)
459
460 # Apply indentation to context_before lines
461 for line in hunk.context_before:

Callers 1

_apply_hunk_to_linesFunction · 0.85

Calls 2

_strip_indentationFunction · 0.85

Tested by

no test coverage detected