Skip to content

fix(editor): preserve indent after compound closers - #328

Merged
fcoury-oai merged 2 commits into
mainfrom
fcoury/compound-closer-indent
Aug 23, 2026
Merged

fcoury-oai merged 2 commits into
mainfrom
fcoury/compound-closer-indent

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Opening a line after compound closing delimiters could over-dedent it. In Rust, for example, pressing o after }), moved the new line and cursor to the enclosing block instead of keeping them aligned with the sibling field. The same shared indentation logic affected JavaScript, JSON, Lua, and other delimiter-based language packs.

This change treats adjacent leading closers as one visual indentation group when their matching openers originated on the same source line. Closers for openers on earlier lines remain separate, preserving genuine structural dedents. It also adds editor-level coverage for o, O, and Enter, plus portable Rust, JavaScript, JSON, and Lua fixtures.

How to Test

  1. Open a Rust buffer containing:

    let isolated_client = Self {
        state: Arc::new(ModelClientState {
        }),
    };

    Place the cursor on }), and press o. The new line and cursor should remain aligned with state, not the enclosing let.

  2. Run cargo test --lib syntax_indent::tests::. All provider tests should pass, including the grouped-closer and cross-language fixtures.

  3. Run cargo test --test editing rust_syntax_indentation_. All six focused editor tests should pass, covering o, O, Enter, undo, typed closers, and the distinct-opener-line dedent regression.

@fcoury-oai
fcoury-oai merged commit 92a4af9 into main Aug 23, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/compound-closer-indent branch August 23, 2026 16:32
@fcoury
fcoury restored the fcoury/compound-closer-indent branch August 23, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant