Yes, a code block must be indented on all lines if nested inside a list item. It is a bug that the indentation is removed when you start typing. We have a pending fix for it already.
We are also working on other code block improvements so that the end marker would have been automatically added in this case.