Skip to content

Commit 7c51a21

Browse files
authored
Merge pull request #905 from jrblevin/issue-904
Fix wrong list item bound calculation when tab indentation is used
2 parents 7c20685 + 18566c2 commit 7c51a21

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- `markdown-export` should not output stderr content to output file
1414
- Hide wikilink markup as part of `markdown-toggle-markup-hiding` [GH-847][]
1515
- Angle URL fontify issue which was introduced by [GH-861][] [GH-895][]
16+
- Fix list item bound calculation when tab indentation is used [GH-904][]
1617

1718
* Improvements:
1819
- Support drag and drop features on Windows and multiple files' drag and drop
@@ -25,6 +26,7 @@
2526
[gh-882]: https://github.com/jrblevin/markdown-mode/issues/882
2627
[gh-891]: https://github.com/jrblevin/markdown-mode/issues/891
2728
[gh-895]: https://github.com/jrblevin/markdown-mode/issues/895
29+
[gh-904]: https://github.com/jrblevin/markdown-mode/issues/904
2830

2931
# Markdown Mode 2.7
3032

markdown-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,11 @@ Return the point at the end when a list item was found at the
26122612
original point. If the point is not in a list item, do nothing."
26132613
(let (indent)
26142614
(forward-line)
2615-
(setq indent (current-indentation))
2615+
;; #904 consider a space indentation and tab indentation case
2616+
(save-excursion
2617+
(let ((pos (point)))
2618+
(back-to-indentation)
2619+
(setq indent (- (point) pos))))
26162620
(while
26172621
(cond
26182622
;; Stop at end of the buffer.

tests/markdown-test.el

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,25 @@ puts 'hello, world'
45954595
(forward-line)
45964596
(should (markdown-cur-list-item-bounds))))
45974597

4598+
(ert-deftest test-markdown-lists/bounds-3 ()
4599+
"Function `markdown-cur-list-item-bounds' with tab indentations.
4600+
Detail: https://github.com/jrblevin/markdown-mode/issues/904"
4601+
;; tab indentation
4602+
(markdown-test-string "- item
4603+
\t- subitem1
4604+
\t- subitem2"
4605+
(forward-line)
4606+
(let ((bounds (markdown-cur-list-item-bounds)))
4607+
(should (= (nth 1 bounds) 19))))
4608+
4609+
;; space indentation
4610+
(markdown-test-string "- item
4611+
- subitem1
4612+
- subitem2"
4613+
(forward-line)
4614+
(let ((bounds (markdown-cur-list-item-bounds)))
4615+
(should (= (nth 1 bounds) 22)))))
4616+
45984617
(ert-deftest test-markdown-lists/bounds-prev ()
45994618
"Test list item bounds function `markdown-prev-list-item-bounds'."
46004619
(markdown-test-file "lists.text"

0 commit comments

Comments
 (0)