Python FencedCode indentation inconsistent

Hi!

I’m playing around with markdown and embedded code, and I noticed that the python indentation is inconsistent when there’s no space after the current line. The example below is from the codemirror MD example I think what’s happening is that the insertNewlineContinueMarkup is being called but once there’s space below the cursor, insertNewlineAndIndent is called, though I’m not entirely sure.

I know there’s some places where markdown needs extra support for embedded code like in completions, and I was wondering if that’s the same case here where I need to add or do something to get the correct behavior, or could this be a bug or just a limitation of embedding code in markdown and just handle it with an Enter keymap?

Thanks!

indent

Might it be related to the parsing? Commenting on the first line of the fenced code also applied markdown comment, also happens with JS codeblocks.

comment

This was two separate issues, both caused by confusion around language boundaries. See these patches.

1 Like

Thank you very much for your work!

Hi there! I recently upgraded to the latest @codemirror/language version, and was able to pin down our issue to this change: Improve behavior of syntax indentation on language boundaries · codemirror/language@8b28e31 · GitHub

We have different languages as well, but users are now no longer able to press enter when in-between boundaries:

<tag>{foo.bar}|</tag>
              ^ cursor

Nothing happens when pressing enter here.

Nothing happening when you press enter is a strange outcome of this patch. It just changes the node from which indentation is computed in some circumstances. If you have enter bound to something like insertNewlineAndIndent, there’s not really a way in which that could cause the new line insertion to not happen — except possibly if there’s a crash. Did you check the console?

See issue 1494, which suggests this was probably a crash. Using @codemirror/language 6.10.8 should help.