diff options
author | Canop <cano.petrole@gmail.com> | 2022-05-16 18:29:31 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2022-05-16 18:30:52 +0200 |
commit | 70f4d09aab75c7610e34bde855f4cd28ce691954 (patch) | |
tree | a6e8271477c17323f5c97d5bd72a4032f5eac2bf /src/app | |
parent | c6b4eea7fb6074ea9a1217d0c8b3a6dba382d9a0 (diff) |
close staging area when a verb empties it
(for example on :rm done in the SA)
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/panel_state.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/app/panel_state.rs b/src/app/panel_state.rs index 743579b..ef21a09 100644 --- a/src/app/panel_state.rs +++ b/src/app/panel_state.rs @@ -473,7 +473,7 @@ pub trait PanelState { if verb.needs_another_panel && app_state.other_panel_path.is_none() { return Ok(CmdResult::error("This verb needs another panel")); } - match &verb.execution { + let res = match &verb.execution { VerbExecution::Internal(internal_exec) => { self.on_internal(w, internal_exec, invocation, trigger_type, app_state, cc) } @@ -483,7 +483,21 @@ pub trait PanelState { VerbExecution::Sequence(seq_ex) => { self.execute_sequence(w, verb, seq_ex, invocation, app_state, cc) } + }; + if res.is_ok() { + // if the stage has been emptied by the operation (eg a "rm"), we + // close it + app_state.stage.refresh(); + if app_state.stage.is_empty() { + if let Some(id) = cc.app.stage_panel { + return Ok(CmdResult::ClosePanel { + validate_purpose: false, + panel_ref: PanelReference::Id(id), + }); + } + } } + res } fn execute_external( |