From 56959e6596d102a1edf5a1e79f5abe921fbc4718 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 11:11:17 +0200 Subject: [PATCH] do not highlight selection in diff when not focused (closes #270) --- CHANGELOG.md | 3 +++ src/components/diff.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf5903a7..97a832e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - push to origin support ([#265](https://github.com/extrawurst/gitui/issues/265)) +### Changed +- do not highlight selection in diff view when not focused ([#270](https://github.com/extrawurst/gitui/issues/270)) + ## [0.10.1] - 2020-09-01 ### Fixed diff --git a/src/components/diff.rs b/src/components/diff.rs index ead6ed8b..bf83d620 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -349,8 +349,10 @@ impl DiffComponent { let mut lines_added = 0_usize; for (i, hunk) in diff.hunks.iter().enumerate() { - let hunk_selected = - self.selected_hunk.map_or(false, |s| s == i); + let hunk_selected = self.focused() + && self + .selected_hunk + .map_or(false, |s| s == i); if lines_added >= height as usize { break; @@ -372,8 +374,10 @@ impl DiffComponent { &mut res, width, line, - self.selection - .contains(line_cursor), + self.focused() + && self + .selection + .contains(line_cursor), hunk_selected, i == hunk_len as usize - 1, &self.theme,