zed/crates
Thorsten Ball 9241b11e1f
Restore unsaved buffers on restart (#13546)
This adds the ability for Zed to restore unsaved buffers on restart. The
user is no longer prompted to save/discard/cancel when trying to close a
Zed window with dirty buffers in it. Instead those dirty buffers are
stored and restored on restart.

It does this by saving the contents of dirty buffers to the internal
SQLite database in which Zed stores other data too. On restart, if there
are dirty buffers in the database, they are restored.

On certain events (buffer changed, file saved, ...) Zed will serialize
these buffers, throttled to a 100ms, so that we don't overload the
machine by saving on every keystroke. When Zed quits, it waits until all
the buffers are serialized.


### Current limitations
- It does not persist undo-history (right now we don't persist/restore
undo-history regardless of dirty buffers or not)
- It does not restore buffers in windows without projects/worktrees.
Example: if you open a new window with `cmd-shift-n` and type something
in a buffer, this will _not_ be stored and you will be asked whether to
save/discard on quit. In the future, we want to fix this by also
restoring windows without projects/worktrees.

### Demo



https://github.com/user-attachments/assets/45c63237-8848-471f-8575-ac05496bba19



### Related tickets

I'm unsure about closing them, without also fixing the 2nd limitation:
restoring of worktree-less windows. So let's wait until that.

- https://github.com/zed-industries/zed/issues/4985
- https://github.com/zed-industries/zed/issues/4683

### Note on performance

- Serializing editing buffer (asynchronously on background thread) with
500k lines takes ~200ms on M3 Max. That's an extreme case and that
performance seems acceptable.

Release Notes:

- Added automatic restoring of unsaved buffers. Zed can now be closed
even if there are unsaved changes in buffers. One current limitation is
that this only works when having projects open, not single files or
empty windows with unsaved buffers. The feature can be turned off by
setting `{"session": {"restore_unsaved_buffers": false}}`.

---------

Co-authored-by: Bennet <bennet@zed.dev>
Co-authored-by: Antonio <antonio@zed.dev>
2024-07-17 18:10:20 +02:00
..
activity_indicator Make LSP task cancellation discoverable (#13226) 2024-06-18 12:44:35 -07:00
anthropic Make Claude 3.5 the default Anthropic model (#13324) 2024-06-21 18:47:38 +02:00
assets Move from Zed fonts to IBM Plex (#13596) 2024-06-27 14:36:44 -06:00
assistant Add an experimental, WIP diagnostics grouping panel (#14515) 2024-07-15 22:58:18 +03:00
assistant_slash_command Lay the groundwork for collaborating on assistant panel (#13991) 2024-07-10 17:36:22 +02:00
assistant_tooling Bring the Tool Calling README up to date (#11683) 2024-05-12 04:47:19 -07:00
audio Make tests less noisy (#12463) 2024-05-29 18:06:45 -07:00
auto_update auto-updates: Do not poll for updates on dev channel (#13311) 2024-06-20 15:00:54 +02:00
breadcrumbs Minor breadcrumb style updates (#14070) 2024-07-10 14:04:17 -04:00
call Remove never-used client parameter from message handler functions (#13406) 2024-06-22 16:07:36 -07:00
channel Remove never-used client parameter from message handler functions (#13406) 2024-06-22 16:07:36 -07:00
cli Open URIs from the CLI, support for the zed:// URI scheme on Linux (#14104) 2024-07-16 14:49:15 -06:00
client Extract a BufferStore object from Project (#14037) 2024-07-12 15:25:54 -07:00
clock Lay the groundwork for collaborating on assistant panel (#13991) 2024-07-10 17:36:22 +02:00
collab collab: Fix exact extension filtering (#14591) 2024-07-16 15:18:48 -04:00
collab_ui Introduce following for assistant panel (#14479) 2024-07-15 11:36:27 +02:00
collections gpui: Add SVG rendering to img element and generic asset cache (#9931) 2024-03-29 17:09:49 -07:00
command_palette Use UpdateGlobal accessors in more places (#11925) 2024-05-16 13:30:04 -04:00
command_palette_hooks Introduce InlineCompletionProvider (#9777) 2024-03-26 13:28:06 +01:00
copilot paths: Replace lazy_static! with OnceLock (#13213) 2024-06-18 12:22:37 -04:00
db paths: Replace lazy_static! with OnceLock (#13213) 2024-06-18 12:22:37 -04:00
dev_server_projects remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
diagnostics Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
editor Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
extension Allow Zed Nightly to use v0.0.7 of the Zed extension API (#14209) 2024-07-11 10:54:15 -04:00
extension_api zed_extension_api: Return structured slash command completions (#13879) 2024-07-05 14:08:42 -04:00
extension_cli extension_cli: Allow building without dynamically linking WebRTC (#13080) 2024-06-14 20:13:31 -04:00
extensions_ui Rank exact extension ID matches higher in search results (#14588) 2024-07-16 12:33:28 -06:00
feature_flags Add an experimental, WIP diagnostics grouping panel (#14515) 2024-07-15 22:58:18 +03:00
feedback Refine inline transformation UX (#12939) 2024-06-13 08:35:22 +02:00
file_finder remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
file_icons Make tests less noisy (#12463) 2024-05-29 18:06:45 -07:00
fs Add support for projects managed with Yarn (#13644) 2024-07-11 14:56:07 +02:00
fsevent Retain run loop (#11241) 2024-04-30 23:31:59 -06:00
fuzzy Introduce an outline panel (#12637) 2024-06-12 23:22:52 +03:00
git Introduce an outline panel (#12637) 2024-06-12 23:22:52 +03:00
git_hosting_providers Extract http from util (#11680) 2024-05-10 15:50:20 -06:00
go_to_line Add more menus to Zed (#12940) 2024-06-18 12:16:54 -07:00
google_ai Respect requested gemini model (#13427) 2024-06-23 14:10:31 -06:00
gpui Fix text appearing twice after Chinese character input (#14558) 2024-07-16 10:54:53 -07:00
gpui_macros Upsell built-in features on the extensions page (#14516) 2024-07-15 17:10:01 -04:00
headless remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
html_to_markdown Publish html_to_markdown (#13718) 2024-07-01 17:18:58 -04:00
http zed_extension_api: Add github_release_by_tag_name (#12172) 2024-05-22 20:40:31 -04:00
image_viewer Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
indexed_docs assistant: Add basic glob support for expanding items in /docs (#14370) 2024-07-12 17:57:50 -04:00
inline_completion_button Change the context menu and Copilot settings icon (#14501) 2024-07-16 09:40:40 -03:00
install_cli Fix flickering (#9012) 2024-03-11 10:45:57 +01:00
journal Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
language Introduce /symbols command in assistant panel (#14360) 2024-07-15 11:51:32 +02:00
language_selector Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
language_tools ui: Use PopoverMenu::new for constructing PopoverMenus (#13178) 2024-06-17 18:14:37 -04:00
languages Respect user preference for JS/TS on_type formatting (#14536) 2024-07-17 11:11:00 +02:00
live_kit_client linux: Panic less on window init (#14255) 2024-07-11 16:04:46 -06:00
live_kit_server Vendor LiveKit protocol (#11672) 2024-05-10 14:18:40 -04:00
lsp Support dynamic formatting capabilities [un]registration (#14478) 2024-07-15 12:27:33 +03:00
markdown Selectable popover text (#12918) 2024-07-10 21:14:34 -06:00
markdown_preview Refine inline transformation UX (#12939) 2024-06-13 08:35:22 +02:00
media Revert "Revert "Revert dependency updates in #9836 (#10089)"" 2024-04-02 13:12:38 -06:00
menu open picker (#14524) 2024-07-15 17:04:15 -06:00
multi_buffer Add an experimental, WIP diagnostics grouping panel (#14515) 2024-07-15 22:58:18 +03:00
node_runtime JSON: Show package.json dependency tooltips on hover (#13481) 2024-06-25 14:59:29 +02:00
notifications Remove never-used client parameter from message handler functions (#13406) 2024-06-22 16:07:36 -07:00
ollama Allow Ollama Model KeepAlive to be None, defaulting to indefinite (#13059) 2024-06-14 10:33:28 -07:00
open_ai Change tool_calls to be an Option in response (#13778) 2024-07-03 11:07:11 -04:00
outline Add a way to filter items in the outline panel (#13984) 2024-07-09 16:44:24 +03:00
outline_panel Do not fold excerpts by default in the outline panel (#14378) 2024-07-13 04:08:21 +03:00
paths settings: Load .zed/settings.json even if .gitignored (#13370) 2024-06-21 18:39:14 +02:00
picker open picker (#14524) 2024-07-15 17:04:15 -06:00
prettier Lookup prettier more leniently (#14403) 2024-07-13 21:59:14 +03:00
project Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
project_panel remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
project_symbols Add more menus to Zed (#12940) 2024-06-18 12:16:54 -07:00
proto remoting: Allow Add/Remove remote folder (#14532) 2024-07-16 12:01:59 -06:00
quick_action_bar Refactor repl context menu (#14587) 2024-07-16 12:18:06 -07:00
recent_projects Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
refineable Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
release_channel auto-updates: Do not poll for updates on dev channel (#13311) 2024-06-20 15:00:54 +02:00
repl repl: Don't send KernelInfoRequest on launch (#14608) 2024-07-16 15:51:23 -07:00
rich_text New revision of the Assistant Panel (#10870) 2024-04-23 16:23:26 -07:00
rope Indent guides (#11503) 2024-05-23 15:50:59 +02:00
rpc Rank exact extension ID matches higher in search results (#14588) 2024-07-16 12:33:28 -06:00
search Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
semantic_index Refactor: Make it possible to share a remote worktree (#12775) 2024-06-07 12:53:01 -07:00
semantic_version Extract SemanticVersion into its own crate (#9956) 2024-03-29 12:11:57 -04:00
settings Show an initial empty keymap (#14609) 2024-07-16 20:24:13 -06:00
snippet html: Add support for autoclosing of tags (#11761) 2024-05-20 17:00:27 +02:00
snippet_provider extensions: Add support for snippets provided by extensions (#14020) 2024-07-10 09:40:50 +02:00
sqlez Remove extraneous Cargo.lock files (#14001) 2024-07-09 12:15:34 -04:00
sqlez_macros Dynamicer builds (#13074) 2024-06-21 16:32:32 -07:00
story Introduce a new markdown crate (#11556) 2024-05-09 11:03:33 +02:00
storybook linux: Panic less on window init (#14255) 2024-07-11 16:04:46 -06:00
sum_tree Introduce Editor::insert_flaps and Editor::remove_flaps (#12096) 2024-05-21 20:23:37 +02:00
supermaven Reduce spamming of inline completion discard events (#11999) 2024-05-17 16:37:17 -04:00
supermaven_api paths: Replace lazy_static! with OnceLock (#13213) 2024-06-18 12:22:37 -04:00
tab_switcher Introduce recent files ambient context for assistant (#11791) 2024-05-14 13:48:36 +02:00
task task: Add re-run task button to terminal title (#12379) 2024-05-29 11:40:43 +02:00
tasks_ui open picker (#14524) 2024-07-15 17:04:15 -06:00
telemetry_events Add metrics_id to editor_events (#13525) 2024-06-25 16:47:55 -04:00
terminal Revert hold: true for macOS tasks (#14376) 2024-07-13 04:02:38 +03:00
terminal_view Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
text Lay the groundwork for collaborating on assistant panel (#13991) 2024-07-10 17:36:22 +02:00
theme linux: Indicate when the window is focused (#14266) 2024-07-12 14:20:58 -07:00
theme_importer linux: Panic less on window init (#14255) 2024-07-11 16:04:46 -06:00
theme_selector Use UpdateGlobal accessors in more places (#11925) 2024-05-16 13:30:04 -04:00
time_format Inline git blame (#10398) 2024-04-15 14:21:52 +02:00
title_bar Fix context in command palette from application menu (#14599) 2024-07-16 15:14:18 -06:00
ui Change the context menu and Copilot settings icon (#14501) 2024-07-16 09:40:40 -03:00
ui_input Rename ui_text_field crate to ui_input (#13949) 2024-07-08 17:05:30 -04:00
util Associate logs from log_err with the calling crate (#13617) 2024-06-27 17:03:47 -07:00
vcs_menu Adjust list item & pickers spacing (#14250) 2024-07-15 10:23:18 -03:00
vim vim: Add :bd/:bp/:bn (#14623) 2024-07-16 23:06:08 -06:00
welcome linux: Hide Install CLI from welcome (#14506) 2024-07-15 12:08:37 -06:00
workspace Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
worktree Extract a BufferStore object from Project (#14037) 2024-07-12 15:25:54 -07:00
zed Restore unsaved buffers on restart (#13546) 2024-07-17 18:10:20 +02:00
zed_actions Add more menus to Zed (#12940) 2024-06-18 12:16:54 -07:00