Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/workspace/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ pub enum WorkspaceAction {
ToggleTabGroupCollapsed(TabGroupId),
/// Opens an inline editor over the given group's header for renaming.
RenameTabGroup(TabGroupId),
CommitActiveRename,
CancelActiveRename,
/// Creates a new tab group containing the tab at the given index.
NewTabGroupFromTab(usize),
Expand Down Expand Up @@ -1156,6 +1157,7 @@ impl WorkspaceAction {
| ShiftSelectTabRange { .. }
| ToggleTabMultiSelection { .. }
| ClearTabMultiSelection
| CommitActiveRename
| CancelActiveRename
| StartNewConversation { .. }
| UndoRevertInCodeReviewPane { .. }
Expand Down
5 changes: 5 additions & 0 deletions app/src/workspace/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23959,6 +23959,11 @@ impl TypedActionView for Workspace {
CloseTabGroup(group_id) => self.close_tab_group(*group_id, ctx),
ToggleTabGroupCollapsed(group_id) => self.toggle_tab_group_collapsed(*group_id, ctx),
RenameTabGroup(group_id) => self.rename_tab_group(*group_id, ctx),
CommitActiveRename => {
self.finish_tab_rename(ctx);
self.finish_pane_rename(ctx);
self.finish_tab_group_rename(ctx);
}
CancelActiveRename => {
self.cancel_tab_rename(ctx);
self.cancel_pane_rename(ctx);
Expand Down
2 changes: 1 addition & 1 deletion app/src/workspace/view/vertical_tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ fn render_vertical_tabs_panel(
.finish()
})
.on_click(|ctx, _, _| {
ctx.dispatch_typed_action(WorkspaceAction::CancelActiveRename);
ctx.dispatch_typed_action(WorkspaceAction::CommitActiveRename);
})
.on_right_click(|ctx, _, position| {
if FeatureFlag::GroupedTabs.is_enabled() {
Expand Down
91 changes: 91 additions & 0 deletions app/src/workspace/view_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,62 @@ fn test_tab_renaming_editor_selections() {
});
}

#[test]
fn test_commit_active_rename_commits_tab_rename() {
App::test((), |mut app| async move {
initialize_app(&mut app);

let workspace = mock_workspace(&mut app);

workspace.update(&mut app, |workspace, ctx| {
workspace.rename_tab_internal(0, "old title", ctx);
workspace.tab_rename_editor.update(ctx, |editor, ctx| {
editor.insert_selected_text("new title", ctx);
});

workspace.handle_action(&WorkspaceAction::CommitActiveRename, ctx);

assert!(!workspace.current_workspace_state.is_tab_being_renamed());
assert_eq!(
workspace.tabs[0]
.pane_group
.as_ref(ctx)
.custom_title(ctx)
.as_deref(),
Some("new title")
);
});
});
}

#[test]
fn test_cancel_active_rename_discards_tab_rename() {
App::test((), |mut app| async move {
initialize_app(&mut app);

let workspace = mock_workspace(&mut app);

workspace.update(&mut app, |workspace, ctx| {
workspace.rename_tab_internal(0, "old title", ctx);
workspace.tab_rename_editor.update(ctx, |editor, ctx| {
editor.insert_selected_text("new title", ctx);
});

workspace.handle_action(&WorkspaceAction::CancelActiveRename, ctx);

assert!(!workspace.current_workspace_state.is_tab_being_renamed());
assert_ne!(
workspace.tabs[0]
.pane_group
.as_ref(ctx)
.custom_title(ctx)
.as_deref(),
Some("new title")
);
});
});
}

#[test]
fn test_tab_renaming_editor_reset() {
App::test((), |mut app| async move {
Expand Down Expand Up @@ -4606,6 +4662,41 @@ fn test_toggle_tab_group_collapsed_flips_state() {
});
}

#[test]
fn test_commit_active_rename_commits_tab_group_rename() {
let _grouped_tabs_guard = FeatureFlag::GroupedTabs.override_enabled(true);

App::test((), |mut app| async move {
initialize_app(&mut app);

let workspace = mock_workspace(&mut app);
workspace.update(&mut app, |workspace, ctx| {
let group = TabGroup::new();
let group_id = group.id;
workspace.tab_groups.insert(group_id, group);
workspace.tabs[0].group_id = Some(group_id);
workspace.rename_tab_group(group_id, ctx);
workspace
.tab_group_rename_editor
.update(ctx, |editor, ctx| {
editor.insert_selected_text("renamed group", ctx);
});

workspace.handle_action(&WorkspaceAction::CommitActiveRename, ctx);

assert!(
!workspace
.current_workspace_state
.is_any_tab_group_being_renamed()
);
assert_eq!(
workspace.tab_groups[&group_id].name.as_deref(),
Some("renamed group")
);
});
});
}

#[test]
fn test_close_tab_group_removes_group_and_members() {
let _grouped_tabs_guard = FeatureFlag::GroupedTabs.override_enabled(true);
Expand Down
Loading