Persist selections for editors (#25083)

Part of https://github.com/zed-industries/zed/issues/7371
Closes https://github.com/zed-industries/zed/issues/12853

Release Notes:

- Started to persist latest selections for editors, to restore those on
restart
This commit is contained in:
Kirill Bulatov 2025-02-18 16:27:00 +02:00 committed by GitHub
parent b34037876e
commit 80458ffb96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 159 additions and 5 deletions

View file

@ -1079,6 +1079,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
})
@ -1134,6 +1135,12 @@ 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,
@ -1152,6 +1159,7 @@ impl SerializableItem for Editor {
window.spawn(cx, |mut cx| async move {
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(&mut 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);
})?;
Ok(editor)