requestDocumentSetActive method

void requestDocumentSetActive(
  1. String entityId
)

Ensures, by any means, that the entity specified by entityId is shown. No checks are performed to verify that entityId points to a valid entity in the VFS.

  1. Checks if any pane contains an instance with this document, creating an instance and assigning it to a pane otherwise
  2. Requests the pane to set that instance as active, using setActiveInstance

Implementation

void requestDocumentSetActive(String entityId) {
  final String instanceToSetActive;
  if (!api.workspace.workspaceConfigs.entitiesLocation
      .containsKey(entityId)) {
    final entity = api.vfs.accessEntity(entityId);
    if (entity != null) {
      final List<String> instanceIds =
          api.workspace.createEditorInstancesForEntities(entities: [entity]);
      instanceToSetActive = instanceIds.first;
    } else {
      throw Exception('Entity ID $entityId is not a valid ID');
    }
  } else {
    instanceToSetActive =
        api.workspace.workspaceConfigs.entitiesLocation[entityId]!.$1;
  }

  api.window.setActiveInstance(
    instanceId: instanceToSetActive,
    paneId: api.workspace.workspaceConfigs.panesData.keys.first,
  );
}