Add "New Window" command

This commit is contained in:
Max Brunsfeld 2022-05-20 11:01:20 -07:00
parent c4fc3d9c7f
commit e72f5cea22
6 changed files with 30 additions and 16 deletions

View file

@ -38,7 +38,7 @@ use std::{
};
use theme::{ThemeRegistry, DEFAULT_THEME_NAME};
use util::{ResultExt, TryFutureExt};
use workspace::{self, AppState, OpenNew, OpenPaths};
use workspace::{self, AppState, NewFile, OpenPaths};
use zed::{
self, build_window_options,
fs::RealFs,
@ -206,7 +206,7 @@ fn main() {
cx.platform().activate(true);
let paths = collect_path_args();
if paths.is_empty() {
cx.dispatch_global_action(OpenNew);
cx.dispatch_global_action(NewFile);
} else {
cx.dispatch_global_action(OpenPaths { paths });
}
@ -215,7 +215,7 @@ fn main() {
cx.spawn(|cx| handle_cli_connection(connection, app_state.clone(), cx))
.detach();
} else {
cx.dispatch_global_action(OpenNew);
cx.dispatch_global_action(NewFile);
}
cx.spawn(|cx| async move {
while let Some(connection) = cli_connections_rx.next().await {

View file

@ -31,7 +31,11 @@ pub fn menus() -> Vec<Menu<'static>> {
items: vec![
MenuItem::Action {
name: "New",
action: Box::new(workspace::OpenNew),
action: Box::new(workspace::NewFile),
},
MenuItem::Action {
name: "New Window",
action: Box::new(workspace::NewWindow),
},
MenuItem::Separator,
MenuItem::Action {

View file

@ -314,7 +314,7 @@ mod tests {
};
use theme::{Theme, ThemeRegistry, DEFAULT_THEME_NAME};
use workspace::{
open_paths, pane, Item, ItemHandle, OpenNew, Pane, SplitDirection, WorkspaceHandle,
open_paths, pane, Item, ItemHandle, NewFile, Pane, SplitDirection, WorkspaceHandle,
};
#[gpui::test]
@ -376,7 +376,7 @@ mod tests {
#[gpui::test]
async fn test_new_empty_workspace(cx: &mut TestAppContext) {
let app_state = init(cx);
cx.dispatch_global_action(workspace::OpenNew);
cx.dispatch_global_action(workspace::NewFile);
let window_id = *cx.window_ids().first().unwrap();
let workspace = cx.root_view::<Workspace>(window_id).unwrap();
let editor = workspace.update(cx, |workspace, cx| {
@ -686,7 +686,7 @@ mod tests {
let worktree = cx.read(|cx| workspace.read(cx).worktrees(cx).next().unwrap());
// Create a new untitled buffer
cx.dispatch_action(window_id, OpenNew);
cx.dispatch_action(window_id, NewFile);
let editor = workspace.read_with(cx, |workspace, cx| {
workspace
.active_item(cx)
@ -741,7 +741,7 @@ mod tests {
// Open the same newly-created file in another pane item. The new editor should reuse
// the same buffer.
cx.dispatch_action(window_id, OpenNew);
cx.dispatch_action(window_id, NewFile);
workspace
.update(cx, |workspace, cx| {
workspace.split_pane(workspace.active_pane().clone(), SplitDirection::Right, cx);
@ -774,7 +774,7 @@ mod tests {
let (window_id, workspace) = cx.add_window(|cx| Workspace::new(project, cx));
// Create a new untitled buffer
cx.dispatch_action(window_id, OpenNew);
cx.dispatch_action(window_id, NewFile);
let editor = workspace.read_with(cx, |workspace, cx| {
workspace
.active_item(cx)