mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
fix: discard empty textchanges, drain range
This commit is contained in:
parent
3881bb38ea
commit
3197c083bf
1 changed files with 36 additions and 33 deletions
|
@ -112,8 +112,10 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
|
||||||
res = self.operations.recv() => match res {
|
res = self.operations.recv() => match res {
|
||||||
None => break,
|
None => break,
|
||||||
Some(change) => {
|
Some(change) => {
|
||||||
match self.buffer.view().get(change.span.clone()) {
|
if !change.is_empty() {
|
||||||
None => tracing::error!("received illegal span from client"),
|
let view = self.buffer.view();
|
||||||
|
match view.get(change.span.clone()) {
|
||||||
|
None => tracing::error!("received illegal span from client: {:?} but buffer is of len {}", change.span, view.len()),
|
||||||
Some(span) => {
|
Some(span) => {
|
||||||
let diff = TextDiff::from_chars(span, &change.content);
|
let diff = TextDiff::from_chars(span, &change.content);
|
||||||
|
|
||||||
|
@ -151,6 +153,7 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// received a message from server
|
// received a message from server
|
||||||
|
@ -161,7 +164,7 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
|
||||||
Ok(op) => {
|
Ok(op) => {
|
||||||
self.buffer.merge(op);
|
self.buffer.merge(op);
|
||||||
self.content.send(self.buffer.view()).unwrap_or_warn("could not send buffer update");
|
self.content.send(self.buffer.view()).unwrap_or_warn("could not send buffer update");
|
||||||
for tx in self.pollers.drain(0..self.pollers.len()) {
|
for tx in self.pollers.drain(..) {
|
||||||
tx.send(()).unwrap_or_warn("could not wake up poller");
|
tx.send(()).unwrap_or_warn("could not wake up poller");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue