workspace: Add Close Multibuffers pane context menu entry (#39199)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-05 10:50:36 +02:00
committed by GitHub
parent eb64ca8758
commit 1a9e9c5faa
22 changed files with 332 additions and 144 deletions
+18 -11
View File
@@ -60,7 +60,10 @@ use notifications::{
simple_message_notification::MessageNotification,
};
pub use pane::*;
pub use pane_group::*;
pub use pane_group::{
ActivePaneDecorator, HANDLE_HITBOX_SIZE, Member, PaneAxis, PaneGroup, PaneRenderContext,
SplitDirection,
};
use persistence::{DB, SerializedWindowBounds, model::SerializedWorkspace};
pub use persistence::{
DB as WORKSPACE_DB, WorkspaceDb, delete_unloaded_items,
@@ -117,11 +120,11 @@ pub use workspace_settings::{
};
use zed_actions::{Spawn, feedback::FileBugReport};
use crate::notifications::NotificationId;
use crate::persistence::{
SerializedAxis,
model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup},
};
use crate::{item::ItemBufferKind, notifications::NotificationId};
pub const SERIALIZATION_THROTTLE_TIME: Duration = Duration::from_millis(200);
@@ -2521,8 +2524,12 @@ impl Workspace {
};
for (pane, item) in dirty_items {
let (singleton, project_entry_ids) =
cx.update(|_, cx| (item.is_singleton(cx), item.project_entry_ids(cx)))?;
let (singleton, project_entry_ids) = cx.update(|_, cx| {
(
item.buffer_kind(cx) == ItemBufferKind::Singleton,
item.project_entry_ids(cx),
)
})?;
if (singleton || !project_entry_ids.is_empty())
&& !Pane::save_item(project.clone(), &pane, &*item, save_intent, cx).await?
{
@@ -4805,7 +4812,7 @@ impl Workspace {
.items()
.find_map(|item| {
let item = item.to_followable_item_handle(cx)?;
if item.is_singleton(cx)
if item.buffer_kind(cx) == ItemBufferKind::Singleton
&& item.project_item_model_ids(cx).as_slice()
== [buffer_entity_id]
{
@@ -8192,7 +8199,7 @@ mod tests {
use crate::{
dock::{PanelEvent, test::TestPanel},
item::{
ItemEvent,
ItemBufferKind, ItemEvent,
test::{TestItem, TestProjectItem},
},
};
@@ -8553,7 +8560,7 @@ mod tests {
let item_2_3 = cx.new(|cx| {
TestItem::new(cx)
.with_dirty(true)
.with_singleton(false)
.with_buffer_kind(ItemBufferKind::Multibuffer)
.with_project_items(&[
single_entry_items[2].read(cx).project_items[0].clone(),
single_entry_items[3].read(cx).project_items[0].clone(),
@@ -8562,7 +8569,7 @@ mod tests {
let item_3_4 = cx.new(|cx| {
TestItem::new(cx)
.with_dirty(true)
.with_singleton(false)
.with_buffer_kind(ItemBufferKind::Multibuffer)
.with_project_items(&[
single_entry_items[3].read(cx).project_items[0].clone(),
single_entry_items[4].read(cx).project_items[0].clone(),
@@ -9583,7 +9590,7 @@ mod tests {
let dirty_multi_buffer_with_both = cx.new(|cx| {
TestItem::new(cx)
.with_dirty(true)
.with_singleton(false)
.with_buffer_kind(ItemBufferKind::Multibuffer)
.with_label("Fake Project Search")
.with_project_items(&[
dirty_regular_buffer.read(cx).project_items[0].clone(),
@@ -9734,7 +9741,7 @@ mod tests {
let dirty_multi_buffer_with_both = cx.new(|cx| {
TestItem::new(cx)
.with_dirty(true)
.with_singleton(false)
.with_buffer_kind(ItemBufferKind::Multibuffer)
.with_label("Fake Project Search")
.with_project_items(&[
dirty_regular_buffer.read(cx).project_items[0].clone(),
@@ -10148,7 +10155,7 @@ mod tests {
let dirty_multi_buffer = cx.new(|cx| {
TestItem::new(cx)
.with_dirty(true)
.with_singleton(false)
.with_buffer_kind(ItemBufferKind::Multibuffer)
.with_label("Fake Project Search")
.with_project_items(&[
dirty_regular_buffer.read(cx).project_items[0].clone(),