lsp_types_max/types/position.rs
1use serde::{Deserialize, Serialize};
2
3/// Position in a text document expressed as zero-based line and character offset.
4/// A position is between two characters like an 'insert' cursor in a editor.
5#[derive(
6 Debug, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Default, Deserialize, Serialize, Hash,
7)]
8pub struct Position {
9 /// Line position in a document (zero-based).
10 pub line: u32,
11 /// Character offset on a line in a document (zero-based). The meaning of this
12 /// offset is determined by the negotiated `PositionEncodingKind`.
13 ///
14 /// If the character value is greater than the line length it defaults back
15 /// to the line length.
16 pub character: u32,
17}
18
19impl Position {
20 pub fn new(line: u32, character: u32) -> Position {
21 Position { line, character }
22 }
23}