nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: nodeca/js-yaml
Pull request #527 (2019-11-14 21:03:52)

Fix issue #526: wrong quote position writing condensed flow

puzrin: Seems ok in general. Please take a look at comment & squash all to single commit.

Patch:
diff --git a/lib/js-yaml/dumper.js b/lib/js-yaml/dumper.js
index 0f5666e..f3d4fd9 100644
--- a/lib/js-yaml/dumper.js
+++ b/lib/js-yaml/dumper.js
@@ -569,10 +569,12 @@ function writeFlowMapping(state, level, object) {
       pairBuffer;
 
   for (index = 0, length = objectKeyList.length; index < length; index += 1) {
-    pairBuffer = state.condenseFlow ? '"' : '';
 
+    pairBuffer = '';
     if (index !== 0) pairBuffer += ', ';
 
+    if (state.condenseFlow) pairBuffer += '"';
+
     objectKey = objectKeyList[index];
     objectValue = object[objectKey];
 


Test patch:
diff --git a/test/issues/0346.js b/test/issues/0346.js
index ccd75d5..9751976 100644
--- a/test/issues/0346.js
+++ b/test/issues/0346.js
@@ -15,11 +15,11 @@ test('should not emit spaces in arrays in flow mode between entries using conden
 });
 
 test('should not emit spaces between key: value and quote keys using condenseFlow: true', function () {
-  var object = { a: { b: 'c' } };
+  var object = { a: { b: 'c', d: 'e' } };
   var objectDump = yaml.dump(object, { flowLevel: 0, indent: 0, condenseFlow: true });
   assert.equal(
     objectDump,
-    '{"a":{"b":c}}\n'
+    '{"a":{"b":c, "d":e}}\n'
   );
   assert.deepEqual(yaml.load(objectDump), object);
 });