Skip to content

Return on a blank line inserts two line breaks instead of one #11

Description

@rodgco

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

  1. Open Omawrite with one, a blank line, then two:

    one
    
    two
    
  2. Put the caret on the blank line.

  3. Press Return once.

Expected

One new blank line:

one


two

Actual

Two:

one



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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions