This adds a "workspace-hack" crate, see
[mozilla's](https://hg.mozilla.org/mozilla-central/file/3a265fdc9f33e5946f0ca0a04af73acd7e6d1a39/build/workspace-hack/Cargo.toml#l7)
for a concise explanation of why this is useful. For us in practice this
means that if I were to run all the tests (`cargo nextest r
--workspace`) and then `cargo r`, all the deps from the previous cargo
command will be reused. Before this PR it would rebuild many deps due to
resolving different sets of features for them. For me this frequently
caused long rebuilds when things "should" already be cached.
To avoid manually maintaining our workspace-hack crate, we will use
[cargo hakari](https://docs.rs/cargo-hakari) to update the build files
when there's a necessary change. I've added a step to CI that checks
whether the workspace-hack crate is up to date, and instructs you to
re-run `script/update-workspace-hack` when it fails.
Finally, to make sure that people can still depend on crates in our
workspace without pulling in all the workspace deps, we use a `[patch]`
section following [hakari's
instructions](https://docs.rs/cargo-hakari/0.9.36/cargo_hakari/patch_directive/index.html)
One possible followup task would be making guppy use our
`rust-toolchain.toml` instead of having to duplicate that list in its
config, I opened an issue for that upstream: guppy-rs/guppy#481.
TODO:
- [x] Fix the extension test failure
- [x] Ensure the dev dependencies aren't being unified by Hakari into
the main dependencies
- [x] Ensure that the remote-server binary continues to not depend on
LibSSL
Release Notes:
- N/A
---------
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This PR adds the ability for icon themes to provide their own file
associations.
The old `file_types.json` that was previously used to make these
associations has been removed in favor of storing them on the default
theme.
Icon themes have two new fields on them:
- `file_stems`: A mapping of file stems to icon keys.
- `file_suffixes`: A mapping of file suffixes to icon keys.
These mappings produce icon keys which can then be used in `file_icons`
to associate them to a particular icon:
```json
{
"file_stems": {
"Makefile": "make"
},
"file_suffixes": {
"idr": "idris"
},
"file_icons": {
"idris": { "path": "./icons/idris.svg" },
"make": { "path": "./icons/make.svg" }
}
}
```
When loading an icon theme, the `file_stems` and `file_icons` fields
will be merged with the ones from the base icon theme, with the values
from the icon theme being loaded overriding ones in the base theme.
Release Notes:
- Added the ability for icon themes to provide their own file
associations.
Follow-up to #24391
The current approach has two issues:
- For the described case of `eslint.config.js`, for which a mapping
exists in `suffixes`, this would get mapped from `eslint.config.js` to
`eslint`. However, for `eslint`, there is no mapping within `suffixes`,
thus currently `get_icon_from_suffix` would return `None` and a wrong
item would be returned at a later step.
- Paths passed to this method are relative to the worktree root, thus
e.g. `eslint.config.js` files in subdirectories would still be assigned
the wrong icon.
---
Behaviour on `main`:
<img width="281" alt="main"
src="https://github.com/user-attachments/assets/19b5e5f8-e413-4ac9-a0a1-2c72f810aa86"
/>
Behaviour with this change:
<img width="299" alt="pr"
src="https://github.com/user-attachments/assets/eec70cbd-df39-49b4-8b07-d22afa949781"
/>
CC @probably-neb
Release Notes:
- N/A
- **fix ignoring ignored files when matching icons**
- **remove poorly named and confusing method
`PathExt.icon_stem_or_suffix` and refactor
`PathExt.extension_or_hidden_file_name` to actually do what it says it
does**
Closes#24314
Release Notes:
- Fixed an issue where hidden files would have the default icon instead
of the correct one
- Fixed an issue where files with specific icons (such as
`eslint.config.js`) would not have the their specific icon without a
leading `.` (`.eslint.config.js`)
There's still a bit more work to do on this, but this PR is compiling
(with warnings) after eliminating the key types. When the tasks below
are complete, this will be the new narrative for GPUI:
- `Entity<T>` - This replaces `View<T>`/`Model<T>`. It represents a unit
of state, and if `T` implements `Render`, then `Entity<T>` implements
`Element`.
- `&mut App` This replaces `AppContext` and represents the app.
- `&mut Context<T>` This replaces `ModelContext` and derefs to `App`. It
is provided by the framework when updating an entity.
- `&mut Window` Broken out of `&mut WindowContext` which no longer
exists. Every method that once took `&mut WindowContext` now takes `&mut
Window, &mut App` and every method that took `&mut ViewContext<T>` now
takes `&mut Window, &mut Context<T>`
Not pictured here are the two other failed attempts. It's been quite a
month!
Tasks:
- [x] Remove `View`, `ViewContext`, `WindowContext` and thread through
`Window`
- [x] [@cole-miller @mikayla-maki] Redraw window when entities change
- [x] [@cole-miller @mikayla-maki] Get examples and Zed running
- [x] [@cole-miller @mikayla-maki] Fix Zed rendering
- [x] [@mikayla-maki] Fix todo! macros and comments
- [x] Fix a bug where the editor would not be redrawn because of view
caching
- [x] remove publicness window.notify() and replace with
`AppContext::notify`
- [x] remove `observe_new_window_models`, replace with
`observe_new_models` with an optional window
- [x] Fix a bug where the project panel would not be redrawn because of
the wrong refresh() call being used
- [x] Fix the tests
- [x] Fix warnings by eliminating `Window` params or using `_`
- [x] Fix conflicts
- [x] Simplify generic code where possible
- [x] Rename types
- [ ] Update docs
### issues post merge
- [x] Issues switching between normal and insert mode
- [x] Assistant re-rendering failure
- [x] Vim test failures
- [x] Mac build issue
Release Notes:
- N/A
---------
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
Co-authored-by: max <max@zed.dev>
Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Mikayla Maki <mikaylamaki@Mikaylas-MacBook-Pro.local>
Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
Co-authored-by: joão <joao@zed.dev>
This PR updates the various `FileIcons` methods to fall back to the
default icon theme if the active icon theme does not have the desired
icon.
Release Notes:
- N/A
This PR pulls the directory and chevron icons out of the
`IconTheme::file_icons` collection and promotes them to named fields.
This makes things less stringly-typed when looking up these icons.
Release Notes:
- N/A
This PR adds the initial concept of an `IconTheme` and refactors
`FileIcons` to use it to resolve the icons.
The `IconTheme` will ultimately be used to allow users to select a
different set of icons to use. Currently, however, this is just laying
the foundation for that work.
The association between file types and icons is now handled by the icon
theme when we resolve file icons. This mapping has been moved out of
`file_types.json` and into `icon_theme.rs`.
Release Notes:
- N/A
When running the tests for linux, I found a lot of benign errors getting
logged. This PR cuts down some of the noise from unnecessary workspace
serialization and SVG renders
Release Notes:
- N/A
This PR restores the `Global` trait's status as a marker trait.
This was the original intent from #7095, when it was added, that had
been lost in #9777.
The purpose of the `Global` trait is to statically convey what types can
and can't be accessed as `Global` state, as well as provide a way of
restricting access to said globals.
For example, in the case of the `ThemeRegistry` we have a private
`GlobalThemeRegistry` that is marked as `Global`:
91b3c24ed3/crates/theme/src/registry.rs (L25-L34)
We're then able to permit reading the `ThemeRegistry` from the
`GlobalThemeRegistry` via a custom getter, while still restricting which
callers are able to mutate the global:
91b3c24ed3/crates/theme/src/registry.rs (L46-L61)
Release Notes:
- N/A
Introducing the Active File Context portion of #9705. When someone is in
the assistant panel it now includes the active file as a system message
on send while showing them a nice little display in the lower right:

For this iteration, I'd love to see the following before we land this:
* [x] Toggle-able context - user should be able to disable sending this
context
* [x] Show nothing if there is no context coming in
* [x] Update token count as we change items
* [x] Listen for a more finely scoped event for when the active item
changes
* [x] Create a global for pulling a file icon based on a path. Zed's
main way to do this is nested within project panel's `FileAssociation`s.
* [x] Get the code fence name for a Language for the system prompt
* [x] Update the token count when the buffer content changes
I'm seeing this PR as the foundation for providing other kinds of
context -- diagnostic summaries, failing tests, additional files, etc.
Release Notes:
- Added file context to assistant chat panel
([#9705](https://github.com/zed-industries/zed/issues/9705)).
<img width="1558" alt="image"
src="https://github.com/zed-industries/zed/assets/836375/86eb7e50-3e28-4754-9c3f-895be588616d">
---------
Co-authored-by: Conrad Irwin <conrad@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>