Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdown-enter-key doesn't delete empty checkbox list #786

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- HTML-escape title in `markdown-add-xhtml-header-and-footer` [markdown-xwidget-issue-9](https://github.com/cfclrk/markdown-xwidget/issues/9)
- Fix wrong inline link parsing that has link title[GH-762][]
- Don't treat backslashes as escapes inside literal blocks[GH-766][] [GH-768][]
- Fix `markdown-enter-key` doesn't delete empty checkbox list[GH-786]

[gh-377]: https://github.com/jrblevin/markdown-mode/issues/377
[gh-572]: https://github.com/jrblevin/markdown-mode/issues/572
Expand All @@ -55,6 +56,7 @@
[gh-773]: https://github.com/jrblevin/markdown-mode/issues/773
[gh-774]: https://github.com/jrblevin/markdown-mode/issues/774
[gh-778]: https://github.com/jrblevin/markdown-mode/issues/778
[gh-786]: https://github.com/jrblevin/markdown-mode/pull/786

# Markdown Mode 2.5

Expand Down
5 changes: 3 additions & 2 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -5066,9 +5066,10 @@ list simply adds a blank line)."
(setq bounds (markdown-cur-list-item-bounds)))
(let ((beg (cl-first bounds))
(end (cl-second bounds))
(length (cl-fourth bounds)))
(nonlist-indent (cl-fourth bounds))
(checkbox (cl-sixth bounds)))
;; Point is in a list item
(if (= (- end beg) length)
(if (= (- end beg) (+ nonlist-indent (length checkbox)))
;; Delete blank list
(progn
(delete-region beg end)
Expand Down
12 changes: 12 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,18 @@ Should not cause an infinite loop."
(should (string-equal (buffer-string) "* foo\n* bar\n * baz\n\n"))
(should (eq (point) 22)))))

(ert-deftest test-markdown-indentation/indent-checkbox-list ()
"Test `markdown-indent-line' with a list item with checkbox."
(let ((markdown-indent-on-enter 'indent-and-new-item))
(markdown-test-string " * [x] item 1"
(end-of-line)
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) " * [x] item 1\n * [ ] "))
(should (eq (point) 24))
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) " * [x] item 1\n\n"))
(should (eq (point) 17)))))

(ert-deftest test-markdown-indentation/indent-pre ()
"Test `markdown-indent-line' with a pre block."
(markdown-test-string
Expand Down