diff options
author | Skyler Hawthorne | 2022-08-23 21:21:26 +0000 |
---|---|---|
committer | Skyler Hawthorne | 2022-10-19 02:31:39 +0000 |
commit | 7b11e9ac6941188c6f6148961fdd97e34988490e (patch) | |
tree | d72274e149963b26e88baea3f8f74d121b1df5af | |
parent | d544376590e9e9d649cc7406282b5ebd54dc6f0a (diff) |
fix erroneous write sender close
This was not distinguishing the error types when trying a receive on an empty
receiver, which was erroneously causing the sender to be closed when trying to
flush the writes when there were none
-rw-r--r-- | helix-view/src/document.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index fe081442..86a1d6d2 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -13,6 +13,7 @@ use std::future::Future; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; +use tokio::sync::mpsc::error::TryRecvError; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use tokio::sync::Mutex; @@ -662,7 +663,16 @@ impl Document { let save_req = if block { rx.recv().await } else { - rx.try_recv().ok() + let msg = rx.try_recv(); + + if let Err(err) = msg { + match err { + TryRecvError::Empty => return None, + TryRecvError::Disconnected => None, + } + } else { + msg.ok() + } }; let save = match save_req { |