Skip to content

Commit f9f6144

Browse files
committed
feat: new cursor struct layout
1 parent 6886436 commit f9f6144

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/api/cursor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use pyo3::prelude::*;
1313
pub struct Cursor {
1414
/// User who sent the cursor.
1515
pub user: String,
16+
/// Path of buffer this cursor is on
17+
pub buffer: String,
1618
/// The updated cursor selection.
1719
pub sel: Vec<Selection>,
1820
}
@@ -32,6 +34,4 @@ pub struct Selection {
3234
pub end_row: i32,
3335
/// Cursor position final column in buffer.
3436
pub end_col: i32,
35-
/// Path of buffer this cursor is on.
36-
pub buffer: String,
3737
}

src/cursor/controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
errors::ControllerResult,
1414
};
1515
use codemp_proto::{
16-
cursor::{CursorPosition, RowCol},
16+
cursor::{CursorPosition, CursorUpdate, RowCol},
1717
files::BufferNode,
1818
};
1919

@@ -33,7 +33,7 @@ impl CursorController {
3333

3434
#[derive(Debug)]
3535
pub(crate) struct CursorControllerInner {
36-
pub(crate) op: mpsc::UnboundedSender<CursorPosition>,
36+
pub(crate) op: mpsc::UnboundedSender<CursorUpdate>,
3737
pub(crate) stream: mpsc::Sender<oneshot::Sender<Option<Cursor>>>,
3838
pub(crate) poll: mpsc::UnboundedSender<oneshot::Sender<()>>,
3939
pub(crate) callback: watch::Sender<Option<ControllerCallback<CursorController>>>,

src/cursor/worker.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use crate::{
88
api::{Cursor, Selection, User, controller::ControllerCallback},
99
ext::IgnorableError,
1010
};
11-
use codemp_proto::cursor::{CursorEvent, CursorPosition};
11+
use codemp_proto::cursor::{CursorEvent, CursorUpdate};
1212

1313
use super::controller::{CursorController, CursorControllerInner};
1414

1515
struct CursorWorker {
1616
workspace_id: String,
17-
op: mpsc::UnboundedReceiver<CursorPosition>,
17+
op: mpsc::UnboundedReceiver<CursorUpdate>,
1818
map: Arc<dashmap::DashMap<Uuid, User>>,
1919
stream: mpsc::Receiver<oneshot::Sender<Option<Cursor>>>,
2020
poll: mpsc::UnboundedReceiver<oneshot::Sender<()>>,
@@ -32,11 +32,12 @@ impl CursorWorker {
3232
if let Some(user_name) = self.map.get(&user_id).map(|u| u.name.clone()) {
3333
Some(Cursor {
3434
user: user_name,
35+
buffer: event.position.buffer,
3536
sel: event
3637
.position
38+
.cursors
3739
.into_iter()
3840
.map(|x| Selection {
39-
buffer: x.buffer.path,
4041
start_row: x.start.row,
4142
start_col: x.start.col,
4243
end_row: x.end.row,
@@ -56,7 +57,7 @@ impl CursorWorker {
5657
impl CursorController {
5758
pub(crate) fn spawn(
5859
user_map: Arc<dashmap::DashMap<Uuid, User>>,
59-
tx: mpsc::Sender<CursorPosition>,
60+
tx: mpsc::Sender<CursorUpdate>,
6061
rx: Streaming<CursorEvent>,
6162
workspace_id: Uuid,
6263
) -> Self {
@@ -95,7 +96,7 @@ impl CursorController {
9596
#[tracing::instrument(skip(worker, tx, rx), fields(ws = worker.workspace_id))]
9697
async fn work(
9798
mut worker: CursorWorker,
98-
tx: mpsc::Sender<CursorPosition>,
99+
tx: mpsc::Sender<CursorUpdate>,
99100
mut rx: Streaming<CursorEvent>,
100101
) {
101102
tracing::debug!("starting cursor worker");

0 commit comments

Comments
 (0)