Skip to content

Conversation

@Neutronlul
Copy link
Contributor

@Neutronlul Neutronlul commented Nov 21, 2025

DISCLAIMER: I based this change off of code generated by an LLM.

This pull request attempts to fix #474.

Using test code taken from #474:

import { parseDocument } from 'yaml';
import { createPatch } from 'diff';

const yaml = `
map:
  item:

anothermap:
  anotheritem:

`;

const document = parseDocument(yaml);
const result = document.toString();

const patch = createPatch('output', yaml, result);

console.log(patch);

Before:

Index: output
===================================================================
--- output
+++ output
@@ -1,7 +1,8 @@
-
 map:
   item:

+
 anothermap:
   anotheritem:

+

After:

Index: output
===================================================================
--- output
+++ output
@@ -1,5 +1,4 @@
-
 map:
   item:

 anothermap:

As you can see, it still removes the newline at the start of the document, but as far as I can tell that's not really a problem.

I hope that the test case is sufficient and that it's in the right place, I wasn't really sure where to put it.

@Neutronlul Neutronlul marked this pull request as ready for review November 21, 2025 11:45
Copy link
Owner

@eemeli eemeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the right fix? Had to ponder the code around this for a while, so the overall savings from having an LLM suggest a solution were pretty minimal here, they just moved the burden to me as the reviewer.

Apply the inline change, and this should be good to go?

@Neutronlul Neutronlul requested a review from eemeli November 27, 2025 11:06
@eemeli eemeli merged commit 70a8db3 into eemeli:main Nov 27, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra newline is added after empty values

2 participants