Pressing Return on a line that is already blank inserts two line breaks instead of one, so every press adds two blank lines rather than one.
Steps to reproduce
-
Open Omawrite with one, a blank line, then two:
-
Put the caret on the blank line.
-
Press Return once.
Expected
One new blank line:
Actual
Two:
Pressing Return again adds two more, so the gap grows in twos: one\n\n\n\n\n\ntwo.
It also shows up in an empty document — the first Return leaves two blank lines rather than one.
Where it comes from
smartReturn in src/Main.qml ends with a fallback for any line that is not a list item and not inside a code fence:
replaceSelectionWith("\n\n");
That is right for a paragraph: a new paragraph in this editor is separated from the one above by a blank line, so Return at the end of two correctly produces two\n\n. But on a line that is already blank there is no paragraph to separate from, and the separator becomes a second empty line nobody asked for.
The list-item and code-fence branches above it are unaffected — both insert a single \n.
Verified on
master at 8f98892, by driving a real window in the test harness with the keyboard:
| Start (caret) |
Key |
Result |
one\n\ntwo (on the blank line) |
Return |
one\n\n\n\ntwo ❌ |
one\n\ntwo (end of two) |
Return |
one\n\ntwo\n\n ✅ |
| `` (empty document) |
Return |
\n\n ❌ |
one\n\ntwo (on the blank line) |
Return ×2 |
one\n\n\n\n\n\ntwo ❌ |
Happy to send a PR if that is useful.
Pressing Return on a line that is already blank inserts two line breaks instead of one, so every press adds two blank lines rather than one.
Steps to reproduce
Open Omawrite with
one, a blank line, thentwo:Put the caret on the blank line.
Press Return once.
Expected
One new blank line:
Actual
Two:
Pressing Return again adds two more, so the gap grows in twos:
one\n\n\n\n\n\ntwo.It also shows up in an empty document — the first Return leaves two blank lines rather than one.
Where it comes from
smartReturninsrc/Main.qmlends with a fallback for any line that is not a list item and not inside a code fence:That is right for a paragraph: a new paragraph in this editor is separated from the one above by a blank line, so Return at the end of
twocorrectly producestwo\n\n. But on a line that is already blank there is no paragraph to separate from, and the separator becomes a second empty line nobody asked for.The list-item and code-fence branches above it are unaffected — both insert a single
\n.Verified on
masterat 8f98892, by driving a real window in the test harness with the keyboard:one\n\ntwo(on the blank line)one\n\n\n\ntwo❌one\n\ntwo(end oftwo)one\n\ntwo\n\n✅\n\n❌one\n\ntwo(on the blank line)one\n\n\n\n\n\ntwo❌Happy to send a PR if that is useful.