Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,9 @@ impl SerializableItem for Editor {
let project = self.project.clone()?;

let serialize_dirty_buffers = match buffer_serialization {
// If we don't have a worktree, we don't serialize, because
// projects without worktrees aren't deserialized.
BufferSerialization::All => project.read(cx).visible_worktrees(cx).next().is_some(),
// Always serialize dirty buffers, including for worktree-less windows.
// This enables hot-exit functionality for empty windows and single files.
BufferSerialization::All => true,
BufferSerialization::NonDirtyBuffers => false,
};

Expand Down
7 changes: 4 additions & 3 deletions crates/workspace/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,8 @@ impl WorkspaceDb {
// WSL VM and file server to boot up. This can block for many seconds.
// Supported scenarios use remote workspaces.
if !has_wsl_path && paths.paths().iter().all(|path| path.exists()) {
// Only show directories in recent projects
if paths.paths().iter().any(|path| path.is_dir()) {
// Include workspaces with directories, or empty workspaces (for hot-exit support)
if paths.is_empty() || paths.paths().iter().any(|path| path.is_dir()) {
result.push((id, SerializedWorkspaceLocation::Local, paths));
}
} else {
Expand Down Expand Up @@ -1405,8 +1405,9 @@ impl WorkspaceDb {
window_id.map(WindowId::from),
));
} else if paths.paths().iter().all(|path| path.exists())
&& paths.paths().iter().any(|path| path.is_dir())
&& (paths.is_empty() || paths.paths().iter().any(|path| path.is_dir()))
{
// Include workspaces with directories, or empty workspaces (for hot-exit support)
workspaces.push((
SerializedWorkspaceLocation::Local,
paths,
Expand Down
16 changes: 3 additions & 13 deletions crates/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,6 @@ pub enum OpenVisible {
enum WorkspaceLocation {
// Valid local paths or SSH project to serialize
Location(SerializedWorkspaceLocation, PathList),
// No valid location found hence clear session id
DetachFromSession,
// No valid location found to serialize
None,
}
Expand Down Expand Up @@ -5537,12 +5535,6 @@ impl Workspace {
persistence::DB.save_workspace(serialized_workspace).await;
})
}
WorkspaceLocation::DetachFromSession => window.spawn(cx, async move |_| {
persistence::DB
.set_session_id(database_id, None)
.await
.log_err();
}),
WorkspaceLocation::None => Task::ready(()),
}
}
Expand All @@ -5552,11 +5544,9 @@ impl Workspace {
if let Some(connection) = self.project.read(cx).remote_connection_options(cx) {
WorkspaceLocation::Location(SerializedWorkspaceLocation::Remote(connection), paths)
} else if self.project.read(cx).is_local() {
if !paths.is_empty() {
WorkspaceLocation::Location(SerializedWorkspaceLocation::Local, paths)
} else {
WorkspaceLocation::DetachFromSession
}
// Always serialize local workspaces, even without worktrees.
// This enables hot-exit functionality for empty windows and single files.
WorkspaceLocation::Location(SerializedWorkspaceLocation::Local, paths)
} else {
WorkspaceLocation::None
}
Expand Down