Do not fail hard on selection persistence if the editor is removed (#25120)

Follow-up of https://github.com/zed-industries/zed/pull/25083

Follows practices from editors' scroll position persisting:
5a05b7461e/crates/editor/src/persistence.rs (L200)
and do not fail hard if the editor with the ID given does not exist.
Also add the problematic IDs into the error context to see them in the
error logs.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-02-19 00:52:23 +02:00 committed by GitHub
parent 98ea659af6
commit 92f128ebb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -2223,7 +2223,7 @@ impl Editor {
.collect();
DB.save_editor_selections(editor_id, workspace_id, selections)
.await
.context("persisting editor selections")
.with_context(|| format!("persisting editor selections for editor {editor_id}, workspace {workspace_id:?}"))
.log_err();
});
}

View file

@ -247,7 +247,7 @@ impl EditorDb {
r#"
DELETE FROM editor_selections WHERE editor_id = ?1 AND workspace_id = ?2;
INSERT INTO editor_selections (editor_id, workspace_id, start, end)
INSERT OR IGNORE INTO editor_selections (editor_id, workspace_id, start, end)
VALUES {placeholders};
"#
);