# Reuse layout for view's element when it wasn't cached \(\#4156\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 90c2da4dec0f5bdf9a5e2054eac04d68e5380639

Requested commit: 90c2da4dec0f5bdf9a5e2054eac04d68e5380639

Commit: 90c2da4dec0f5bdf9a5e2054eac04d68e5380639

Tree: dbdf633005bf19a73839f5c802080935bd87477f

Author: Antonio Scandurra

Committer: GitHub

## Message

```
Reuse layout for view's element when it wasn't cached (#4156)

Refs https://github.com/zed-industries/zed/pull/4131
Refs https://github.com/zed-industries/community/issues/2415

Previously, when a view cache miss occurred during paint, we would
either use the element produced during layout or create a new, detached
node layout node. In both cases, we would issue a call to `draw`.

The problem with this approach, however, is that `draw` would always
paint the element at the given `bounds.origin`, which was required when
the layout node was detached but harmful when the element was already
embedded in the layout tree and already knew its bounds. In this second
case, in fact, it was as if we were positioning the element "twice",
which caused content to jump.

Release Notes:

- N/A
```

## Parents

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

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

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