summaryrefslogtreecommitdiff
path: root/support/texlab/src/range.rs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
committerNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
commitb8d4bb76703bcb15578e2b23c5d256532180b894 (patch)
treebedd1df7a00521a2bd986b3c0289d6556a59e39b /support/texlab/src/range.rs
parent02e4625a78a5029e8b5dc2a4ec70193b232f497e (diff)
CTAN sync 201912030301
Diffstat (limited to 'support/texlab/src/range.rs')
-rw-r--r--support/texlab/src/range.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/support/texlab/src/range.rs b/support/texlab/src/range.rs
new file mode 100644
index 0000000000..515ec187a6
--- /dev/null
+++ b/support/texlab/src/range.rs
@@ -0,0 +1,32 @@
+use lsp_types::*;
+
+pub trait RangeExt {
+ fn new_simple(start_line: u64, start_character: u64, end_line: u64, end_character: u64)
+ -> Self;
+
+ fn contains(&self, position: Position) -> bool;
+
+ fn contains_exclusive(&self, position: Position) -> bool;
+}
+
+impl RangeExt for Range {
+ fn new_simple(
+ start_line: u64,
+ start_character: u64,
+ end_line: u64,
+ end_character: u64,
+ ) -> Self {
+ Range {
+ start: Position::new(start_line, start_character),
+ end: Position::new(end_line, end_character),
+ }
+ }
+
+ fn contains(&self, position: Position) -> bool {
+ position >= self.start && position <= self.end
+ }
+
+ fn contains_exclusive(&self, position: Position) -> bool {
+ position > self.start && position < self.end
+ }
+}