Skip to content

Commit 8781cf9

Browse files
authored
Merge pull request #786 from kuranari/markdown-enter-key
Fix markdown-enter-key doesn't delete empty checkbox list
2 parents 50ac14f + e045e8f commit 8781cf9

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- HTML-escape title in `markdown-add-xhtml-header-and-footer` [markdown-xwidget-issue-9](https://github.com/cfclrk/markdown-xwidget/issues/9)
3737
- Fix wrong inline link parsing that has link title[GH-762][]
3838
- Don't treat backslashes as escapes inside literal blocks[GH-766][] [GH-768][]
39+
- Fix `markdown-enter-key` doesn't delete empty checkbox list[GH-786]
3940

4041
[gh-377]: https://github.com/jrblevin/markdown-mode/issues/377
4142
[gh-572]: https://github.com/jrblevin/markdown-mode/issues/572
@@ -55,6 +56,7 @@
5556
[gh-773]: https://github.com/jrblevin/markdown-mode/issues/773
5657
[gh-774]: https://github.com/jrblevin/markdown-mode/issues/774
5758
[gh-778]: https://github.com/jrblevin/markdown-mode/issues/778
59+
[gh-786]: https://github.com/jrblevin/markdown-mode/pull/786
5860

5961
# Markdown Mode 2.5
6062

markdown-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5066,9 +5066,10 @@ list simply adds a blank line)."
50665066
(setq bounds (markdown-cur-list-item-bounds)))
50675067
(let ((beg (cl-first bounds))
50685068
(end (cl-second bounds))
5069-
(length (cl-fourth bounds)))
5069+
(nonlist-indent (cl-fourth bounds))
5070+
(checkbox (cl-sixth bounds)))
50705071
;; Point is in a list item
5071-
(if (= (- end beg) length)
5072+
(if (= (- end beg) (+ nonlist-indent (length checkbox)))
50725073
;; Delete blank list
50735074
(progn
50745075
(delete-region beg end)

tests/markdown-test.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,18 @@ Should not cause an infinite loop."
20542054
(should (string-equal (buffer-string) "* foo\n* bar\n * baz\n\n"))
20552055
(should (eq (point) 22)))))
20562056

2057+
(ert-deftest test-markdown-indentation/indent-checkbox-list ()
2058+
"Test `markdown-indent-line' with a list item with checkbox."
2059+
(let ((markdown-indent-on-enter 'indent-and-new-item))
2060+
(markdown-test-string " * [x] item 1"
2061+
(end-of-line)
2062+
(call-interactively #'markdown-enter-key)
2063+
(should (string-equal (buffer-string) " * [x] item 1\n * [ ] "))
2064+
(should (eq (point) 24))
2065+
(call-interactively #'markdown-enter-key)
2066+
(should (string-equal (buffer-string) " * [x] item 1\n\n"))
2067+
(should (eq (point) 17)))))
2068+
20572069
(ert-deftest test-markdown-indentation/indent-pre ()
20582070
"Test `markdown-indent-line' with a pre block."
20592071
(markdown-test-string

0 commit comments

Comments
 (0)