summaryrefslogtreecommitdiff
path: root/helix-view/src/view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r--helix-view/src/view.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index e02436b3..f3d92bfd 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -35,6 +35,17 @@ impl View {
Ok(view)
}
+ pub fn check_cursor_in_view(&self) -> bool {
+ let cursor = self.doc.selection().cursor();
+ let line = self.doc.text().char_to_line(cursor);
+ let document_end = self.first_line + self.area.height.saturating_sub(1) as usize;
+
+ if (line > document_end.saturating_sub(PADDING)) || (line < self.first_line + PADDING) {
+ return false;
+ }
+ true
+ }
+
pub fn ensure_cursor_in_view(&mut self) {
let cursor = self.doc.state.selection().cursor();
let line = self.doc.text().char_to_line(cursor);