A few of our users have requested that this doesn’t happen. The use case is adding blank lines in an indented block and then going back to add content to that line later. E.g. see the gif below. The middle steps are:
Type bar
Press Return twice
Optional: Type baz
Press ArrowUp
Expected: Indentation is maintained
Observed: Indentation has been removed and the user has to press Space a couple of times or Tab to start editing with the appropriate indentation.
Just to make sure I understand, you are working in a context where blank lines with trailing space are an expected part of the code, and committed to the repository? Most linters I am familiar with complain about trailing space, and in general programmer culture, leaving that kind of spacing in is considered sloppy and undesirable. Since our default Enter binding adds auto-indentation, it also removes it again if the line is left blank, in order to not create this kind of mess.
You are free to bind Enter to another command of course. I could even be convinced to export a command that behaves this way (auto-indent, but don’t strip trailing space) to @codemirror/commands. But at the moment I don’t really see why it would be a good idea.
I work at Overleaf, so our users write in LaTeX and most of them would just be collaborating with other users and not commit to a repository as such. Some do collaborate with users from other IDEs though. There also aren’t very standardised rules for indenting in LaTeX, so we simply follow the indentation from the previous line when pressing Enter.
OK yes upon looking a bit more, it does seem to be more standard than I first believed to strip whitespace. It looks like some workflows get around this by stripping whitespace on save or on commit, but I can see why you wouldn’t want the spaces/tabs to remain in CM6 by default.
You are free to bind Enter to another command of course
Yes we can see how to change it for our use case if we want, although we’re trying to stick to the core CM6 behaviour where possible, to avoid extra maintenance work. I’ll discuss with the team, but we’ll probably stick as it is, thanks for clarifying.