mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-28 15:54:54 +01:00
fix: leave_workspace returns like detach
This commit is contained in:
parent
b585708f8d
commit
6afbb23590
2 changed files with 11 additions and 1 deletions
|
@ -182,7 +182,10 @@ impl Client {
|
|||
|
||||
/// Leave the [`Workspace`] with the given name.
|
||||
pub fn leave_workspace(&self, id: &str) -> bool {
|
||||
self.0.workspaces.remove(id).is_some()
|
||||
match self.0.workspaces.remove(id) {
|
||||
None => true,
|
||||
Some(x) => x.1.consume(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a [`Workspace`] handle by name.
|
||||
|
|
|
@ -100,6 +100,11 @@ impl Workspace {
|
|||
Ok(ws)
|
||||
}
|
||||
|
||||
/// drop arc, return true if was last
|
||||
pub(crate) fn consume(self) -> bool {
|
||||
Arc::into_inner(self.0).is_some()
|
||||
}
|
||||
|
||||
/// Create a new buffer in the current workspace.
|
||||
pub async fn create(&self, path: &str) -> RemoteResult<()> {
|
||||
let mut workspace_client = self.0.services.ws();
|
||||
|
@ -312,6 +317,7 @@ impl Workspace {
|
|||
let weak = Arc::downgrade(&self.0);
|
||||
let name = self.id();
|
||||
tokio::spawn(async move {
|
||||
tracing::debug!("workspace worker starting");
|
||||
loop {
|
||||
// TODO can we stop responsively rather than poll for Arc being dropped?
|
||||
if weak.upgrade().is_none() {
|
||||
|
@ -359,6 +365,7 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
}
|
||||
tracing::debug!("workspace worker stopping");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue