From 149eedb73d8b9339e90a11df93f142c46fb98b9d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 6 Nov 2025 13:37:27 +0200 Subject: [PATCH] Fix scroll position restoration (#42088) Follow-up of https://github.com/zed-industries/zed/pull/42035 Scroll position needs to be stored immediately, otherwise editor close may not register that. Release Notes: - N/A --- crates/editor/src/editor.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 9df60acb3226318b2aee860b43dbd4d9b5178323..69196feb3473f1ec71088694660aeb3dee18b2bd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2298,6 +2298,15 @@ impl Editor { if *local { editor.hide_signature_help(cx, SignatureHelpHiddenBy::Escape); editor.inline_blame_popover.take(); + let new_anchor = editor.scroll_manager.anchor(); + let snapshot = editor.snapshot(window, cx); + editor.update_restoration_data(cx, move |data| { + data.scroll_position = ( + new_anchor.top_row(snapshot.buffer_snapshot()), + new_anchor.offset, + ); + }); + editor.post_scroll_update = cx.spawn_in(window, async move |editor, cx| { cx.background_executor() .timer(Duration::from_millis(50)) @@ -2310,15 +2319,6 @@ impl Editor { InlayHintRefreshReason::NewLinesShown, cx, ); - - let new_anchor = editor.scroll_manager.anchor(); - let snapshot = editor.snapshot(window, cx); - editor.update_restoration_data(cx, move |data| { - data.scroll_position = ( - new_anchor.top_row(snapshot.buffer_snapshot()), - new_anchor.offset, - ); - }); }) .ok(); });