emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/yaml 84b88c9ed1 073/124: Merge pull request #27 from zk


From: ELPA Syncer
Subject: [elpa] externals/yaml 84b88c9ed1 073/124: Merge pull request #27 from zkry/fix-empty-single-quote-string
Date: Fri, 29 Nov 2024 16:00:03 -0500 (EST)

branch: externals/yaml
commit 84b88c9ed178af16da18b230c1f61c57cefedf28
Merge: 69c699a15a a2ed8f1fd6
Author: Zachary Romero <zacromero@posteo.net>
Commit: GitHub <noreply@github.com>

    Merge pull request #27 from zkry/fix-empty-single-quote-string
    
    Fix empty single quote string bug
---
 yaml-tests.el |  5 ++++-
 yaml.el       | 16 +++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/yaml-tests.el b/yaml-tests.el
index 928d18638b..7a3aae569e 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -341,7 +341,10 @@ key-2: |2-
                                     :object-key-type 'string
                                     :object-type 'alist)
                  '(("key-1" . "  ---\n  ---")
-                   ("key-2" . "  ---\n  ---")))))
+                   ("key-2" . "  ---\n  ---"))))
+  (should (equal (yaml-parse-string "''") ""))
+  (should (equal (yaml-parse-string "foo: ''" :object-type 'alist)
+                 '((foo . "")))))
 
 
 (ert-deftest yaml-parsing-completes ()
diff --git a/yaml.el b/yaml.el
index f7c7ee02b2..5a21f28cb3 100644
--- a/yaml.el
+++ b/yaml.el
@@ -581,13 +581,15 @@ reverse order."
                                (substring x 1)
                              " "))
                          replaced))
-              (replaced (replace-regexp-in-string
-                         "''"
-                         (lambda (x)
-                           (if (> (length x) 1)
-                               (substring x 1)
-                             "'"))
-                         replaced)))
+              (replaced (if (not (equal "''" replaced))
+                            (replace-regexp-in-string
+                             "''"
+                             (lambda (x)
+                               (if (> (length x) 1)
+                                   (substring x 1)
+                                 "'"))
+                             replaced)
+                          replaced)))
          (yaml--scalar-event "single"
                              (substring replaced 1 (1- (length replaced)))))))
     ("c-double-quoted" .



reply via email to

[Prev in Thread] Current Thread [Next in Thread]