# Foundations for Open All the Things \(\#9353\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/72d36d02134d9a34e0d46dd3c8375c31c7ebd127)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 72d36d02134d9a34e0d46dd3c8375c31c7ebd127

Requested commit: 72d36d02134d9a34e0d46dd3c8375c31c7ebd127

Commit: 72d36d02134d9a34e0d46dd3c8375c31c7ebd127

Tree: cff705b7d8cf6468f276742dfdd49dfd3779452c

Author: Kyle Kelley

Committer: GitHub

## Message

````
Foundations for Open All the Things (#9353)

This is the beginning of setting up a flexible way to open items beyond
the text buffer -- think notebooks, images, GeoJSON, etc. The primary
requirement to allow opening an arbitrary file is `try_open` on the
`project::Item` trait. Now we can make new `Item`s for other types with
their own ways to render.

Under the hood, `register_project_item` uses this new opening scheme. It
supports a dynamic array of opener functions, that will handle specific
item types. By default, a `Buffer` should be able to be able to open any
file that another opener did not.

A key detail here is that the order of registration matters. The last
item has primacy. Here's an example:

```rust
workspace::register_project_item::<Editor>(cx);
workspace::register_project_item::<Notebook>(cx);
workspace::register_project_item::<ImageViewer>(cx);
```

When a project item (file) is attempted to be opened, it's first tried
with the `ImageViewer`, followed by the `Notebook`, then the `Editor`.

The tests are set up in a way that should make it _hopefully_ easy to
learn how to write a new opener. First to go after should probably be
image files.

Release Notes:

N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
````

## Parents

- [f9b91236062cc0c06f5d07943cc566df1ea99862](https://git.cafe/gitcafe/zed/commit/f9b91236062cc0c06f5d07943cc566df1ea99862?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/72d36d02134d9a34e0d46dd3c8375c31c7ebd127?format=markdown)
