Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Kirill Bulatov92f128ebb099
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 664882af8e4..0788d7d51d4 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -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();
});
}
diff --git a/crates/editor/src/persistence.rs b/crates/editor/src/persistence.rs
index e8d2ed05d43..d8e9331c4b4 100644
--- a/crates/editor/src/persistence.rs
+++ b/crates/editor/src/persistence.rs
@@ -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};
"#
);