aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/view.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-16 06:30:29 +0000
committerBlaž Hrastnik2021-03-16 06:41:42 +0000
commit143cfe13e05b17840a9f2c69417ed98bc3b8cb0e (patch)
tree45cdea8a84a51a1cbf53daf55e5d9415d840762b /helix-view/src/view.rs
parent4f77d80e74b1406b8701f5569b3bec8da2e5ed03 (diff)
minor: TODO comment cleanup
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r--helix-view/src/view.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 5b269a9a..b406b756 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -13,15 +13,12 @@ use tui::layout::Rect;
pub const PADDING: usize = 5;
-// TODO: view should be View { doc: Document(state, history,..) }
-// since we can have multiple views into the same file
pub struct View {
pub id: Key,
pub doc: Document,
pub first_line: usize,
pub area: Rect,
}
-// TODO: popups should be a thing on the view with a rect + text
impl View {
pub fn new(doc: Document) -> Result<Self, Error> {
@@ -54,9 +51,9 @@ impl View {
/// Calculates the last visible line on screen
#[inline]
pub fn last_line(&self) -> usize {
- let viewport = Rect::new(6, 0, self.area.width, self.area.height.saturating_sub(1)); // - 1 for statusline
+ let height = self.area.height.saturating_sub(1); // - 1 for statusline
std::cmp::min(
- self.first_line + (viewport.height as usize),
+ self.first_line + height as usize,
self.doc.text().len_lines() - 1,
)
}
@@ -67,7 +64,7 @@ impl View {
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() {
+ if line < self.first_line || line > self.last_line() {
// Line is not visible on screen
return None;
}