Skip to content

Commit

Permalink
Fix `json-par-beginning-of-object-value' at end of one-line object
Browse files Browse the repository at this point in the history
When the following condition mets, move just after the colon:

* The surrounding object is one-line.
* The value is missing.
* No comments between the colon and the close bracket.

Example:

{ "abc|":  }
↓
{ "abc": | }

where "|" represents the point.
  • Loading branch information
taku0 committed Jun 8, 2024
1 parent 14d5a04 commit c4a9566
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions json-par-motion.el
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,22 @@ If PARSED is given, it is used instead of calling
(json-par--forward-spaces)
(when (memq (char-after) '(?\] ?\) ?}))
(goto-char (json-par-token-end (gethash :colon-token parsed)))
(skip-chars-forward "\s\t")))
(skip-chars-forward "\s\t")
(when (memq (char-after) '(?\] ?\) ?}))
(goto-char (json-par-token-end (gethash :colon-token parsed)))
(when (memq (char-after) '(?\s ?\t))
(forward-char)))))

((gethash :key-token parsed)
(goto-char (json-par-token-end (gethash :key-token parsed)))
(json-par--forward-spaces)
(when (memq (char-after) '(?\] ?\) ?}))
(goto-char (json-par-token-end (gethash :key-token parsed)))
(skip-chars-forward "\s\t")))
(skip-chars-forward "\s\t")
(when (memq (char-after) '(?\] ?\) ?}))
(goto-char (json-par-token-end (gethash :key-token parsed)))
(when (memq (char-after) '(?\s ?\t))
(forward-char)))))

(t
(goto-char (gethash :end-of-member parsed)))))
Expand Down

0 comments on commit c4a9566

Please sign in to comment.