Skip to content

Commit

Permalink
org-list-struct-apply-struct: Do not rely on `match-data' after edits
Browse files Browse the repository at this point in the history
* lisp/org-list.el (org-list-struct-apply-struct): Refresh
`org-list-full-item-re' match data if we edit the bullet.  Fixes
https://orgmode.org/list/62cbc0f3.1c69fb81.13d5e.e250SMTPIN_ADDED_BROKEN@mx.google.com
* testing/lisp/test-org-list.el (test-org-list/indent-item): Add test
checking for the reported bug.
  • Loading branch information
yantar92 committed Jul 11, 2022
1 parent 53e6aa8 commit 6540053
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lisp/org-list.el
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@ Initial position of cursor is restored after the changes."
(goto-char (match-end 1))
(insert-before-markers new-bul)
(insert keep-space))))
;; Refresh potentially shifted match markers.
(goto-char item)
(looking-at org-list-full-item-re)
;; b. Replace checkbox.
(cond
((equal (match-string 3) new-box))
Expand Down
10 changes: 10 additions & 0 deletions testing/lisp/test-org-list.el
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@
(buffer-string))))
(should
(equal "
- [ ] list item 1
+ [ ] list item 2"
(org-test-with-temp-text "
- [ ] list item 1
- [ ] list item 2<point>"
(let ((org-list-demote-modify-bullet '(("-" . "+"))))
(org-indent-item)
(buffer-string)))))
(should
(equal "
1. Item 1
+ Item 2"
(org-test-with-temp-text "
Expand Down

0 comments on commit 6540053

Please sign in to comment.