summaryrefslogtreecommitdiff
path: root/helix-view/src/view.rs
diff options
context:
space:
mode:
authorJan Hrastnik2020-10-06 23:41:09 +0000
committerJan Hrastnik2020-10-06 23:41:09 +0000
commit750610f0e7e2d27604983ffdcd8d6a447bc898b2 (patch)
tree574e857cdb97ac4bb5cd4545b81253a6e5b09ab0 /helix-view/src/view.rs
parent88f93399fd4a451f529693269e4154421c8a6d06 (diff)
various fixes
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r--helix-view/src/view.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 09cd4c65..0e6705f0 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -34,7 +34,7 @@ impl View {
pub fn ensure_cursor_in_view(&mut self) {
let cursor = self.state.selection().cursor();
let line = self.state.doc().char_to_line(cursor) as u16;
- let document_end = self.first_line + self.size.1.saturating_sub(1) - 1;
+ let document_end = self.first_line + self.size.1.saturating_sub(2);
let padding = 5u16;
@@ -51,7 +51,8 @@ impl View {
/// Calculates the last visible line on screen
#[inline]
- pub fn last_line(&self, viewport: Rect) -> usize {
+ pub fn last_line(&self) -> usize {
+ let viewport = Rect::new(6, 0, self.size.0, self.size.1 - 1); // - 1 for statusline
std::cmp::min(
(self.first_line + viewport.height) as usize,
self.state.doc().len_lines() - 1,
@@ -61,15 +62,10 @@ impl View {
/// Translates a document position to an absolute position in the terminal.
/// Returns a (line, col) position if the position is visible on screen.
// TODO: Could return width as well for the character width at cursor.
- pub fn screen_coords_at_pos(
- &self,
- text: &RopeSlice,
- pos: usize,
- viewport: Rect,
- ) -> Option<Position> {
+ pub fn screen_coords_at_pos(&self, text: &RopeSlice, pos: usize) -> Option<Position> {
let line = text.char_to_line(pos);
- if line < self.first_line as usize || line > self.last_line(viewport) {
+ if line < self.first_line as usize || line > self.last_line() {
// Line is not visible on screen
return None;
}