branch: externals/yaml commit 39f8412becebf39974bce1b5c90220c89f7ebacc Author: Zachary Romero <zacrom...@posteo.net> Commit: Zachary Romero <zacrom...@posteo.net>
Fix encoding deeply nested lists --- yaml-tests.el | 8 ++++++++ yaml.el | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/yaml-tests.el b/yaml-tests.el index 6993986b7c..2e323be7da 100644 --- a/yaml-tests.el +++ b/yaml-tests.el @@ -546,6 +546,14 @@ keep: |+ (should (equal (yaml-encode `((deeper . [((foo . bar) (baz . bax))]))) "\ndeeper: \n- foo: bar\n baz: bax")) + (should (equal + (equal (yaml-parse-string + (yaml-encode [1 [2 [3] 2] 1]) + :object-type 'alist + :sequence-type 'array) + [[1 [2 [3] 2] 1]]))) + (should (equal + (yaml-test-round-trip `[1 [2 [[4 4 4] 3 ((a . 1) (b . 2) (c . 3)) 3] 2] 1]))) (should (yaml-test-round-trip '((build_the_package (script . "if [ -z \"${CUSTOM}\" ]; then ./mvnw package diff --git a/yaml.el b/yaml.el index 718e111c97..f0a38eda53 100644 --- a/yaml.el +++ b/yaml.el @@ -2800,10 +2800,10 @@ auto-detecting the indentation" (insert (make-string (- indent curr-indent) ?\s) "- ")) (insert "\n" indent-string "- ")) (setq first nil)) - (yaml--encode-object object indent - (or - (hash-table-p object) - (yaml--alist-to-hash-table object)))) + (if (or (hash-table-p object) + (yaml--alist-to-hash-table object)) + (yaml--encode-object object indent t) + (yaml--encode-object object (+ indent 2) nil))) l)))))) (defun yaml--encode-auto-detect-indent ()