Add check to prevent closing pinned items#50333
Add check to prevent closing pinned items#50333JosephTLyons merged 5 commits intozed-industries:mainfrom
Conversation
|
Perhaps such modifications would be better: 1 diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
2 index 66e5eeb473..0d025ac350 100644
3 --- a/crates/workspace/src/pane.rs
4 +++ b/crates/workspace/src/pane.rs
5 @@ -2859,7 +2859,7 @@ impl Pane {
6 }))
7 .on_aux_click(
8 cx.listener(move |pane: &mut Self, event: &ClickEvent, window, cx| {
9 - if !event.is_middle_click() {
10 + if !event.is_middle_click() || is_pinned {
11 return;
12 }
13 |
Pinned items should not be closed when the close action is triggered.
a9c7c8f to
0a5c70d
Compare
|
@austincummings It's possible that we could also add an automated test for this functionality. I think there are some examples in the For example, I think we can simulate the middle-click event like this: cx.simulate_event(MouseDownEvent {
position: tab_a_bounds.center(),
button: MouseButton::Middle,
modifiers: Modifiers::default(),
click_count: 1,
first_mouse: false,
});
cx.run_until_parked();
cx.simulate_event(MouseUpEvent {
position: tab_a_bounds.center(),
button: MouseButton::Middle,
modifiers: Modifiers::default(),
click_count: 1,
});
cx.run_until_parked();There's more code needed for the entire test, here's an entire test function for reference: https://github.com/seanstrom/zed/blob/083cdcf6348aecdfd4770735bd50b9e0a578b741/crates/workspace/src/pane.rs#L6804-L6868 |
|
Thanks for this fix @austincummings. I agree with @seanstrom that we should have a test in place to keep this behavior pinned. Sean's test looks great, testing a middle click on both a pinned and an unpinned tab, and ensuring the first remains and the second is closed. |
Test that middle-clicking a pinned tab does not close it, while middle-clicking an unpinned tab does close it as expected.
|
Added a test! |
|
Perfect. Thank you! |
|
@austincummings, can you fix the failing CI? It is just an unused import. Also, if you could rebase on main and force push, just so this branch is up to date, that would be awesome. Thank you for your work! |
|
@JosephTLyons yep my bad! Fixed |
|
Thank you! |
|
@zed-zippy approved |
Pinned items should not be closed when the close action is triggered.
Closes #50309
Before you mark this PR as ready for review, make sure that you have:
Release Notes: