remote project: Fix project reference leak when waiting for prompt reply (#19838)

When the language server gave us a prompt and we'd close the window, we
wouldn't release the `project` until the next `flush_effects` call that
came in when opening a window.

With this change, we no longer hold a strong reference to the project in
the future. Fixes the leak and makes sure we clean up the SSH connection
when closing a window.

Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-10-28 17:07:30 +01:00 committed by GitHub
parent a451bcc3c4
commit fab2f22a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3603,6 +3603,13 @@ impl Project {
anyhow::Ok(())
})??;
// We drop `this` to avoid holding a reference in this future for too
// long.
// If we keep the reference, we might not drop the `Project` early
// enough when closing a window and it will only get releases on the
// next `flush_effects()` call.
drop(this);
let answer = rx.next().await;
Ok(LanguageServerPromptResponse {