ZIm/crates/workspace/src
Kyle Kelley 72d36d0213
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>
2024-03-14 18:01:40 -07:00
..
persistence Fix window restoration bugs (#9358) 2024-03-14 14:25:12 -07:00
dock.rs Center dock resize handle hitboxes (#9225) 2024-03-12 15:42:18 +01:00
item.rs Foundations for Open All the Things (#9353) 2024-03-14 18:01:40 -07:00
modal_layer.rs Occlude only modal and not the space around it used to center it 2024-03-11 18:13:00 +01:00
notifications.rs Expose more errors from rust-analyzer on invalid Cargo.toml contents (#8356) 2024-03-02 10:07:25 +02:00
pane.rs Set the correct dispatch action for the double-click handler for the pane tab bar (#9221) 2024-03-13 17:30:10 +02:00
pane_group.rs Automatically reset cursor style when hit test changes (#9289) 2024-03-13 17:21:25 +01:00
persistence.rs Fix window restoration bugs (#9358) 2024-03-14 14:25:12 -07:00
searchable.rs lsp-log: Reemit Editors search events. 2024-01-22 14:02:48 +01:00
shared_screen.rs Add more open events 2024-01-15 16:26:04 -05:00
status_bar.rs Rename overflow_hidden_{x,y} to overflow_{x,y}_hidden (#4146) 2024-01-18 22:10:41 -05:00
toolbar.rs Editor toolbar configuration (#7338) 2024-02-03 22:40:54 +02:00
workspace.rs Foundations for Open All the Things (#9353) 2024-03-14 18:01:40 -07:00
workspace_settings.rs Display setting documentation in settings.json (#3936) 2024-01-08 19:30:18 +01:00