Fix incorrect cell foreground when clearing screen

This fixes a bug that would clear the cells with the current template
cell with just the `flags` reset, to make sure the colors are correct.
However, the cell foreground was not reset, leading to cells counting as
occupied when resizing.

With this change both cell flags and foreground color are ignored when
clearing both the whole screen and inside the line, allowing us to
accurately keep track of cell occupation.

Fixes #2866.
This commit is contained in:
Christian Duerr 2019-11-04 00:14:23 +01:00 committed by GitHub
parent b47a88b142
commit 93e87eb0f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 22 deletions

View File

@ -398,11 +398,8 @@ impl<N: Notify> Processor<N> {
font_size: &mut self.font_size, font_size: &mut self.font_size,
config: &mut self.config, config: &mut self.config,
}; };
let mut processor = input::Processor::new( let mut processor =
context, input::Processor::new(context, &self.display.urls, &self.display.highlighted_url);
&self.display.urls,
&self.display.highlighted_url,
);
for event in event_queue.drain(..) { for event in event_queue.drain(..) {
Processor::handle_event(event, &mut processor); Processor::handle_event(event, &mut processor);

View File

@ -20,9 +20,9 @@
//! determine what to do when a non-modifier key is pressed. //! determine what to do when a non-modifier key is pressed.
use std::borrow::Cow; use std::borrow::Cow;
use std::cmp::min; use std::cmp::min;
use std::cmp::Ordering;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::time::Instant; use std::time::Instant;
use std::cmp::Ordering;
use glutin::event::{ use glutin::event::{
ElementState, KeyboardInput, ModifiersState, MouseButton, MouseScrollDelta, TouchPhase, ElementState, KeyboardInput, ModifiersState, MouseButton, MouseScrollDelta, TouchPhase,
@ -250,11 +250,7 @@ impl From<MouseState> for CursorIcon {
} }
impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
pub fn new( pub fn new(ctx: A, urls: &'a Urls, highlighted_url: &'a Option<Url>) -> Self {
ctx: A,
urls: &'a Urls,
highlighted_url: &'a Option<Url>,
) -> Self {
Self { ctx, urls, highlighted_url, _phantom: Default::default() } Self { ctx, urls, highlighted_url, _phantom: Default::default() }
} }
@ -646,10 +642,12 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
let new_icon = match current_lines.cmp(&new_lines) { let new_icon = match current_lines.cmp(&new_lines) {
Ordering::Less => CursorIcon::Default, Ordering::Less => CursorIcon::Default,
Ordering::Equal => CursorIcon::Hand, Ordering::Equal => CursorIcon::Hand,
Ordering::Greater => if mouse_mode { Ordering::Greater => {
CursorIcon::Default if mouse_mode {
} else { CursorIcon::Default
CursorIcon::Text } else {
CursorIcon::Text
}
}, },
}; };

View File

@ -1661,8 +1661,7 @@ impl<T: EventListener> ansi::Handler for Term<T> {
#[inline] #[inline]
fn clear_line(&mut self, mode: ansi::LineClearMode) { fn clear_line(&mut self, mode: ansi::LineClearMode) {
trace!("Clearing line: {:?}", mode); trace!("Clearing line: {:?}", mode);
let mut template = self.cursor.template; let template = Cell { bg: self.cursor.template.bg, ..Cell::default() };
template.flags ^= template.flags;
let col = self.cursor.point.col; let col = self.cursor.point.col;
@ -1725,8 +1724,7 @@ impl<T: EventListener> ansi::Handler for Term<T> {
#[inline] #[inline]
fn clear_screen(&mut self, mode: ansi::ClearMode) { fn clear_screen(&mut self, mode: ansi::ClearMode) {
trace!("Clearing screen: {:?}", mode); trace!("Clearing screen: {:?}", mode);
let mut template = self.cursor.template; let template = Cell { bg: self.cursor.template.bg, ..Cell::default() };
template.flags ^= template.flags;
// Remove active selections // Remove active selections
self.grid.selection = None; self.grid.selection = None;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long