@@ -31,7 +31,7 @@ use std::{
31use tokio::{
31use tokio::{
33 mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
33 mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
34− Notify, RwLock,
34+ oneshot, Notify, RwLock,
36 time::{sleep, Duration, Instant, Sleep},
36 time::{sleep, Duration, Instant, Sleep},
@@ -852,6 +852,14 @@ pub struct Editor {
852 /// avoid calculating the cursor position multiple
852 /// avoid calculating the cursor position multiple
853 /// times during rendering and should not be set by other functions.
853 /// times during rendering and should not be set by other functions.
854 pub cursor_cache: Cell<Option<Option<Position>>>,
854 pub cursor_cache: Cell<Option<Option<Position>>>,
855+ /// When a new completion request is sent to the server old
856+ /// unifinished request must be dropped. Each completion
857+ /// request is associated with a channel that cancels
858+ /// when the channel is dropped. That channel is stored
859+ /// here. When a new completion request is sent this
860+ /// field is set and any old requests are automatically
861+ /// canceled as a result
862+ pub completion_request_handle: Option<oneshot::Sender<()>>,
857pub type RedrawHandle = (Arc<Notify>, Arc<RwLock<()>>);
865pub type RedrawHandle = (Arc<Notify>, Arc<RwLock<()>>);
@@ -950,6 +958,7 @@ impl Editor {
950 redraw_handle: Default::default(),
958 redraw_handle: Default::default(),
951 needs_redraw: false,
959 needs_redraw: false,
952 cursor_cache: Cell::new(None),
960 cursor_cache: Cell::new(None),
961+ completion_request_handle: None,