Apply proper indentation to a line based on its relative indent in patch.
(line: str)
| 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: |
no test coverage detected