diff options
author | Mathis Brossier | 2022-01-16 01:55:28 +0000 |
---|---|---|
committer | GitHub | 2022-01-16 01:55:28 +0000 |
commit | f5b0821860940782567a0baa17280aef04f845e3 (patch) | |
tree | 40b72ef97945fb535fd7e3f29898c1b59a1e4a07 /helix-view | |
parent | 9da0abaa5d0744d6480c6e6f23a3c5ddb5ae0bce (diff) |
Fix panics when resizing (#1408)
* Change buffer.get & buffer.get_mut to return Option, Implement Trait Index & IndexMut to panic
* Prevent FilePicker from drawing outside buffer (rust panics)
* apply suggestion
* add function in_bounds to avoid useless calculations
Co-authored-by: mathis <mathis.brossier@universite-paris-saclay.fr>
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/graphics.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index b8e43ba5..5fd54c8c 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -323,7 +323,7 @@ impl FromStr for Modifier { /// ];
/// let mut buffer = Buffer::empty(Rect::new(0, 0, 1, 1));
/// for style in &styles {
-/// buffer.get_mut(0, 0).set_style(*style);
+/// buffer[(0, 0)].set_style(*style);
/// }
/// assert_eq!(
/// Style {
@@ -332,7 +332,7 @@ impl FromStr for Modifier { /// add_modifier: Modifier::BOLD,
/// sub_modifier: Modifier::empty(),
/// },
-/// buffer.get(0, 0).style(),
+/// buffer[(0, 0)].style(),
/// );
/// ```
///
@@ -348,7 +348,7 @@ impl FromStr for Modifier { /// ];
/// let mut buffer = Buffer::empty(Rect::new(0, 0, 1, 1));
/// for style in &styles {
-/// buffer.get_mut(0, 0).set_style(*style);
+/// buffer[(0, 0)].set_style(*style);
/// }
/// assert_eq!(
/// Style {
@@ -357,7 +357,7 @@ impl FromStr for Modifier { /// add_modifier: Modifier::empty(),
/// sub_modifier: Modifier::empty(),
/// },
-/// buffer.get(0, 0).style(),
+/// buffer[(0, 0)].style(),
/// );
/// ```
#[derive(Debug, Clone, Copy, PartialEq)]
|