mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
Fix invisible selection
This resolves a bug where the very first/last cell would still be selected when both the start and the end were below/above the viewport.
This commit is contained in:
parent
3d7a789fd3
commit
ba05e505d5
2 changed files with 8 additions and 7 deletions
|
@ -650,11 +650,6 @@ impl<T> Grid<T> {
|
||||||
GridIterator { grid: self, cur: point }
|
GridIterator { grid: self, cur: point }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn contains(&self, point: &Point) -> bool {
|
|
||||||
self.lines > point.line && self.cols > point.col
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn display_offset(&self) -> usize {
|
pub fn display_offset(&self) -> usize {
|
||||||
self.display_offset
|
self.display_offset
|
||||||
|
|
|
@ -226,7 +226,6 @@ impl<'a, C> RenderableCellsIter<'a, C> {
|
||||||
selection: Option<SelectionRange>,
|
selection: Option<SelectionRange>,
|
||||||
) -> RenderableCellsIter<'b, C> {
|
) -> RenderableCellsIter<'b, C> {
|
||||||
let grid = &term.grid;
|
let grid = &term.grid;
|
||||||
let num_cols = grid.num_cols();
|
|
||||||
|
|
||||||
let inner = grid.display_iter();
|
let inner = grid.display_iter();
|
||||||
|
|
||||||
|
@ -234,9 +233,16 @@ impl<'a, C> RenderableCellsIter<'a, C> {
|
||||||
let (limit_start, limit_end) = if span.is_block {
|
let (limit_start, limit_end) = if span.is_block {
|
||||||
(span.start.col, span.end.col)
|
(span.start.col, span.end.col)
|
||||||
} else {
|
} else {
|
||||||
(Column(0), num_cols - 1)
|
(Column(0), grid.num_cols() - 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Do not render completely offscreen selection
|
||||||
|
let viewport_start = grid.display_offset();
|
||||||
|
let viewport_end = viewport_start + grid.num_lines().0;
|
||||||
|
if span.end.line >= viewport_end || span.start.line < viewport_start {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
// Get on-screen lines of the selection's locations
|
// Get on-screen lines of the selection's locations
|
||||||
let mut start = grid.clamp_buffer_to_visible(span.start);
|
let mut start = grid.clamp_buffer_to_visible(span.start);
|
||||||
let mut end = grid.clamp_buffer_to_visible(span.end);
|
let mut end = grid.clamp_buffer_to_visible(span.end);
|
||||||
|
|
Loading…
Reference in a new issue