mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-14 17:53:03 -04:00
Fix crash
There might be a better way to track cursor state such that these checks aren't necessary.
This commit is contained in:
parent
c5bc39fe26
commit
7da9de34d8
2 changed files with 6 additions and 2 deletions
|
@ -134,6 +134,10 @@ impl<T> Grid<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn contains(&self, cursor: &Cursor) -> bool {
|
||||
self.lines > cursor.line && self.cols > cursor.col
|
||||
}
|
||||
|
||||
/// Swap two lines in the grid
|
||||
///
|
||||
/// This could have used slice::swap internally, but we are able to have
|
||||
|
|
|
@ -36,7 +36,7 @@ pub struct RenderGrid<'a> {
|
|||
|
||||
impl<'a> RenderGrid<'a> {
|
||||
fn new<'b>(grid: &'b mut Grid<Cell>, cursor: &'b Cursor, mode: TermMode) -> RenderGrid<'b> {
|
||||
if mode.contains(mode::SHOW_CURSOR) {
|
||||
if mode.contains(mode::SHOW_CURSOR) && grid.contains(cursor) {
|
||||
let cell = &mut grid[cursor];
|
||||
mem::swap(&mut cell.fg, &mut cell.bg);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl<'a> RenderGrid<'a> {
|
|||
|
||||
impl<'a> Drop for RenderGrid<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.mode.contains(mode::SHOW_CURSOR) {
|
||||
if self.mode.contains(mode::SHOW_CURSOR) && self.inner.contains(self.cursor) {
|
||||
let cell = &mut self.inner[self.cursor];
|
||||
mem::swap(&mut cell.fg, &mut cell.bg);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue