This PR restructures the `ui` crate into just `elements` and
`components`.
This was already done on the `gpui2-ui` branch, just getting it onto
`main`.
Release Notes:
- N/A
---------
Co-authored-by: Nate Butler <nate@zed.dev>
This PR improves the error message when `FontCache.load_family` attempts
to load a font that is not present on the system.
I ran into this while trying to run the `storybook` for the first time.
The error message indicated that a font family was not found, but did
not provide any information as to which font family was being loaded.
### Before
```
Compiling storybook v0.1.0 (/Users/maxdeviant/projects/zed/crates/storybook)
Finished dev [unoptimized + debuginfo] target(s) in 8.52s
Running `/Users/maxdeviant/projects/zed/target/debug/storybook`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: could not find a non-empty font family matching one of the given names', crates/theme/src/theme_settings.rs:132:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
libc++abi: terminating due to uncaught foreign exception
fish: Job 1, 'cargo run' terminated by signal SIGABRT (Abort)
```
### After
```
Compiling storybook v0.1.0 (/Users/maxdeviant/projects/zed/crates/storybook)
Finished dev [unoptimized + debuginfo] target(s) in 7.90s
Running `/Users/maxdeviant/projects/zed/target/debug/storybook`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: could not find a non-empty font family matching one of the given names: `Zed Mono`', crates/theme/src/theme_settings.rs:132:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
libc++abi: terminating due to uncaught foreign exception
fish: Job 1, 'cargo run' terminated by signal SIGABRT (Abort)
```
Release Notes:
- N/A
This PR removes the need for writing manual mappings in the `FromStr`
implementation for the `StorySelector` enum used in the storybook CLI.
We are now using the
[`EnumString`](https://docs.rs/strum/0.25.0/strum/derive.EnumString.html)
trait from `strum` to automatically derive snake_cased names for the
enums.
This will cut down on some of the manual work needed to wire up more
stories to the storybook.
Release Notes:
- N/A
This PR puts the `Theme` returned from the `theme` function behind an
`Arc`.
### Motivation
While working on wiring up window focus events for the `TitleBar`
component we ran into issues where `theme` was holding an immutable
borrow to the `ViewContext` for the entirety of the `render` scope,
which prevented having mutable borrows in the same scope.
### Explanation
To avoid this, we can make `theme` return an `Arc<Theme>` to allow for
cheap clones and avoiding the issues with the borrow checker.
Release Notes:
- N/A
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This PR factors out the bulk of the boilerplate required to setup a
story in the storybook out into separate components.
The pattern we're using here is adapted from the "[associated
component](https://maxdeviant.com/posts/2021/react-associated-components/)"
pattern in React.
Release Notes:
- N/A
Copilot sends multiple events about its LSP server readiness, not necessarily recreating the server from scratch (e.g. due to re-sign in action).
Avoid re-adding same log subscriptions on the same LSP server, which
causes panics.
This PR updates the `storybook` with support for adding stories for
individual components.
### Motivation
Right now we just have one story in the storybook that renders an entire
`WorkspaceElement`.
While iterating on the various UI components, it will be helpful to be
able to create stories of those components just by themselves.
This is especially true for components that have a number of different
states, as we can render the components in all of the various states in
a single layout.
### Explanation
We achieve this by adding a simple CLI to the storybook.
The `storybook` binary now accepts an optional `[STORY]` parameter that
can be used to indicate which story should be loaded. If this parameter
is not provided, it will load the workspace story as it currently does.
Passing a story name will load the corresponding story, if it exists.
For example:
```
cargo run -- elements/avatar
```
<img width="723" alt="Screenshot 2023-09-21 at 10 29 52 PM"
src="https://github.com/zed-industries/zed/assets/1486634/5df489ed-8607-4024-9c19-c5f4541f97c9">
```
cargo run -- components/facepile
```
<img width="785" alt="Screenshot 2023-09-21 at 10 30 07 PM"
src="https://github.com/zed-industries/zed/assets/1486634/e04a4577-7403-405d-b23c-e765b7a06229">
Release Notes:
- N/A
This PR reorganizes the exports for the `ui` module in the `storybook`
crate.
### Motivation
Currently we expose each of the various elements/components/modules in
two places:
- Through the module itself (e.g., `ui::element::Avatar`)
- Through the `ui` module's re-exports (e.g., `ui::Avatar`)
This means it's possible to import any given item from two spots, which
can lead to inconsistencies in the consumers. Additionally, it also
means we're shipping the exact module structure underneath `ui` as part
of the public API.
### Explanation
To avoid this, we can avoid exposing each of the individual modules
underneath `ui::{element, component, module}` and instead export just
the module contents themselves.
This makes the `ui` module namespace flat.
Release Notes:
- N/A
Update project search semantic ui to accommodate for users who have not
set the OPENAI_API_KEY in their environment variables.
Release Notes:
- Expand Semantic Index status to include status for non authenticated
users
- Update Search UI to illustrate this status.
Targeting Preview of 09.27.
This is still pending several touchups/clearups:
- We should watch multibuffer for changes and rescan the excerpts. This
should also update match count.
- Closing editor while multibuffer with 100's of changed files is open
leads to us prompting for save once per each file in the multibuffer.
One could in theory save in multibuffer before closing it (thus avoiding
unnecessary prompts), but it'd be cool to be able to "Save all"/"Discard
All".
Release Notes:
- Added "Replace in project" functionality
These methods were slightly different which caused (for example) there
to be no "Discard" option in the conflict case at the workspace level.
To make this work, a new SaveBehavior (::PromptForNewPath) was added to
support SaveAs.
This mostly adds the commonly requested set (:wq and friends) and
a few that I use frequently
:<line> to go to a line number
:vsp / :sp to create a split
:cn / :cp to go to diagnostics
This PR adds an initial set of components to `crates/storybook/src/ui`.
All changes still are contained to inside storybook. Merging to keep up
to date with main.
Enable keyboard shortcuts for Project Search modes, and ensure project
search settings are persisted search to search.
Release Notes:
- Added alt-cmd-s to Toggle Semantic Search Mode
- Added alt-cmd-g to Toggle Regex Search Mode
- Added alt-cmd-x to Toggle Text Search Mode
- Defaulted new project searches to using last used search mode and
settings.
Copilot is being used in every buffer, but we do not see its logs that
easily.
In the future, prettier wrapper will pretend to be an LSP server, it is
better to log its messages somewhere, so prepare an infrastructure for
that.
<img width="1727" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/d31a257c-9608-46fa-8be1-f0a2a2bdbdb7">
Copilot seem to have no rpc messages logged for some reason now,
prettier wrapper might be a better case to investigate this, so leaving
as is.
Release Notes:
- N/A
This should have no user-visible impact, but tidies up one of the
awkwardnesses
of how vim uses global state at the moment.
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
v0 of the Semantic Index evaluate test suite
Release Notes:
- Added eval.rs as an example to the semantic-index crates
- Generates test metrics for two small projects, as a starting point to
systematically evaluate retrieval quality