diff --git a/json-par-insert.el b/json-par-insert.el index cfcaae6..7ac1039 100644 --- a/json-par-insert.el +++ b/json-par-insert.el @@ -543,7 +543,6 @@ START is the start position of the object." ((use-region-p) (json-par-stringify-region (region-beginning) (region-end))) - ;; Inside a string ((save-excursion (nth 3 (setq parser-state (syntax-ppss)))) (cond @@ -620,7 +619,9 @@ If the region is active, unwrap all strings in it. Otherwise, unwrap the nearest string. -Escaped characters in the strings are unescaped." +Escaped characters in the strings are unescaped. + +Inhibit fixing up until next modification." (interactive) (let* ((parser-state (save-excursion (syntax-ppss))) (current-atom (json-par--current-atom parser-state)) @@ -678,10 +679,12 @@ Escaped characters in the strings are unescaped." (push #'json-par-destringify json-par--fixup-adviced-functions) (defun json-par-destringify-region (start end) - "Unwrap strings in the region from START to END. + "Unwrap strings overlapping the region from START to END. Escaped characters in the strings are unescaped. +Inhibit fixing up until next modification. + Return the end position." (interactive "r") (save-excursion @@ -711,14 +714,17 @@ Return the end position." (push #'json-par-destringify-region json-par--fixup-adviced-functions) (defun json-par--destringify-after () - "Unwrap a string just after the point." + "Unwrap a string just after the point. + +Inhibit fixing up until next modification." (let ((start (point-marker)) (end (save-excursion (json-par-forward-token) (point-marker)))) (goto-char end) (delete-char -1) (goto-char start) (delete-char 1) - (goto-char (json-par-unescape-region-for-string start end)))) + (goto-char (json-par-unescape-region-for-string start end)) + (setq json-par--inhibit-fixup-tick (buffer-chars-modified-tick)))) (defun json-par--insert-key-or-value (value) "Insert VALUE as a key or a value. diff --git a/test/json-files/editing/insert_double_quotes.json b/test/json-files/editing/insert_double_quotes.json index ec52c22..0e59232 100644 --- a/test/json-files/editing/insert_double_quotes.json +++ b/test/json-files/editing/insert_double_quotes.json @@ -1695,8 +1695,8 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - /*|*/"", \, /, , , - , 😀 + /*|*/""\/ + 😀 ] // expected-end // test-end @@ -1735,8 +1735,7 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - "\"abc\"",/*|*/ - "abc" + "\"abc\""/*|*/"abc" ] // expected-end // test-end @@ -1750,7 +1749,7 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - "abc", /*|*/ + "abc" /*|*/ "\"abc\"" ] // expected-end @@ -1765,7 +1764,7 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - "\"abc\"", + "\"abc\"" /*|*/ "abc" ] // expected-end @@ -1780,8 +1779,7 @@ // FIXME: should the point be adjusted? // expected-start [ - "\"abc\"", - /*|*/ "abc" + "\"abc\"", /*|*/ "abc" ] // expected-end // test-end @@ -1797,7 +1795,7 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - "\"abc\"", + "\"abc\"" /*|*/ "abc" ] @@ -1814,7 +1812,7 @@ // action: (json-par-insert-double-quotes t) // expected-start [ - "abc", + "abc" /*|*/ 1 ]