Skip to content

Conversation

@smitbarmase
Copy link
Member

@smitbarmase smitbarmase commented Nov 17, 2025

The bug is in the place_near logic, specifically the !row_block_types.contains_key(&(row - 1)) check. The problem isn’t really that condition itself, but it’s that it relies on row_block_types, which does not take into account that upon block resizes, subsequent block start row moves up/down. Since place_near depends on this incorrect map, it ends up causing incorrect resize syncs to the block map, which then triggers more bad recursive calls. The reason it worked till now in most of the cases is that recursive resizes eventually lead to stabilizing it.

Before place_near, we never touched row_block_types during the first prepaint pass because we knew it was based on outdated heights. Once all heights are finalized, using it is fine.

The fix is to make sure row_block_types is accurate from the very first prepaint pass by keeping an offset whenever a block shrinks or expands. Now ideally it should take only one subsequent prepaint. But due to shrinking, new custom/diagnostics blocks might come into the view from below, which needs further prepaint calls for resolving. Right now, tests pass after 2 subsequent prepaint calls. Just to be safe, we have set it to 5.

image

Release Notes:

  • Fix issue where sometimes Zed used to experience freeze while working with inline diagnostics.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 17, 2025
@smitbarmase smitbarmase changed the title editor: Fix prepaint recursion when updating stale sizes is not stable editor: Fix prepaint recursion when updating stale sizes Nov 19, 2025
@smitbarmase smitbarmase merged commit 79be5cb into main Nov 19, 2025
41 of 43 checks passed
@smitbarmase smitbarmase deleted the fix-editor-prepaint-recursion branch November 19, 2025 15:32
JosephTLyons added a commit that referenced this pull request Nov 19, 2025
mikayla-maki pushed a commit that referenced this pull request Nov 20, 2025
The bug is in the `place_near` logic, specifically the
`!row_block_types.contains_key(&(row - 1))` check. The problem isn’t
really that condition itself, but it’s that it relies on
`row_block_types`, which does not take into account that upon block
resizes, subsequent block start row moves up/down. Since `place_near`
depends on this incorrect map, it ends up causing incorrect resize syncs
to the block map, which then triggers more bad recursive calls. The
reason it worked till now in most of the cases is that recursive resizes
eventually lead to stabilizing it.

Before `place_near`, we never touched `row_block_types` during the first
prepaint pass because we knew it was based on outdated heights. Once all
heights are finalized, using it is fine.

The fix is to make sure `row_block_types` is accurate from the very
first prepaint pass by keeping an offset whenever a block shrinks or
expands. Now ideally it should take only one subsequent prepaint. But
due to shrinking, new custom/diagnostics blocks might come into the view
from below, which needs further prepaint calls for resolving. Right now,
tests pass after 2 subsequent prepaint calls. Just to be safe, we have
set it to 5.

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/da3d32ff-5972-46d9-8597-b438e162552b"
/>

Release Notes:

- Fix issue where sometimes Zed used to experience freeze while working
with inline diagnostics.
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
…ies#42896)

The bug is in the `place_near` logic, specifically the
`!row_block_types.contains_key(&(row - 1))` check. The problem isn’t
really that condition itself, but it’s that it relies on
`row_block_types`, which does not take into account that upon block
resizes, subsequent block start row moves up/down. Since `place_near`
depends on this incorrect map, it ends up causing incorrect resize syncs
to the block map, which then triggers more bad recursive calls. The
reason it worked till now in most of the cases is that recursive resizes
eventually lead to stabilizing it.

Before `place_near`, we never touched `row_block_types` during the first
prepaint pass because we knew it was based on outdated heights. Once all
heights are finalized, using it is fine.

The fix is to make sure `row_block_types` is accurate from the very
first prepaint pass by keeping an offset whenever a block shrinks or
expands. Now ideally it should take only one subsequent prepaint. But
due to shrinking, new custom/diagnostics blocks might come into the view
from below, which needs further prepaint calls for resolving. Right now,
tests pass after 2 subsequent prepaint calls. Just to be safe, we have
set it to 5.

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/da3d32ff-5972-46d9-8597-b438e162552b"
/>

Release Notes:

- Fix issue where sometimes Zed used to experience freeze while working
with inline diagnostics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants