diff options
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/editor.rs | 5 | ||||
-rw-r--r-- | helix-view/src/tree.rs | 10 | ||||
-rw-r--r-- | helix-view/src/view.rs | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index e9f8b5a1..e7b25814 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -194,8 +194,9 @@ impl Editor { } pub fn resize(&mut self, area: Rect) { - self.tree.resize(area); - self._refresh(); + if self.tree.resize(area) { + self._refresh(); + }; } pub fn focus_next(&mut self) { diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index b7c99e16..5b56156f 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -293,9 +293,13 @@ impl Tree { } } - pub fn resize(&mut self, area: Rect) { - self.area = area; - self.recalculate(); + pub fn resize(&mut self, area: Rect) -> bool { + if self.area != area { + self.area = area; + self.recalculate(); + return true; + } + false } pub fn recalculate(&mut self) { diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs index f82de90e..b7bfaa17 100644 --- a/helix-view/src/view.rs +++ b/helix-view/src/view.rs @@ -143,8 +143,9 @@ impl View { } } - let row = line - self.first_line as usize; - let col = col - self.first_col as usize; + // It is possible for underflow to occur if the buffer length is larger than the terminal width. + let row = line.saturating_sub(self.first_line); + let col = col.saturating_sub(self.first_col); Some(Position::new(row, col)) } |