pane: Ignore max tabs on terminal pane (#40740)
Closes #39901 I'm unsure as to which direction the team wants to go with this, but this is the behavior of VSCode which is what this feature is based off so i'm going with this. Changes: 1. Introduced a new argument to the `new` method on the Pane called `ignore_max_tabs` that forces the `max_tabs` to None if it's true. 2. Added a new test `test_bypass_max_tabs_limit`. Release Notes: - Fixed: `max_tabs` Setting affecting the terminal pane. --------- Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
This commit is contained in:
@@ -376,6 +376,7 @@ pub struct Pane {
|
||||
render_tab_bar: Rc<dyn Fn(&mut Pane, &mut Window, &mut Context<Pane>) -> AnyElement>,
|
||||
show_tab_bar_buttons: bool,
|
||||
max_tabs: Option<NonZeroUsize>,
|
||||
use_max_tabs: bool,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
tab_bar_scroll_handle: ScrollHandle,
|
||||
/// This is set to true if a user scroll has occurred more recently than a system scroll
|
||||
@@ -473,10 +474,16 @@ impl Pane {
|
||||
next_timestamp: Arc<AtomicUsize>,
|
||||
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut Window, &mut App) -> bool + 'static>>,
|
||||
double_click_dispatch_action: Box<dyn Action>,
|
||||
use_max_tabs: bool,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let focus_handle = cx.focus_handle();
|
||||
let max_tabs = if use_max_tabs {
|
||||
WorkspaceSettings::get_global(cx).max_tabs
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let subscriptions = vec![
|
||||
cx.on_focus(&focus_handle, window, Pane::focus_in),
|
||||
@@ -498,7 +505,8 @@ impl Pane {
|
||||
zoomed: false,
|
||||
active_item_index: 0,
|
||||
preview_item_id: None,
|
||||
max_tabs: WorkspaceSettings::get_global(cx).max_tabs,
|
||||
max_tabs,
|
||||
use_max_tabs,
|
||||
last_focus_handle_by_item: Default::default(),
|
||||
nav_history: NavHistory(Arc::new(Mutex::new(NavHistoryState {
|
||||
mode: NavigationMode::Normal,
|
||||
@@ -706,7 +714,7 @@ impl Pane {
|
||||
self.preview_item_id = None;
|
||||
}
|
||||
|
||||
if new_max_tabs != self.max_tabs {
|
||||
if self.use_max_tabs && new_max_tabs != self.max_tabs {
|
||||
self.max_tabs = new_max_tabs;
|
||||
self.close_items_on_settings_change(window, cx);
|
||||
}
|
||||
|
||||
@@ -1331,6 +1331,7 @@ impl Workspace {
|
||||
pane_history_timestamp.clone(),
|
||||
None,
|
||||
NewFile.boxed_clone(),
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
@@ -3235,6 +3236,7 @@ impl Workspace {
|
||||
self.pane_history_timestamp.clone(),
|
||||
None,
|
||||
NewFile.boxed_clone(),
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user