diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2022-02-07 22:18:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-07 22:18:51 +0300 |
commit | c2959f45ec5e9dc3891a6bcbbb793b0452d344cd (patch) | |
tree | ec2e456956d200180715451aa9db2cbc4a130628 /alacritty_terminal/src/term | |
parent | 998250f3c3168855ede9ee14be9a52f884f12055 (diff) | |
download | alacritty-c2959f45ec5e9dc3891a6bcbbb793b0452d344cd.tar.gz alacritty-c2959f45ec5e9dc3891a6bcbbb793b0452d344cd.zip |
Fix alacritty_terminal not emitting damage on color change
Diffstat (limited to 'alacritty_terminal/src/term')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 7b0667e2..50f423e5 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1621,6 +1621,12 @@ impl<T: EventListener> Handler for Term<T> { #[inline] fn set_color(&mut self, index: usize, color: Rgb) { trace!("Setting color[{}] = {:?}", index, color); + + // Damage terminal if the color changed and it's not the cursor. + if index != NamedColor::Cursor as usize && self.colors[index] != Some(color) { + self.mark_fully_damaged(); + } + self.colors[index] = Some(color); } @@ -1645,6 +1651,12 @@ impl<T: EventListener> Handler for Term<T> { #[inline] fn reset_color(&mut self, index: usize) { trace!("Resetting color[{}]", index); + + // Damage terminal if the color changed and it's not the cursor. + if index != NamedColor::Cursor as usize && self.colors[index].is_some() { + self.mark_fully_damaged(); + } + self.colors[index] = None; } @@ -2992,6 +3004,23 @@ mod tests { assert!(!term.damage.is_fully_damaged); term.reset_damage(); + let color_index = 257; + term.set_color(color_index, Rgb::default()); + assert!(term.damage.is_fully_damaged); + term.reset_damage(); + + // Setting the same color once again shouldn't trigger full damage. + term.set_color(color_index, Rgb::default()); + assert!(!term.damage.is_fully_damaged); + + term.reset_color(color_index); + assert!(term.damage.is_fully_damaged); + term.reset_damage(); + + // We shouldn't trigger fully damage when cursor gets update. + term.set_color(NamedColor::Cursor as usize, Rgb::default()); + assert!(!term.damage.is_fully_damaged); + // However requesting terminal damage should mark terminal as fully damaged in `Insert` // mode. let _ = term.damage(None); |