Skip to content

Commit

Permalink
Do not fail hard on selection persistence if the editor is removed (#…
Browse files Browse the repository at this point in the history
…25120)

Follow-up of #25083

Follows practices from editors' scroll position persisting:
https://github.com/zed-industries/zed/blob/5a05b7461e476d7ddc59418868ebdab6687b8d2f/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
  • Loading branch information
SomeoneToIgnore authored Feb 18, 2025
1 parent 98ea659 commit 92f128e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
"#
);
Expand Down

0 comments on commit 92f128e

Please sign in to comment.