Skip to content

Bug: Code Block formatting applies to unintended adjacent lines #7691

@romancavry

Description

@romancavry

Lexical version: ^0.32.1, 0.33.1

Steps To Reproduce

  1. In rich-text editor, enter three lines of the text:
    aaa
    bbb
    ccc

  2. Select only the middle line (bbb)

  3. Apply code block formatting to the selection

  4. Observe that the resulting code block unexpectedly includes ccc, instead of just wrapping the selected line

Link to code example: https://playground.lexical.dev/

Worth noting: applying a code block to the last line works as expected

Screen.Recording.2025-07-14.at.15.07.38.mov

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions