1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use serde::{Deserialize, Serialize};
use crate::{Cursor, FileId};
/// TODO: docs
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CursorMoved {
cursor: Cursor,
file: FileId,
}
impl CursorMoved {
/// Returns the new [`Cursor`].
#[inline(always)]
pub fn cursor(&self) -> Cursor {
self.cursor
}
/// Returns the [`FileId`] of the file the cursor was moved in.
///
/// This can be used to determine if the cursor was moved within the same
/// file or if it was moved to another file in the project.
///
/// The returned `FileId` is always of a file whose
/// [`FileKind`](crate::FileKind) is
/// [`Document`](crate::FileKind::Document), never
/// [`Directory`](crate::FileKind::Directory).
#[inline(always)]
pub fn file(&self) -> FileId {
self.file
}
/// Creates a new `CursorMoved` message.
#[cfg(feature = "__client")]
#[inline(always)]
pub fn new(cursor: Cursor, file: FileId) -> Self {
Self { cursor, file }
}
}