Skip to content

Commit 0f29caf

Browse files
committed
fix: editor postfix dedent uses current cursor
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); }; } ```
1 parent f04c372 commit 0f29caf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

crates/ide-completion/src/completions/postfix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ fn get_receiver_text(
398398
}
399399
let file_text = sema.db.file_text(range.file_id.file_id(sema.db));
400400
let text = file_text.text(sema.db);
401-
let indent_spaces = indent_of_tail_line(&text[TextRange::up_to(range.range.start())]);
401+
let indent_spaces = indent_of_tail_line(&text[TextRange::up_to(range.range.end())]);
402402
let mut text = stdx::dedent_by(indent_spaces, &text[range.range]);
403403

404404
// The receiver texts should be interpreted as-is, as they are expected to be
@@ -1667,8 +1667,8 @@ fn foo(x: Option<i32>, y: Option<i32>) {
16671667
fn foo(x: Option<i32>, y: Option<i32>) {
16681668
let _f = || {
16691669
let $0 = x
1670-
.and(y)
1671-
.map(|it| it+2);
1670+
.and(y)
1671+
.map(|it| it+2);
16721672
};
16731673
}
16741674
"#,

0 commit comments

Comments
 (0)