Skip to content

fix: editor postfix dedent uses current cursor#22286

Open
A4-Tacks wants to merge 2 commits intorust-lang:masterfrom
A4-Tacks:editor-dedent-cur-cursor
Open

fix: editor postfix dedent uses current cursor#22286
A4-Tacks wants to merge 2 commits intorust-lang:masterfrom
A4-Tacks:editor-dedent-cur-cursor

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

@A4-Tacks A4-Tacks commented May 4, 2026

Fixup #21324

I realized that the editor indentation is based on the current cursor position, not the position after completion

Example

fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        x
            .and(y)
            .map(|it| it+2)
            .let;
    };
}

Before this PR

fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        let $0 = x
                .and(y)
                .map(|it| it+2);
    };
}

After this PR

fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        let $0 = x
            .and(y)
            .map(|it| it+2);
    };
}

I realized that the editor indentation is based on the current cursor position, not the position after completion

Example
---
```rust
fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        x
            .and(y)
            .map(|it| it+2)
            .let;
    };
}
```

**Before this PR**

```rust
fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        let $0 = x
                .and(y)
                .map(|it| it+2);
    };
}
```

**After this PR**

```rust
fn foo(x: Option<i32>, y: Option<i32>) {
    let _f = || {
        let $0 = x
            .and(y)
            .map(|it| it+2);
    };
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants