diff --git a/nion/swift/DocumentController.py b/nion/swift/DocumentController.py index d40365f42..63fb20fac 100755 --- a/nion/swift/DocumentController.py +++ b/nion/swift/DocumentController.py @@ -2755,6 +2755,7 @@ def _get_action_context_for_display_items(self, display_items: typing.Sequence[D if not data_item_1 in used_data_items: used_data_items.append(data_item_1) selected_graphics = used_display_item.selected_graphics if used_display_item else list() + selected_display_panel = selected_display_panel or (display_panel if len(used_display_panels) == 1 else None) return DocumentController.ActionContext(typing.cast("Application.Application", self.app), self, focus_widget, used_display_panel, used_display_panels, selected_display_panel, model, used_display_item, used_display_items, crop_graphic, selected_graphics, diff --git a/nion/swift/test/Workspace_test.py b/nion/swift/test/Workspace_test.py index 1afa98201..54acb7f40 100644 --- a/nion/swift/test/Workspace_test.py +++ b/nion/swift/test/Workspace_test.py @@ -632,6 +632,15 @@ def test_workspace_split_with_another_panel_focused(self): action_context = document_controller._get_action_context_for_display_items(document_controller.selected_display_items, workspace_controller.display_panels[0]) document_controller.perform_action_in_context("workspace.split_vertical", action_context) + def test_workspace_split_with_another_no_panel_focused(self): + with TestContext.create_memory_context() as test_context: + document_controller = test_context.create_document_controller() + workspace_controller = document_controller.workspace_controller + self.assertEqual(1, len(workspace_controller.display_panels)) + document_controller.selected_display_panel = None + action_context = document_controller._get_action_context_for_display_items(document_controller.selected_display_items, workspace_controller.display_panels[0]) + document_controller.perform_action_in_context("workspace.split_vertical", action_context) + def test_workspace_split_horizontal_does_not_create_extra_splits(self): with TestContext.create_memory_context() as test_context: document_controller = test_context.create_document_controller()