setActiveInstance method

void setActiveInstance({
  1. required String instanceId,
  2. required String paneId,
})

Called to set the instance given by instanceId as the active instance in the pane given by paneId.

  1. Adds the instanceId to the pane's data (if not already present)
  2. Updates the globally active instance
  3. Updates the active instance for the pane given by paneId
  4. Notifies listeners

Implementation

void setActiveInstance({
  required String instanceId,
  required String paneId,
}) {
  if (!api.workspace.workspaceConfigs.panesData[paneId]!.instances
      .contains(instanceId)) {
    api.workspace
        .addInstancesToPane(instanceIds: [instanceId], paneId: paneId);
  }
  api.workspace.workspaceConfigs
    ..activeInstance = instanceId
    ..panesData[paneId]!.activeInstance = instanceId;
  AffogatoEvents.windowPaneRequestReloadEventsController
      .add(WindowPaneRequestReloadEvent(paneId));
  AffogatoEvents.windowInstanceDidSetActiveEventsController
      .add(WindowInstanceDidSetActiveEvent(instanceId: instanceId));
}