Skip to content

fix: editor postfix dedent uses current cursor#22286

Merged
ChayimFriedman2 merged 2 commits into
rust-lang:masterfrom
A4-Tacks:editor-dedent-cur-cursor
May 6, 2026
Merged

fix: editor postfix dedent uses current cursor#22286
ChayimFriedman2 merged 2 commits into
rust-lang:masterfrom
A4-Tacks:editor-dedent-cur-cursor

Conversation

@A4-Tacks

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

Copy link
Copy Markdown
Member

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
@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue May 6, 2026
Merged via the queue into rust-lang:master with commit 5fe9d7b May 6, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 6, 2026
@A4-Tacks A4-Tacks deleted the editor-dedent-cur-cursor branch May 6, 2026 16:50
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.

3 participants