# buffer: Fix broken auto indent when pasting code starting with new line \(\#28134\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/69d7ea7b606f2321307623795c152ccffc1d01e5)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 69d7ea7b606f2321307623795c152ccffc1d01e5

Requested commit: 69d7ea7b606f2321307623795c152ccffc1d01e5

Commit: 69d7ea7b606f2321307623795c152ccffc1d01e5

Tree: 2cb4908fd481b262b487c7f0517d66915e804b7f

Author: Smit Barmase

Committer: GitHub

## Message

```
buffer: Fix broken auto indent when pasting code starting with new line (#28134)

Closes #26907

Currently, in case of new line to find delta, it is comparing old first
line indent with new second line indent. This results into incorrect
indentation. This PR fixes this delta calculation by passing correct
second line indent in that particular case.

- [X] Add Test

Before:


https://github.com/user-attachments/assets/065deba0-be19-4643-a784-d248a8e7c891

After:


https://github.com/user-attachments/assets/a0037043-4bd8-460f-b8ba-b7da7bdbe1ea

Release Notes:

- Fixed issue where pasting code starting with new line resulted
incorrect auto indent.
```

## Parents

- [d0e82b0538079f69008afcfa742ad26cedc3822a](https://git.cafe/gitcafe/zed/commit/d0e82b0538079f69008afcfa742ad26cedc3822a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/69d7ea7b606f2321307623795c152ccffc1d01e5?format=markdown)
