Fix postfix completion indentation compensation#21324
Fix postfix completion indentation compensation#21324ChayimFriedman2 merged 2 commits intorust-lang:masterfrom
Conversation
Editor adds the current indentation to the content of the code snippet
This PR dedentation is used to offset the editor snippet indentation
Example
---
```rust
fn foo(x: Option<i32>, y: Option<i32>) {
let _f = || {
x
.and(y)
.map(|it| it+2)
.$0
};
}
```
**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);
};
}
```
ChayimFriedman2
left a comment
There was a problem hiding this comment.
It feels a bit wrong to change the indentation of existing code, and it's not a severe issue since formatting will fix that anyway... Are all editors indenting like that?
The language server protocol can adjust this behavior
A dedentation is the least disruptive implementation
Frequent formatting greatly affects the user experience, |
|
Small note that this would fixup #13370, thanks!
I'd rather go for the route for using |
I didn't look at the entire file, I only extracted the indentation of the current line |
|
I meant needing to pull the file text, which I realized is something that we already do 😅 |
|
Can this PR be merge now? |
Editor adds the current indentation to the content of the code snippet
This PR dedentation is used to offset the editor snippet indentation
Fixes #13370
Example
Before this PR
After this PR