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
This commit is contained in:
Kirill Bulatov
2025-11-06 11:37:27 +00:00
committed by GitHub
parent fb46bae3ed
commit 149eedb73d
+9 -9
View File
@@ -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();
});