branch: elpa/markdown-mode
commit 7c51a2167c5a1330e0ab52fe5b2d03c1ead122ca
Merge: 7c20685df6 18566c282f
Author: Shohei YOSHIDA <syo...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #905 from jrblevin/issue-904
    
    Fix wrong list item bound calculation when tab indentation is used
---
 CHANGES.md             |  2 ++
 markdown-mode.el       |  6 +++++-
 tests/markdown-test.el | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 3da109a47e..5ce23b66db 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -13,6 +13,7 @@
     - `markdown-export` should not output stderr content to output file
     - Hide wikilink markup as part of `markdown-toggle-markup-hiding` 
[GH-847][]
     - Angle URL fontify issue which was introduced by [GH-861][] [GH-895][]
+    - Fix list item bound calculation when tab indentation is used [GH-904][]
 
 *   Improvements:
     - Support drag and drop features on Windows and multiple files' drag and 
drop
@@ -25,6 +26,7 @@
   [gh-882]: https://github.com/jrblevin/markdown-mode/issues/882
   [gh-891]: https://github.com/jrblevin/markdown-mode/issues/891
   [gh-895]: https://github.com/jrblevin/markdown-mode/issues/895
+  [gh-904]: https://github.com/jrblevin/markdown-mode/issues/904
 
 # Markdown Mode 2.7
 
diff --git a/markdown-mode.el b/markdown-mode.el
index 74d958a7d7..f31ad9cdbb 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -2612,7 +2612,11 @@ Return the point at the end when a list item was found 
at the
 original point.  If the point is not in a list item, do nothing."
   (let (indent)
     (forward-line)
-    (setq indent (current-indentation))
+    ;; #904 consider a space indentation and tab indentation case
+    (save-excursion
+      (let ((pos (point)))
+        (back-to-indentation)
+        (setq indent (- (point) pos))))
     (while
         (cond
          ;; Stop at end of the buffer.
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index fdf23e3e89..3b3186901f 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -4595,6 +4595,25 @@ puts 'hello, world'
     (forward-line)
     (should (markdown-cur-list-item-bounds))))
 
+(ert-deftest test-markdown-lists/bounds-3 ()
+  "Function `markdown-cur-list-item-bounds' with tab indentations.
+Detail: https://github.com/jrblevin/markdown-mode/issues/904";
+  ;; tab indentation
+  (markdown-test-string "- item
+\t- subitem1
+\t- subitem2"
+    (forward-line)
+    (let ((bounds (markdown-cur-list-item-bounds)))
+      (should (= (nth 1 bounds) 19))))
+
+  ;; space indentation
+  (markdown-test-string "- item
+    - subitem1
+    - subitem2"
+    (forward-line)
+    (let ((bounds (markdown-cur-list-item-bounds)))
+      (should (= (nth 1 bounds) 22)))))
+
 (ert-deftest test-markdown-lists/bounds-prev ()
   "Test list item bounds function `markdown-prev-list-item-bounds'."
   (markdown-test-file "lists.text"

Reply via email to