List extension by insertNewlineContinueMarkup intentional?


When using the built in Command insertNewlineContinueMarkup from the lang-markdown package. Its behavior works as expected for the most part. However, there is a glaring problem in my setup that I’m unable to verify if this is intended or not:

When I type a list and press enter afterwards everything works as expected.

1. Hello, world!
2. (my cursor is here now)

Let’s say I just wanted that for my list, in the demo editor for cm-5 as well as most other online editors, I would press enter to get rid of the 2. and go to the next line. But I get this result:

1. Hello, world!

2. (my cursor is still here)

expected result:

1. Hello, world!

(Cursor sitting here)

This happens with - lists, and quotes > however in the case of the quotes it actually removes both the trailing > from the last 2 lines correctly to clean up.

Is this an intentional behavior? Is this a bug with my implementation? I’m more or less using a barebones setup (just the markdown plugin and the tab plugin. I’m adding my own plugin for further keymaps but it doesn’t touch Enter) But this behavior deviates from what I’ve seen on this forum as well as the cm 5 behavior.

This is intentional behavior. Makes it possible to quickly write non-tight lists. Press enter again to clear the number.


For anyone reading this in the future, my solution was to write a custom plugin to handle new-lines the way I wanted! The behavior of insertNewlineContinueMarkup is complex, it was a bit difficult/time-consuming to get the behavior I want. However, it seems like the codemirror way to DIY for the behavior you want.