pub fn compute_new_window(&mut self, new_offset: usize) {
        let window_end = self.window_end.load(Ordering::SeqCst);
        // If the distance of the current offset to the end of the window is less than a
        // third of the SYNC_BUFF_LEN then increase the window.
        // OR
        // If the new offset is sufficiently far away from the end of the window, shrink the
        // window. We want to do this because if we never shrink the window, then editing at
        // the end of the file creates a large buffer that will have to sync on deletions,
        // thus blocking the user and defeating the point of all this.
        //
        // This is set behind this if to prevent rerunning every single frame and cause a
        // potential performance hit.
        if window_end.saturating_sub(new_offset) < SYNC_BUFF_LEN / 3
            || window_end.saturating_sub(new_offset) > SYNC_BUFF_LEN * 4 / 3
        {
            self.block();
            self.tx
                .send(EditMessage::ModifyWindow((new_offset + SYNC_BUFF_LEN).min(self.len)))
                .unwrap();
        }
    }
Compute whether the window needs to be extended, blocks if so until there is no
more work to prevent data from being inserter / removed in the wrong places.
src/buffer.rs