Skip to content

Backspace only removes one formatting character from an empty formatting snippet #468

Closed

Description

@uNyanda
  • Date: 2026-07-24
  • Type: Bug
  • Severity: Minor

Environment

  • OS: Linux
  • WM: Niri
  • Compositor: Wayland
  • Software version: 2.16.0

Description

When a formatting shortcut inserts an empty Markdown formatting snippet, pressing Backspace before entering any text only removes a single formatting character instead of removing the entire snippet.

This affects all formatting shortcuts.

Steps to reproduce

  1. Create or open a note.
  2. Use any formatting shortcut (for example, Ctrl+B for Bold).
  3. Without typing any text, press Backspace.

Expected Behaviour

If no text has been entered, pressing Backspace should remove the entire inserted formatting snippet in a single action.

For example:

  • Bold: **|** -> (removed completely)
  • Italic: *|* -> (removed completely)
  • Strikethrough: ~~|~~ -> (removed completely)
  • Highlight: ==|== -> (removed completely)
  • Inline code: | -> (removed completely)

Actual Behaviour

Only a single formatting character is removed, leaving incomplete Markdown.

Examples:

  • Bold: **|** -> *|**
  • Italic: *|* -> |*
  • Strikethrough: ~~|~~ -> ~|~~
  • Highlight: ==|== -> =|==
  • Inline code: | -> |`

Additional Notes

This issue is reproducible with every formatting shortcut tested, suggesting the behaviour is not specific to a single formatting selection.

Activity

  1. adibhanna commented on Jul 24, 2026

    @adibhanna
    Contributor

    Fixed.

    Pressing Backspace inside a just-inserted empty formatting snippet now removes the whole pair in a single press instead of one marker character. This works for every formatting shortcut:

    • Bold **|**, Italic *|*, Strikethrough ~~|~~, Highlight ==|==, Inline code `|`, Math $|$ → all cleared completely.

    It matches on the longest marker first, so **|** clears all four characters, not *|*. A snippet that already has text (**text|**) is untouched — Backspace deletes normally there. The handler is gated the same way as the auto-close/auto-pairs behavior (active while typing — Vim off or Vim insert mode), so it never interferes with Backspace as a motion in Vim normal mode.

    Verified in the running app (Ctrl+B → **|** → one Backspace → gone) and with unit + editor-keymap tests covering every marker.

    Ships in v2.17.0.

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