Backspace behavior with 4 space indent lists in Markdown

I have an issue with a markdown editor (here in github), and the problem stems from CodeMirror, presumably here.

When using 2 space indent, in this situation in a list:

Screenshot 2023-09-24 at 15 15 45

With two backspaces you end up here, i.e. at a 2 space indent, which seems to be the intended behavior:

1 backspace

2 backspaces

But with 4 space indent, the first backspace is working correctly:

Screenshot 2023-09-24 at 15 19 25

But the second removes 4 spaces instead of 2, which leads to a wrong 2 space indent in a 4 space indent file:

Screenshot 2023-09-24 at 15 19 39

I don’t think it is the intended behavior, and if it is, I’d like to understand the reason behind it.

The problem does not appear in 2 space indent just because 2 spaces is the length of the - sequence that is removed at the first backspace, i.e. the indentation is never wrong.

But when using 4 space indent (4th picture), now it removes one indentation level from the right from a state where the indentation level is already wrong, because removing - here breaks (here on purpose) the indentation. So the indentation level ends up being wrong (5th image). But the 4th picture wrongness is useful to make multiline list items (I believe), the second backspace just sets the cursor to a useless position: typing here makes no sense, for the writer and the renderer.

Numbered lists may have the same issue but I’m not familiar with them.

Thank you for your help

You can continue the outer list item by adding content at a two-space indent if you put in a blank line. I don’t think the backspacing stopping at that indentation level is a problem.

“If I put a blank line”, so that does mean that the cursor position right now after two backspaces is useless no? We can’t type here, we have to (1) press enter to do what you suggested or (2) press 2 spaces to be back on a 4 space indent.

I understand that this is the required position to make (1) work, but it leads to (2) which is counter intuitive for anyone using soft tabs to indent, which usually avoids any kind of space bar use for indents.

Can a compromise be made by adding a intermediary back space step which sets the cursor to a regular 4 space indentation level, between the two actual states?