Skip to content

Commit 54513b7

Browse files
docs: clarify indent_block preserves blank lines without trailing whitespace
1 parent 5b14061 commit 54513b7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/document.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ fn apply_complex_replace(
289289
let base_indent = feat_start - line_start;
290290
// NOTE: The +2 assumes 2-space indentation. This is consistent with yamlpatch,
291291
// which also hardcodes 2-space indent in Add, Append, MergeInto, and Replace ops.
292-
// Fixing this for non-2-space documents should be done upstream in yamlpatch.
293292
let value_indent = " ".repeat(base_indent + 2);
294293

295294
// Serialize the new value in block style
@@ -404,6 +403,9 @@ fn indent_block(content: &str, indent: &str) -> String {
404403
if i > 0 {
405404
result.push('\n');
406405
}
406+
// Blank lines are preserved (the \n above) but not indented,
407+
// avoiding trailing whitespace. In practice serde_yaml::to_string()
408+
// never emits blank lines for Mapping/Sequence values.
407409
if !line.trim().is_empty() {
408410
result.push_str(indent);
409411
result.push_str(line);

0 commit comments

Comments
 (0)