Restore editor state on reopen (#27672)

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

`"restore_on_file_reopen": true` in workspace settings can now be used
to enable and disable editor data between file reopens in the same pane:


https://github.com/user-attachments/assets/8d938ee1-d854-42a8-bbc3-2a4e4d7d5933

The settings are generic and panes' data store can be extended for
further entities, beyond editors.

---------------
Impl details: 

Currently, the project entry IDs seem to be stable across file reopens,
unlike BufferIds, so those were used.
Originally, the DB data was considered over in-memory one as editors
serialize their state anyway, but managing and exposing PaneIds out of
the DB is quite tedious and joining the DB data otherwise is not
possible.


Release Notes:

- Started to restore editor state on reopen
This commit is contained in:
Kirill Bulatov 2025-03-29 00:04:16 +02:00 committed by GitHub
parent bbd1e628f0
commit e11e7df724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 611 additions and 48 deletions

View file

@ -17,7 +17,7 @@ use project::{Project, ProjectEntryId, ProjectPath};
use ui::{prelude::*, Tooltip};
use workspace::item::{ItemEvent, TabContentParams};
use workspace::searchable::SearchableItemHandle;
use workspace::{Item, ItemHandle, ProjectItem, ToolbarItemLocation};
use workspace::{Item, ItemHandle, Pane, ProjectItem, ToolbarItemLocation};
use workspace::{ToolbarItemEvent, ToolbarItemView};
use super::{Cell, CellPosition, RenderableCell};
@ -825,6 +825,7 @@ impl ProjectItem for NotebookEditor {
fn for_project_item(
project: Entity<Project>,
_: &Pane,
item: Entity<Self::Item>,
window: &mut Window,
cx: &mut Context<Self>,