diff options
-rw-r--r-- | alacritty/src/display/hint.rs | 2 | ||||
-rw-r--r-- | alacritty/src/display/mod.rs | 20 | ||||
-rw-r--r-- | alacritty/src/event.rs | 3 |
3 files changed, 16 insertions, 9 deletions
diff --git a/alacritty/src/display/hint.rs b/alacritty/src/display/hint.rs index 5e770bcf..6d61b094 100644 --- a/alacritty/src/display/hint.rs +++ b/alacritty/src/display/hint.rs @@ -165,7 +165,7 @@ impl HintState { } /// Hint match which was selected by the user. -#[derive(Debug, Clone)] +#[derive(PartialEq, Debug, Clone)] pub struct HintMatch { /// Action for handling the text. pub action: HintAction, diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index 810d20f3..0947ab7e 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -657,26 +657,31 @@ impl Display { } /// Update the mouse/vi mode cursor hint highlighting. + /// + /// This will return whether the highlighted hints changed. pub fn update_highlighted_hints<T>( &mut self, term: &Term<T>, config: &Config, mouse: &Mouse, modifiers: ModifiersState, - ) { + ) -> bool { // Update vi mode cursor hint. - if term.mode().contains(TermMode::VI) { + let vi_highlighted_hint = if term.mode().contains(TermMode::VI) { let mods = ModifiersState::all(); let point = term.vi_mode_cursor.point; - self.vi_highlighted_hint = hint::highlighted_at(&term, config, point, mods); + hint::highlighted_at(&term, config, point, mods) } else { - self.vi_highlighted_hint = None; - } + None + }; + let mut dirty = vi_highlighted_hint != self.vi_highlighted_hint; + self.vi_highlighted_hint = vi_highlighted_hint; // Abort if mouse highlighting conditions are not met. if !mouse.inside_text_area || !term.selection.as_ref().map_or(true, Selection::is_empty) { + dirty |= self.highlighted_hint.is_some(); self.highlighted_hint = None; - return; + return dirty; } // Find highlighted hint at mouse position. @@ -694,7 +699,10 @@ impl Display { } } + dirty |= self.highlighted_hint != highlighted_hint; self.highlighted_hint = highlighted_hint; + + dirty } /// Format search regex to account for the cursor and fullwidth characters. diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index a895514f..64283eb7 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -1114,14 +1114,13 @@ impl<N: Notify + OnResize> Processor<N> { } if self.dirty || self.mouse.hint_highlight_dirty { - self.display.update_highlighted_hints( + self.dirty |= self.display.update_highlighted_hints( &terminal, &self.config, &self.mouse, self.modifiers, ); self.mouse.hint_highlight_dirty = false; - self.dirty = true; } if self.dirty { |