Persist editor folds between restarts (#27252)

Part of https://github.com/zed-industries/zed/issues/11626


https://github.com/user-attachments/assets/276cca5f-dd87-4496-b1b8-40b211f65aa7

Folds restoration between editor reopens will follow later

Release Notes:

- Started to persist editor folds between restarts
This commit is contained in:
Kirill Bulatov 2025-03-21 17:28:11 +02:00 committed by GitHub
parent 93bd32b425
commit 6397872c49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 173 additions and 35 deletions

View file

@ -1078,8 +1078,7 @@ impl SerializableItem for Editor {
cx.new(|cx| {
let mut editor = Editor::for_buffer(buffer, Some(project), window, cx);
editor.read_selections_from_db(item_id, workspace_id, window, cx);
editor.read_scroll_position_from_db(item_id, workspace_id, window, cx);
editor.read_metadata_from_db(item_id, workspace_id, window, cx);
editor
})
})
@ -1137,18 +1136,7 @@ impl SerializableItem for Editor {
let mut editor =
Editor::for_buffer(buffer, Some(project), window, cx);
editor.read_selections_from_db(
item_id,
workspace_id,
window,
cx,
);
editor.read_scroll_position_from_db(
item_id,
workspace_id,
window,
cx,
);
editor.read_metadata_from_db(item_id, workspace_id, window, cx);
editor
})
})
@ -1169,8 +1157,7 @@ impl SerializableItem for Editor {
window.spawn(cx, async move |cx| {
let editor = open_by_abs_path?.await?.downcast::<Editor>().with_context(|| format!("Failed to downcast to Editor after opening abs path {abs_path:?}"))?;
editor.update_in(cx, |editor, window, cx| {
editor.read_selections_from_db(item_id, workspace_id, window, cx);
editor.read_scroll_position_from_db(item_id, workspace_id, window, cx);
editor.read_metadata_from_db(item_id, workspace_id, window, cx);
})?;
Ok(editor)
})