summaryrefslogtreecommitdiffstats
path: root/src/browser/browser_state.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-02-24 19:49:41 +0100
committerCanop <cano.petrole@gmail.com>2021-02-24 19:49:41 +0100
commit7d512894808500946a6acb6d4939d4ba1473c14d (patch)
tree78ce8071e4c3f85a2b22c621c5a75c03cca8d81a /src/browser/browser_state.rs
parentab3602693a5361187427a5ebab3e4705956c01e6 (diff)
limit the number of panels to 2
Can be changed in conf with `max_panels_count`. Fix #345
Diffstat (limited to 'src/browser/browser_state.rs')
-rw-r--r--src/browser/browser_state.rs36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs
index 91110a3..9dae74c 100644
--- a/src/browser/browser_state.rs
+++ b/src/browser/browser_state.rs
@@ -346,30 +346,23 @@ impl AppState for BrowserState {
AppStateCmdResult::Keep
}
Internal::panel_left => {
- if cc.areas.is_first() {
- if cc.preview.is_some() && cc.areas.nb_pos == 2 {
- AppStateCmdResult::ClosePanel {
- validate_purpose: false,
- id: cc.preview,
- }
- } else {
- // we ask for the creation of a panel to the left
- internal_focus::new_panel_on_path(
- self.selected_path().to_path_buf(),
- screen,
- self.displayed_tree().options.clone(),
- PanelPurpose::None,
- con,
- HDir::Left,
- )
- }
+ if cc.areas.is_first() && cc.areas.nb_pos < cc.con.max_panels_count {
+ // we ask for the creation of a panel to the left
+ internal_focus::new_panel_on_path(
+ self.selected_path().to_path_buf(),
+ screen,
+ self.displayed_tree().options.clone(),
+ PanelPurpose::None,
+ con,
+ HDir::Left,
+ )
} else {
- // we ask the app to focus the panel to the left
+ // we let the app handle other cases
AppStateCmdResult::HandleInApp(Internal::panel_left)
}
}
Internal::panel_right => {
- if cc.areas.is_last() {
+ if cc.areas.is_last() && cc.areas.nb_pos < cc.con.max_panels_count {
let purpose = if self.selected_path().is_file() && cc.preview.is_none() {
PanelPurpose::Preview
} else {
@@ -385,7 +378,8 @@ impl AppState for BrowserState {
HDir::Right,
)
} else {
- // we ask the app to focus the panel to the right
+ // we ask the app to handle other cases :
+ // focus the panel to the right or close the leftest one
AppStateCmdResult::HandleInApp(Internal::panel_right)
}
}
@@ -415,7 +409,7 @@ impl AppState for BrowserState {
debug!("start_end understood as end");
AppStateCmdResult::ClosePanel {
validate_purpose: true,
- id: None,
+ panel_ref: PanelReference::Active,
}
} else {
debug!("start_end understood as start");