Skip to content

Commit

Permalink
Don't insert list item if here is in code block
Browse files Browse the repository at this point in the history
  • Loading branch information
syohex committed Jan 15, 2025
1 parent 9fd2661 commit 30137f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Mark `markdown-css-paths` safe as file local variables [GH-834][]
- Resolve style sheets in `markdown-css-paths` relative to the Markdown file
(if the path starts with `./` or `../`) [GH-855][] [GH-870][]
- Don't insert list item in code block [GH-841][]

[gh-780]: https://github.com/jrblevin/markdown-mode/issues/780
[gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
Expand All @@ -43,6 +44,7 @@
[gh-834]: https://github.com/jrblevin/markdown-mode/issues/834
[gh-838]: https://github.com/jrblevin/markdown-mode/issues/838
[gh-839]: https://github.com/jrblevin/markdown-mode/issues/839
[gh-841]: https://github.com/jrblevin/markdown-mode/issues/841
[gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
[gh-848]: https://github.com/jrblevin/markdown-mode/issues/848
[gh-855]: https://github.com/jrblevin/markdown-mode/issues/855
Expand Down
1 change: 1 addition & 0 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -5188,6 +5188,7 @@ list simply adds a blank line)."
(markdown-indent-on-enter
(let (bounds)
(if (and (memq markdown-indent-on-enter '(indent-and-new-item))
(not (markdown-code-block-at-point-p))
(setq bounds (markdown-cur-list-item-bounds)))
(let ((beg (cl-first bounds))
(end (cl-second bounds))
Expand Down
11 changes: 11 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,17 @@ See GH-245."
(should (string-equal (buffer-string) " - [X] item\n\n"))
(should (= (point) 18)))))

(ert-deftest test-markdown-indentation/not-insert-list-item-in-code-block ()
"Don't insert new item if here is in code."
(let ((markdown-indent-on-enter 'indent-and-new-item))
(markdown-test-string "```
- foo
```"
(forward-line)
(end-of-line)
(call-interactively #'markdown-enter-key)
(should-not (looking-back "- ")))))

;;; Markup hiding tests:

(ert-deftest test-markdown-markup-hiding/italics-1 ()
Expand Down

0 comments on commit 30137f3

Please sign in to comment.