Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

feat: Add reveal buffer if already open (#63306)

Sean Wood351899e53107
diff --git a/assets/settings/default.json b/assets/settings/default.json
index 0455f31b3d5..9ad2ee3271d 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -188,6 +188,8 @@
//
// Default: true
"restore_on_file_reopen": true,
+ // Whether to reveal an already open file in an existing pane instead of opening it in the active pane.
+ "reveal_if_open": false,
// Whether to automatically close files that have been deleted on disk.
"close_on_file_delete": false,
// Whether toggling a panel (e.g. with its keyboard shortcut) also closes
diff --git a/crates/call_hierarchy/src/call_hierarchy.rs b/crates/call_hierarchy/src/call_hierarchy.rs
index bc20c57baf5..6680fca443b 100644
--- a/crates/call_hierarchy/src/call_hierarchy.rs
+++ b/crates/call_hierarchy/src/call_hierarchy.rs
@@ -641,8 +641,16 @@ impl PickerDelegate for CallHierarchyDelegate {
workspace.active_pane().clone()
};
- let editor = workspace
- .open_project_item::<Editor>(pane, buffer, true, true, true, true, window, cx);
+ let editor = workspace.open_project_item::<Editor>(
+ Some(pane),
+ buffer,
+ true,
+ true,
+ true,
+ true,
+ window,
+ cx,
+ );
editor.update(cx, |editor, cx| {
editor.change_selections(
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index c9fa7409317..c1aea14d1db 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -10444,7 +10444,7 @@ impl Editor {
let allow_new_preview = PreviewTabsSettings::get_global(cx)
.enable_preview_from_multibuffer;
workspace.open_project_item::<Self>(
- pane.clone(),
+ split.then_some(pane.clone()),
buffer,
true,
true,
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs
index c718e9541a9..d489c5e3a99 100644
--- a/crates/editor/src/editor_tests.rs
+++ b/crates/editor/src/editor_tests.rs
@@ -30469,6 +30469,135 @@ let foo = 15;"#,
});
}
+#[gpui::test]
+async fn test_goto_definition_reveals_existing_editor_in_other_pane(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+ cx.update(|cx| {
+ SettingsStore::update_global(cx, |store, cx| {
+ store.update_user_settings(cx, |settings| {
+ settings.workspace.reveal_if_open = Some(true);
+ });
+ });
+ });
+
+ let mut cx = EditorLspTestContext::new_rust(
+ lsp::ServerCapabilities {
+ definition_provider: Some(lsp::OneOf::Left(true)),
+ ..lsp::ServerCapabilities::default()
+ },
+ cx,
+ )
+ .await;
+ cx.set_state("fn main() { ˇtarget(); }");
+
+ let origin_path = cx.update_editor(|editor, _, cx| editor.active_project_path(cx).unwrap());
+ let (fake_fs, worktree_id) = cx.update_workspace(|workspace, _, cx| {
+ let project = workspace.project();
+ let fake_fs = project.read(cx).fs().as_fake();
+ let worktree_id = project.read(cx).worktrees(cx).next().unwrap().read(cx).id();
+ (fake_fs, worktree_id)
+ });
+ let target_abs_path = EditorLspTestContext::root_path()
+ .join("dir")
+ .join("definition.rs");
+ fake_fs
+ .insert_file(&target_abs_path, b"fn target() {}\n".to_vec())
+ .await;
+ cx.run_until_parked();
+
+ let (left_pane, right_pane) = cx.update_workspace(|workspace, window, cx| {
+ let left_pane = workspace.active_pane().clone();
+ let right_pane = workspace.split_pane(left_pane.clone(), SplitDirection::Right, window, cx);
+ (left_pane, right_pane)
+ });
+ let origin_editor = cx
+ .update_workspace(|workspace, window, cx| {
+ workspace.open_path(origin_path, Some(right_pane.downgrade()), true, window, cx)
+ })
+ .await
+ .unwrap()
+ .downcast::<Editor>()
+ .unwrap();
+ let target_editor = cx
+ .update_workspace(|workspace, window, cx| {
+ workspace.open_path(
+ (worktree_id, rel_path("dir/definition.rs")),
+ Some(left_pane.downgrade()),
+ false,
+ window,
+ cx,
+ )
+ })
+ .await
+ .unwrap()
+ .downcast::<Editor>()
+ .unwrap();
+ let target_buffer = target_editor.read_with(&cx.cx.cx, |editor, cx| {
+ editor.buffer().read(cx).as_singleton().unwrap()
+ });
+ cx.update_workspace(|workspace, window, cx| {
+ assert!(workspace.activate_item(&origin_editor, true, true, window, cx));
+ });
+ cx.run_until_parked();
+ cx.update_workspace(|workspace, _, _| {
+ assert_eq!(workspace.active_pane(), &right_pane);
+ });
+
+ let target_uri = lsp::Uri::from_file_path(target_abs_path).unwrap();
+ let _go_to_definition = cx
+ .lsp
+ .set_request_handler::<lsp::request::GotoDefinition, _, _>(move |_, _| {
+ let target_uri = target_uri.clone();
+ async move {
+ Ok(Some(lsp::GotoDefinitionResponse::Scalar(lsp::Location {
+ uri: target_uri,
+ range: lsp::Range::new(lsp::Position::new(0, 3), lsp::Position::new(0, 9)),
+ })))
+ }
+ });
+
+ let navigated = origin_editor
+ .update_in(&mut cx.cx.cx, |editor, window, cx| {
+ editor.go_to_definition(&GoToDefinition::default(), window, cx)
+ })
+ .await
+ .expect("Failed to navigate to definition");
+ assert_eq!(navigated, Navigated::Yes);
+ cx.run_until_parked();
+
+ cx.update_workspace(|workspace, _, cx| {
+ assert_eq!(workspace.active_pane(), &left_pane);
+ assert_eq!(
+ left_pane
+ .read(cx)
+ .active_item()
+ .unwrap()
+ .downcast::<Editor>()
+ .unwrap(),
+ target_editor
+ );
+ assert_eq!(
+ right_pane
+ .read(cx)
+ .active_item()
+ .unwrap()
+ .downcast::<Editor>()
+ .unwrap(),
+ origin_editor
+ );
+ assert_eq!(
+ workspace
+ .items_of_type::<Editor>(cx)
+ .filter(|editor| {
+ editor.read(cx).buffer().read(cx).as_singleton().as_ref()
+ == Some(&target_buffer)
+ })
+ .count(),
+ 1
+ );
+ });
+}
+
#[gpui::test]
async fn test_goto_definition_with_find_all_references_fallback(cx: &mut TestAppContext) {
init_test(cx, |_| {});
@@ -35373,6 +35502,75 @@ async fn test_apply_code_lens_actions_with_commands(cx: &mut gpui::TestAppContex
);
}
+#[gpui::test]
+async fn test_reveal_if_open_uses_user_setting_for_loaded_editor(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+ cx.update_global(|store: &mut SettingsStore, cx| {
+ store
+ .set_user_settings(r#"{ "reveal_if_open": true }"#, cx)
+ .unwrap();
+ });
+
+ let fs = FakeFs::new(cx.executor());
+ fs.insert_tree(path!("/root"), json!({ "file.txt": "content" }))
+ .await;
+ let project = Project::test(fs, [path!("/root").as_ref()], cx).await;
+ let (multi_workspace, cx) =
+ cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
+ let workspace =
+ multi_workspace.read_with(cx, |multi_workspace, _| multi_workspace.workspace().clone());
+ let worktree_id = project.read_with(cx, |project, cx| {
+ project.worktrees(cx).next().unwrap().read(cx).id()
+ });
+ let left_pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
+ let original_editor = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path((worktree_id, rel_path("file.txt")), None, true, window, cx)
+ })
+ .await
+ .unwrap()
+ .downcast::<Editor>()
+ .unwrap();
+ let buffer = original_editor.read_with(cx, |editor, cx| {
+ editor.buffer().read(cx).as_singleton().unwrap()
+ });
+
+ let right_pane = workspace.update_in(cx, |workspace, window, cx| {
+ let right_pane = workspace.split_pane(left_pane.clone(), SplitDirection::Right, window, cx);
+ window.focus(&right_pane.focus_handle(cx), cx);
+ right_pane
+ });
+ cx.run_until_parked();
+ workspace.read_with(cx, |workspace, _| {
+ assert_eq!(workspace.active_pane(), &right_pane);
+ });
+
+ let revealed_editor = workspace.update_in(cx, |workspace, window, cx| {
+ workspace.open_project_item(None, buffer.clone(), true, true, false, false, window, cx)
+ });
+ assert_eq!(revealed_editor, original_editor);
+ assert_eq!(left_pane.read_with(cx, |pane, _| pane.items_len()), 1);
+ assert_eq!(right_pane.read_with(cx, |pane, _| pane.items_len()), 0);
+ workspace.read_with(cx, |workspace, _| {
+ assert_eq!(workspace.active_pane(), &left_pane);
+ });
+
+ let duplicate_editor = workspace.update_in(cx, |workspace, window, cx| {
+ workspace.open_project_item(
+ Some(right_pane.clone()),
+ buffer,
+ true,
+ true,
+ false,
+ false,
+ window,
+ cx,
+ )
+ });
+ assert_ne!(duplicate_editor, original_editor);
+ assert_eq!(right_pane.read_with(cx, |pane, _| pane.items_len()), 1);
+}
+
#[gpui::test]
async fn test_editor_restore_data_different_in_panes(cx: &mut TestAppContext) {
init_test(cx, |_| {});
diff --git a/crates/editor/src/navigation.rs b/crates/editor/src/navigation.rs
index 1c075e72bd4..76108fdd7df 100644
--- a/crates/editor/src/navigation.rs
+++ b/crates/editor/src/navigation.rs
@@ -1467,8 +1467,6 @@ impl Editor {
window.defer(cx, move |window, cx| {
let target_editor: Entity<Self> =
workspace.update(cx, |workspace, cx| {
- let pane = workspace.active_pane().clone();
-
let preview_tabs_settings = PreviewTabsSettings::get_global(cx);
let keep_old_preview = preview_tabs_settings
.enable_keep_preview_on_code_navigation;
@@ -1476,7 +1474,7 @@ impl Editor {
.enable_preview_file_from_code_navigation;
workspace.open_project_item(
- pane,
+ None,
target_buffer.clone(),
true,
true,
@@ -1942,7 +1940,7 @@ impl Editor {
window.defer(cx, move |window, cx| {
let (target_editor, target_pane): (Entity<Self>, Entity<Pane>) =
workspace.update(cx, |workspace, cx| {
- let pane = if split {
+ let requested_pane = if split {
workspace.adjacent_pane(window, cx)
} else {
workspace.active_pane().clone()
@@ -1955,7 +1953,7 @@ impl Editor {
.enable_preview_file_from_code_navigation;
let editor = workspace.open_project_item(
- pane.clone(),
+ split.then_some(requested_pane.clone()),
target_buffer.clone(),
true,
true,
@@ -1964,7 +1962,10 @@ impl Editor {
window,
cx,
);
- (editor, pane)
+ let target_pane = workspace
+ .pane_for_item_id(editor.entity_id())
+ .unwrap_or(requested_pane);
+ (editor, target_pane)
});
// We create our own nav history instead of using
// `target_editor.nav_history` because `nav_history`
diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs
index 65771815693..5f6b4e50dbc 100644
--- a/crates/project_symbols/src/project_symbols.rs
+++ b/crates/project_symbols/src/project_symbols.rs
@@ -141,7 +141,14 @@ impl PickerDelegate for ProjectSymbolsDelegate {
};
let editor = workspace.open_project_item::<Editor>(
- pane, buffer, true, true, true, true, window, cx,
+ secondary.then_some(pane),
+ buffer,
+ true,
+ true,
+ true,
+ true,
+ window,
+ cx,
);
editor.update(cx, |editor, cx| {
diff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rs
index 32dfa8e12d0..4051de95e92 100644
--- a/crates/settings/src/vscode_import.rs
+++ b/crates/settings/src/vscode_import.rs
@@ -1066,6 +1066,7 @@ impl VsCodeSettings {
pane_split_direction_vertical: None,
resize_all_panels_in_dock: None,
restore_on_file_reopen: self.read_bool("workbench.editor.restoreViewState"),
+ reveal_if_open: self.read_bool("workbench.editor.revealIfOpen"),
restore_on_startup: None,
window_decorations: None,
show_call_status_icon: None,
@@ -1184,4 +1185,16 @@ mod tests {
);
assert_eq!(imported_reduce_motion("{}"), None);
}
+
+ #[test]
+ fn test_import_reveal_if_open() {
+ let settings = VsCodeSettings::from_str(
+ r#"{ "workbench.editor.revealIfOpen": true }"#,
+ VsCodeSettingsSource::VsCode,
+ )
+ .unwrap()
+ .settings_content();
+
+ assert_eq!(settings.workspace.reveal_if_open, Some(true));
+ }
}
diff --git a/crates/settings_content/src/workspace.rs b/crates/settings_content/src/workspace.rs
index 0b463c47157..bcc6ba1523b 100644
--- a/crates/settings_content/src/workspace.rs
+++ b/crates/settings_content/src/workspace.rs
@@ -67,6 +67,10 @@ pub struct WorkspaceSettingsContent {
///
/// Default: true
pub restore_on_file_reopen: Option<bool>,
+ /// Whether to reveal an already open file in an existing pane instead of opening it in the active pane.
+ ///
+ /// Default: false
+ pub reveal_if_open: Option<bool>,
/// The size of the workspace split drop targets on the outer edges.
/// Given as a fraction that will be multiplied by the smaller dimension of the workspace.
///
diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs
index 93aa3de59f3..66add381b95 100644
--- a/crates/settings_ui/src/page_data.rs
+++ b/crates/settings_ui/src/page_data.rs
@@ -273,6 +273,20 @@ fn general_page(cx: &App) -> SettingsPage {
})),
files: USER,
}),
+ SettingsPageItem::SettingItem(SettingItem {
+ title: "Reveal If Open",
+ description: "when enabled, zed will prefer already-open buffers.",
+ field: Box::new(SettingField {
+ organization_override: None,
+ json_path: Some("reveal_if_open"),
+ pick: |settings_content| settings_content.workspace.reveal_if_open.as_ref(),
+ write: |settings_content, value, _| {
+ settings_content.workspace.reveal_if_open = value;
+ },
+ }),
+ metadata: None,
+ files: USER,
+ }),
SettingsPageItem::SettingItem(SettingItem {
title: "Default Open Behavior",
description: "How projects open from the UI by default.",
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs
index b580481f43c..ca41b281fbc 100644
--- a/crates/workspace/src/workspace.rs
+++ b/crates/workspace/src/workspace.rs
@@ -4846,6 +4846,9 @@ impl Workspace {
})
}
+ /// Passing `None` for `pane` uses the default destination and honors
+ /// `reveal_if_open`. Passing a pane explicitly limits reuse and opening to
+ /// that pane.
pub fn open_path(
&mut self,
path: impl Into<ProjectPath>,
@@ -4867,7 +4870,8 @@ impl Workspace {
window: &mut Window,
cx: &mut App,
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
- let pane = pane.unwrap_or_else(|| {
+ let reveal_if_open = pane.is_none() && WorkspaceSettings::get_global(cx).reveal_if_open;
+ let requested_pane = pane.unwrap_or_else(|| {
self.last_active_center_pane.clone().unwrap_or_else(|| {
self.panes
.first()
@@ -4876,10 +4880,28 @@ impl Workspace {
})
});
+ let workspace = self.weak_self.clone();
let project_path = path.into();
let task = self.load_path(project_path.clone(), window, cx);
window.spawn(cx, async move |cx| {
let (project_entry_id, build_item) = task.await?;
+ let pane = if reveal_if_open {
+ workspace
+ .read_with(cx, |workspace, cx| {
+ workspace.pane_containing_project_item(
+ &requested_pane,
+ project_entry_id,
+ &project_path,
+ cx,
+ )
+ })
+ .ok()
+ .flatten()
+ .map(|pane| pane.downgrade())
+ .unwrap_or(requested_pane)
+ } else {
+ requested_pane
+ };
pane.update_in(cx, |pane, window, cx| {
pane.open_item(
@@ -4897,6 +4919,43 @@ impl Workspace {
})
}
+ fn pane_containing_project_item(
+ &self,
+ requested_pane: &WeakEntity<Pane>,
+ project_entry_id: Option<ProjectEntryId>,
+ project_path: &ProjectPath,
+ cx: &App,
+ ) -> Option<Entity<Pane>> {
+ let pane_contains_project_item = |pane: &Entity<Pane>| {
+ pane.read(cx).items().any(|item| {
+ if item.buffer_kind(cx) != ItemBufferKind::Singleton {
+ return false;
+ }
+
+ if let Some(project_entry_id) = project_entry_id {
+ item.project_entry_ids(cx).as_slice() == [project_entry_id]
+ } else {
+ item.project_path(cx).as_ref() == Some(project_path)
+ }
+ })
+ };
+
+ let requested_pane = requested_pane.upgrade();
+ if let Some(requested_pane) = requested_pane.as_ref()
+ && pane_contains_project_item(requested_pane)
+ {
+ return Some(requested_pane.clone());
+ }
+
+ self.panes.iter().find_map(|pane| {
+ if requested_pane.as_ref() == Some(pane) || !pane_contains_project_item(pane) {
+ None
+ } else {
+ Some(pane.clone())
+ }
+ })
+ }
+
/// Opens a URL or file path, intelligently routing to the appropriate handler:
///
/// - `http://` and `https://` URLs are opened in the system's default browser
@@ -5117,9 +5176,12 @@ impl Workspace {
.is_some()
}
+ /// Passing `None` for `pane` uses the active pane as the default destination
+ /// and honors `reveal_if_open`. Passing a pane explicitly limits reuse and
+ /// opening to that pane.
pub fn open_project_item<T>(
&mut self,
- pane: Entity<Pane>,
+ pane: Option<Entity<Pane>>,
project_item: Entity<T::Item>,
activate_pane: bool,
focus_item: bool,
@@ -5131,9 +5193,32 @@ impl Workspace {
where
T: ProjectItem,
{
+ let reveal_if_open = pane.is_none() && WorkspaceSettings::get_global(cx).reveal_if_open;
+ let requested_pane = pane.unwrap_or_else(|| self.active_pane.clone());
+ let existing_item = self
+ .find_project_item(&requested_pane, &project_item, cx)
+ .map(|item| (requested_pane.clone(), item))
+ .or_else(|| {
+ if reveal_if_open {
+ self.panes.iter().find_map(|pane| {
+ if pane == &requested_pane {
+ None
+ } else {
+ self.find_project_item(pane, &project_item, cx)
+ .map(|item| (pane.clone(), item))
+ }
+ })
+ } else {
+ None
+ }
+ });
+ let pane = existing_item
+ .as_ref()
+ .map(|(pane, _)| pane.clone())
+ .unwrap_or(requested_pane);
let old_item_id = pane.read(cx).active_item().map(|item| item.item_id());
- if let Some(item) = self.find_project_item(&pane, &project_item, cx) {
+ if let Some((_, item)) = existing_item {
if !keep_old_preview
&& let Some(old_id) = old_item_id
&& old_id != item.item_id()
@@ -17425,6 +17510,7 @@ mod tests {
// View
struct TestPngItemView {
focus_handle: FocusHandle,
+ project_item: Entity<TestPngItem>,
project_path: ProjectPath,
}
// Model
@@ -17464,6 +17550,18 @@ mod tests {
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
"".into()
}
+
+ fn for_each_project_item(
+ &self,
+ cx: &App,
+ callback: &mut dyn FnMut(EntityId, &dyn project::ProjectItem),
+ ) {
+ callback(self.project_item.entity_id(), self.project_item.read(cx));
+ }
+
+ fn buffer_kind(&self, _cx: &App) -> ItemBufferKind {
+ ItemBufferKind::Singleton
+ }
}
impl EventEmitter<()> for TestPngItemView {}
impl Focusable for TestPngItemView {
@@ -17497,6 +17595,7 @@ mod tests {
{
Self {
focus_handle: cx.focus_handle(),
+ project_item: item.clone(),
project_path: item.read(cx).project_path.clone(),
}
}
@@ -17688,6 +17787,127 @@ mod tests {
assert!(handle.is_err());
}
+ #[gpui::test]
+ async fn test_reveal_if_open(cx: &mut TestAppContext) {
+ init_test(cx);
+ cx.update(register_project_item::<TestPngItemView>);
+
+ let fs = FakeFs::new(cx.executor());
+ fs.insert_tree(
+ "/root",
+ json!({
+ "one.png": "",
+ "two.png": "",
+ }),
+ )
+ .await;
+ let project = Project::test(fs, ["root".as_ref()], cx).await;
+ let (workspace, cx) =
+ cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
+ let worktree_id = project.update(cx, |project, cx| {
+ project.worktrees(cx).next().unwrap().read(cx).id()
+ });
+ let left_pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
+
+ let one_in_left_pane = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path(
+ (worktree_id, rel_path("one.png")),
+ Some(left_pane.downgrade()),
+ true,
+ window,
+ cx,
+ )
+ })
+ .await
+ .unwrap();
+ let two_in_left_pane = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path(
+ (worktree_id, rel_path("two.png")),
+ Some(left_pane.downgrade()),
+ true,
+ window,
+ cx,
+ )
+ })
+ .await
+ .unwrap();
+
+ let right_pane = workspace.update_in(cx, |workspace, window, cx| {
+ let right_pane =
+ workspace.split_pane(left_pane.clone(), SplitDirection::Right, window, cx);
+ workspace.set_active_pane(&right_pane, window, cx);
+ right_pane
+ });
+
+ workspace.read_with(cx, |_, cx| {
+ assert!(!WorkspaceSettings::get_global(cx).reveal_if_open);
+ });
+ let one_in_right_pane = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path(
+ (worktree_id, rel_path("one.png")),
+ Some(right_pane.downgrade()),
+ true,
+ window,
+ cx,
+ )
+ })
+ .await
+ .unwrap();
+ assert_ne!(one_in_left_pane.item_id(), one_in_right_pane.item_id());
+
+ cx.update_global(|store: &mut SettingsStore, cx| {
+ store.update_user_settings(cx, |settings| {
+ settings.workspace.reveal_if_open = Some(true);
+ });
+ });
+
+ let revealed_two = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path((worktree_id, rel_path("two.png")), None, true, window, cx)
+ })
+ .await
+ .unwrap();
+
+ assert_eq!(revealed_two.item_id(), two_in_left_pane.item_id());
+ assert_eq!(left_pane.read_with(cx, |pane, _| pane.items_len()), 2);
+ assert_eq!(right_pane.read_with(cx, |pane, _| pane.items_len()), 1);
+ workspace.read_with(cx, |workspace, _| {
+ assert_eq!(workspace.active_pane(), &left_pane);
+ });
+
+ let two_in_right_pane = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.open_path(
+ (worktree_id, rel_path("two.png")),
+ Some(right_pane.downgrade()),
+ true,
+ window,
+ cx,
+ )
+ })
+ .await
+ .unwrap();
+
+ assert_ne!(two_in_right_pane.item_id(), two_in_left_pane.item_id());
+ assert_eq!(right_pane.read_with(cx, |pane, _| pane.items_len()), 2);
+
+ let two_in_split_pane = workspace
+ .update_in(cx, |workspace, window, cx| {
+ workspace.split_path((worktree_id, rel_path("two.png")), window, cx)
+ })
+ .await
+ .unwrap();
+
+ assert_ne!(two_in_split_pane.item_id(), two_in_left_pane.item_id());
+ assert_ne!(two_in_split_pane.item_id(), two_in_right_pane.item_id());
+ workspace.read_with(cx, |workspace, _| {
+ assert_eq!(workspace.panes.len(), 3);
+ });
+ }
+
#[gpui::test]
async fn test_open_url_or_file_resolves_remote_base_path(cx: &mut TestAppContext) {
init_test(cx);
diff --git a/crates/workspace/src/workspace_settings.rs b/crates/workspace/src/workspace_settings.rs
index 1011579c6e9..b88658fea48 100644
--- a/crates/workspace/src/workspace_settings.rs
+++ b/crates/workspace/src/workspace_settings.rs
@@ -25,6 +25,7 @@ pub struct WorkspaceSettings {
pub cli_default_open_behavior: settings::CliDefaultOpenBehavior,
pub default_open_behavior: settings::DefaultOpenBehavior,
pub restore_on_file_reopen: bool,
+ pub reveal_if_open: bool,
pub drop_target_size: f32,
pub use_system_path_prompts: bool,
pub use_system_prompts: bool,
@@ -120,6 +121,7 @@ impl Settings for WorkspaceSettings {
cli_default_open_behavior: workspace.cli_default_open_behavior.unwrap(),
default_open_behavior: workspace.default_open_behavior.unwrap(),
restore_on_file_reopen: workspace.restore_on_file_reopen.unwrap(),
+ reveal_if_open: workspace.reveal_if_open.unwrap(),
drop_target_size: workspace.drop_target_size.unwrap(),
use_system_path_prompts: workspace.use_system_path_prompts.unwrap(),
use_system_prompts: workspace.use_system_prompts.unwrap(),