From e73cdb67bcb38aabbdf8aa06578df5e90e9724ea Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 19 May 2020 18:16:05 +0200 Subject: [PATCH] stop status from adding commands when not active --- src/tabs/status.rs | 98 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 03b9c86b17..f7e78d3cf0 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -246,59 +246,61 @@ impl Component for Status { out: &mut Vec, force_all: bool, ) -> CommandBlocking { - for c in self.components() { - if c.commands(out, force_all) - != CommandBlocking::PassingOn - && !force_all + if self.visible { + for c in self.components() { + if c.commands(out, force_all) + != CommandBlocking::PassingOn + && !force_all + { + break; + } + } + { - break; + let focus_on_diff = self.focus == Focus::Diff; + out.push(CommandInfo::new( + commands::STATUS_FOCUS_LEFT, + true, + (self.visible && focus_on_diff) || force_all, + )); + out.push(CommandInfo::new( + commands::STATUS_FOCUS_RIGHT, + self.can_focus_diff(), + (self.visible && !focus_on_diff) || force_all, + )); } - } - { - let focus_on_diff = self.focus == Focus::Diff; - out.push(CommandInfo::new( - commands::STATUS_FOCUS_LEFT, - true, - (self.visible && focus_on_diff) || force_all, - )); - out.push(CommandInfo::new( - commands::STATUS_FOCUS_RIGHT, - self.can_focus_diff(), - (self.visible && !focus_on_diff) || force_all, - )); + out.push( + CommandInfo::new( + commands::SELECT_STATUS, + true, + (self.visible && self.focus == Focus::Diff) + || force_all, + ) + .hidden(), + ); + + out.push( + CommandInfo::new( + commands::SELECT_STAGING, + true, + (self.visible && self.focus == Focus::WorkDir) + || force_all, + ) + .order(-2), + ); + + out.push( + CommandInfo::new( + commands::SELECT_UNSTAGED, + true, + (self.visible && self.focus == Focus::Stage) + || force_all, + ) + .order(-2), + ); } - out.push( - CommandInfo::new( - commands::SELECT_STATUS, - true, - (self.visible && self.focus == Focus::Diff) - || force_all, - ) - .hidden(), - ); - - out.push( - CommandInfo::new( - commands::SELECT_STAGING, - true, - (self.visible && self.focus == Focus::WorkDir) - || force_all, - ) - .order(-2), - ); - - out.push( - CommandInfo::new( - commands::SELECT_UNSTAGED, - true, - (self.visible && self.focus == Focus::Stage) - || force_all, - ) - .order(-2), - ); - if self.visible { CommandBlocking::Blocking } else {