emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode 8781cf9732 2/2: Merge pull request #786 from


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 8781cf9732 2/2: Merge pull request #786 from kuranari/markdown-enter-key
Date: Mon, 7 Aug 2023 01:00:22 -0400 (EDT)

branch: elpa/markdown-mode
commit 8781cf9732c878621fd5821ccf8dfb731bf16f16
Merge: 50ac14ffe4 e045e8f773
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #786 from kuranari/markdown-enter-key
    
    Fix markdown-enter-key doesn't delete empty checkbox list
---
 CHANGES.md             |  2 ++
 markdown-mode.el       |  5 +++--
 tests/markdown-test.el | 12 ++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 3ec48f79d3..d4f33f8265 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -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
@@ -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
 
diff --git a/markdown-mode.el b/markdown-mode.el
index 3c95c92527..e0192b92b6 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -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)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 7a7685f35d..50862df4d9 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]