Compare commits

...

1 Commits

Author SHA1 Message Date
Thorsten Ball
d5842f372d WIP: Leave debug info for deserializing empty windows 2025-01-21 15:46:19 +01:00
4 changed files with 30 additions and 11 deletions

View File

@@ -1124,15 +1124,15 @@ impl SerializableItem for Editor {
let mut serialize_dirty_buffers = self.serialize_dirty_buffers;
let project = self.project.clone()?;
if project.read(cx).visible_worktrees(cx).next().is_none() {
// If we don't have a worktree, we don't serialize, because
// projects without worktrees aren't deserialized.
serialize_dirty_buffers = false;
}
// if project.read(cx).visible_worktrees(cx).next().is_none() {
// // If we don't have a worktree, we don't serialize, because
// // projects without worktrees aren't deserialized.
// serialize_dirty_buffers = false;
// }
if closing && !serialize_dirty_buffers {
return None;
}
// if closing && !serialize_dirty_buffers {
// return None;
// }
let workspace_id = workspace.database_id()?;

View File

@@ -543,6 +543,7 @@ impl WorkspaceDb {
match workspace.location {
SerializedWorkspaceLocation::Local(local_paths, local_paths_order) => {
println!("save workspace. local_paths: {:?}", local_paths);
conn.exec_bound(sql!(
DELETE FROM toolchains WHERE workspace_id = ?1;
DELETE FROM workspaces WHERE local_paths = ? AND workspace_id != ?
@@ -787,7 +788,9 @@ impl WorkspaceDb {
let mut delete_tasks = Vec::new();
let ssh_projects = self.ssh_projects()?;
println!("recent workspaces on disk");
for (id, location, order, ssh_project_id) in self.recent_workspaces()? {
println!("id: {}, location: {:?}", id.0, location);
if let Some(ssh_project_id) = ssh_project_id.map(SshProjectId) {
if let Some(ssh_project) = ssh_projects.iter().find(|rp| rp.id == ssh_project_id) {
result.push((id, SerializedWorkspaceLocation::Ssh(ssh_project.clone())));
@@ -797,8 +800,13 @@ impl WorkspaceDb {
continue;
}
println!("we are here! local_paths; {:?}", location);
for path in location.paths().iter() {
println!("path: {}", path.display());
}
if location.paths().iter().all(|path| path.exists())
&& location.paths().iter().any(|path| path.is_dir())
// && location.paths().iter().any(|path| path.is_dir())
{
result.push((id, SerializedWorkspaceLocation::Local(location, order)));
} else {
@@ -829,15 +837,17 @@ impl WorkspaceDb {
last_session_window_stack: Option<Vec<WindowId>>,
) -> Result<Vec<SerializedWorkspaceLocation>> {
let mut workspaces = Vec::new();
println!("last_session_workspace_locations: {:?}", last_session_id);
for (location, order, window_id, ssh_project_id) in
self.session_workspaces(last_session_id.to_owned())?
{
println!("location: {:?}", location);
if let Some(ssh_project_id) = ssh_project_id {
let location = SerializedWorkspaceLocation::Ssh(self.ssh_project(ssh_project_id)?);
workspaces.push((location, window_id.map(WindowId::from)));
} else if location.paths().iter().all(|path| path.exists())
&& location.paths().iter().any(|path| path.is_dir())
// && location.paths().iter().any(|path| path.is_dir())
{
let location = SerializedWorkspaceLocation::Local(location, order);
workspaces.push((location, window_id.map(WindowId::from)));
@@ -852,6 +862,7 @@ impl WorkspaceDb {
});
}
println!("workspaces.len(): {}", workspaces.len());
Ok(workspaces
.into_iter()
.map(|(paths, _)| paths)

View File

@@ -4307,9 +4307,11 @@ impl Workspace {
}
}
println!("lol we are here");
let location = if let Some(ssh_project) = &self.serialized_ssh_project {
Some(SerializedWorkspaceLocation::Ssh(ssh_project.clone()))
} else if let Some(local_paths) = self.local_paths(cx) {
println!("we have local paths; {:?}", local_paths);
if !local_paths.is_empty() {
Some(SerializedWorkspaceLocation::from_local_paths(local_paths))
} else {
@@ -4319,6 +4321,8 @@ impl Workspace {
None
};
println!("location: {:?}", location);
if let Some(location) = location {
let center_group = build_serialized_pane_group(&self.center.root, cx);
let docks = build_serialized_docks(self, cx);

View File

@@ -900,11 +900,15 @@ pub(crate) async fn restorable_workspace_locations(
if let Some(last_session_id) = last_session_id {
let ordered = last_session_window_stack.is_some();
println!("last session workspace location");
let mut locations = workspace::last_session_workspace_locations(
&last_session_id,
last_session_window_stack,
)
.filter(|locations| !locations.is_empty());
.filter(|locations| {
println!("locations: {:?}", locations);
!locations.is_empty()
});
// Since last_session_window_order returns the windows ordered front-to-back
// we need to open the window that was frontmost last.