Compare commits

..

353 Commits

Author SHA1 Message Date
Julia
b420aea6bb Avoid scrolling when clicking near editor top/bottom
Also makes go-to navigation autoscroll guarantee some amount of
margin regardless of user cursor scroll margin
2024-03-14 16:54:20 -04:00
Julia
88e33a1dbe Account for all hover heights & prevent un-hover between popovers (#9257)
Fixes https://github.com/zed-industries/zed/issues/5227
Fixes https://github.com/zed-industries/zed/issues/7304

Release Notes:

- Fixed an issue where not all editor hover popovers would be accounted
for when choosing to hover above or below the mouse cursor
([#5227](https://github.com/zed-industries/zed/issues/5227)).
- Fixed an issue where editor hover could be dismissed by moving the
mouse between hover popovers
([#7304](https://github.com/zed-industries/zed/issues/7304)).

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
2024-03-13 12:55:15 -04:00
Antonio Scandurra
139bb3275a Automatically reset cursor style when hit test changes (#9289)
Release Notes:

- N/A

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2024-03-13 17:21:25 +01:00
Joseph T. Lyons
7f0e373358 v0.128.x dev 2024-03-13 11:57:44 -04:00
Igal Tabachnik
6286d86262 Set the correct dispatch action for the double-click handler for the pane tab bar (#9221)
Fixes #9003

Release Notes:

- Fixed the double-click action on the terminal tab bar opening a new
buffer instead of a new terminal
([#9003](https://github.com/zed-industries/zed/issues/9003)).
2024-03-13 17:30:10 +02:00
Antonio Scandurra
fc9f84446a Always stop propagation in div's scroll wheel listener (#9282)
Fixes #9274

This fixes a bug that was preventing the editor hover popovers from
being scrolled with the trackpad.

Release Notes:

- N/A
2024-03-13 15:48:22 +01:00
Kirill Bulatov
109482761b Omit .git worktree indexing (#9281)
Closes https://github.com/zed-industries/zed/issues/9174

Release Notes:

- Fixed panics when `.git` was opened as a Zed worktree
([9174](https://github.com/zed-industries/zed/issues/9174))
2024-03-13 16:35:44 +02:00
Kirill Bulatov
572ba3f93b Fall back to FindAllReferences if cmd-click did not preform GoToDefinition elsewhere (#9243) 2024-03-13 13:00:04 +02:00
Piotr Osiewicz
427d66990c gpui: Do not emit MouseUpEvent when exiting drag & drop (#9273)
Fixes #9198

Release Notes:

- Fixed a bug where empty panes could be created during drag & drop.
2024-03-13 11:37:34 +01:00
Thorsten Ball
ac4bbb6135 Correctly re-render mouse cursor when hovering over pane group divider (#9270)
Before this change, the hitbox felt one-sided because the cursor didn't
consistently change into the drag-handle cursor.

The reason was that we didn't trigger a redraw on hover, so we'd only
change the cursor if we detected hover AND something else caused a
redraw.

Release Notes:

- Fixed the pane resize handler not consistently triggering on mouse
hover.

Co-authored-by: Antonio <antonio@zed.dev>
2024-03-13 10:57:10 +01:00
Thorsten Ball
754df9356d Fix segfault when dropping MacWindow (#9267)
This avoids calling `window.setDelegate(nil)` when the window was
already closed.

Release Notes:

- Fixed a segfault that could show up when closing windows.

Co-authored-by: Antonio <antonio@zed.dev>
2024-03-13 10:41:25 +01:00
Thorsten Ball
3c28282108 Redraw when toggling between windows (#9236)
Before this change we didn't consistently trigger focus events when
toggling between with windows `Cmd-backtick`. We only triggered them
when the OS decided to trigger a redraw.

That lead to a nasty bug that showed up in Vim mode where a cursor would
still be active in the hidden window, even though it was deactivated.

One then had to manually try to trigger a focus event in the new window
to activate the cursor.

With this change, we call `cx.refresh` when the window activation status
changed which triggers focus events consistently and fixes this bug.

With logging we can observe this:

**BEFORE**:


https://github.com/zed-industries/zed/assets/1185253/e1ad8878-129c-44ba-9d8b-c720f9dca5b6


**AFTER**:


https://github.com/zed-industries/zed/assets/1185253/733fdadb-d1ea-47fe-a2c1-7b50af299cc0


Release Notes:

- Fixed focus not being consistently changed when switching between
multiple Zed windows via `Cmd-backtick`.

---------

Co-authored-by: Manu Raj <git@manuraj.dev>
Co-authored-by: Antonio <antonio@zed.dev>
2024-03-13 10:15:22 +01:00
Rajesh Malviya
80b80dfa78 gpui: Switch to x11rb (#9113)
Switch to using `x11rb` crate instead of current `xcb` crate for gpui's
x11 platform.

Also fixes the crash on resize, and white flashing on resize.

Release Notes:

- N/A

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-12 21:47:08 -07:00
Joseph T. Lyons
47afc70979 Update Lua config.toml (#9260)
Release Notes:

- Added autoclosing of `(` and `'` in Lua.
2024-03-13 00:32:45 -04:00
Conrad Irwin
646f69583a Allow opening non-extant files (#9256)
Fixes #7400



Release Notes:

- Improved the `zed` command to not create files until you save them in
the editor ([#7400](https://github.com/zed-industries/zed/issues/7400)).
2024-03-12 22:30:04 -06:00
Mikayla Maki
e792c1a5c5 Open new windows with a default size and position (#9204)
This PR changes GPUI to open windows with a default size and location,
and to otherwise inherit from their spawning window.

Note: The linux build now crashes on startup.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Ezekiel Warren <zaucy@users.noreply.github.com>
2024-03-12 21:19:51 -07:00
张小白
9a2dceeea1 windows: Support dropping targets with filenames longer than 260 characters (#9115)
use `Vec` instead of slice to support dynamic filename length.

Release Notes:
- N/A
2024-03-12 21:19:31 -07:00
Bennet Bo Fenner
fb83cf2042 notification panel: rework time formatting (#8997)
Follow up of #7994 to rework the notification panel timestamps.
This PR also includes some of the changes @evrsen proposed in #8996 
Here is what it looks like now:


https://github.com/zed-industries/zed/assets/53836821/d85450e7-eab6-4fe7-bd11-1d76c0e87258

Release Notes:
- Reworked date time formatting in the chat and the notification panel
- Added hover style to notifications and hovering tooltip on timestamps

---------

Co-authored-by: Evren Sen <146845123+evrsen@users.noreply.github.com>
2024-03-12 21:02:04 -06:00
bbb651
a105b5f215 Wayland: Remove bogus wl_surface::commits on resize (with integer scaling) (#9245)
Release Notes:
- N/A

This prevents a crash on sway (on older versions without fractional
scaling). This means the resize is delayed until the next this we
present a frame, we need to investigate if this is the correct this to
do.
2024-03-12 19:46:18 -07:00
Piotr Osiewicz
aeb2a98058 chore: Move new util deps to workspace level (#9250)
I've missed a comment from @maxdeviant on #9247 before hitting merge;
mea culpa

Release Notes:

- N/A
2024-03-13 00:37:10 +01:00
Piotr Osiewicz
34f09bae4f chore: Clean up util dependencies. (#9247)
This allows this crate to start building sooner + it reduces our total
build graph size by 13 units (1104 -> 1091).

Release Notes:

- N.A
2024-03-13 00:10:49 +01:00
Kirill Bulatov
c09fe1ce8a Do not allow concurrent FindAllReferences requests for the same multibuffer anchors (#9242)
FindAllReferences LSP requests might take a long time to complete, and
currently Zed allows multiple requests spawned concurrently for the same
Anchor in the multi buffer. That results in multiple search results'
multi buffers appearing, sometimes at once, which is not what we want.

Part of https://github.com/zed-industries/zed/issues/5351 that helps to
reduce the amount of search results after clicks that did not resolve
instantly.


Release Notes:

- Improved FindAllReferences action by not allowing concurrent requests
for the same multi buffer source
2024-03-12 23:02:34 +02:00
Max Brunsfeld
64219ba49f When fetching extensions from blob store, don't halt on invalid extensions. (#9241)
This fixes an error where we were failing to sync extensions from the
blob store because of the presence of one invalid extensions
(`gentle-dark`), which was missing the `authors` field in its manifest.

Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-12 16:36:40 -04:00
Conrad Irwin
05dfe96f0c Add --add/--new to control CLI behaviour (#9202)
When neither is specified, if you open a directory you get a new
workspace, otherwise files are added to your existing workspace.

With --new files are always opened in a new workspace
With --add directories are always added to an existing workspace

Fixes #9076
Fixes #4861
Fixes #5370

Release Notes:

- Added `-n/--new` and `-a/--add` to the zed CLI. When neither is
specified, if you open a directory you get a new workspace, otherwise
files are added to your existing workspace. With `--new` files are
always opened in a new workspace, with `--add` directories are always
added to an existing workspace.
([#9076](https://github.com/zed-industries/zed/issues/9096),
[#4861](https://github.com/zed-industries/zed/issues/4861),
[#5370](https://github.com/zed-industries/zed/issues/5370)).
2024-03-12 14:27:58 -06:00
Marshall Bowers
89c67fb1ab Fix typos in default settings.json (#9239)
This PR fixes some typos in the comments within the default
`settings.json` file.

Fixes #4257.

Release Notes:

- Fixed some incorrect comments in the default `settings.json` file
([#4257](https://github.com/zed-industries/zed/issues/4257)).
2024-03-12 15:30:52 -04:00
dalton-oliveira
41d8ba12ec Remove wezterm fork from dependencie (#8998)
Improves build time by removing wezterm dependency
([#8604](https://github.com/zed-industries/zed/issues/8604)).

Release Notes:

- N/A
2024-03-12 21:27:40 +02:00
Antonio Scandurra
e7289c385d Correctly show the shift icon for keybindings on macOS (#9235)
Release Notes:

- N/A

Co-authored-by: Nathan <nathan@zed.dev>
2024-03-12 18:27:24 +01:00
Kainoa Kanter
ece0fb532d Rosé Pine: Change #f5c177 to #f6c177 (#9232)
As discussed in #themes-and-ui

Release Notes:

- N/A
2024-03-12 09:35:34 -07:00
Thorsten Ball
8c87b349dc Show formatting failure (#9229)
This fixes #8072 and #9061 by surfacing formatting errors in the
activity indicator.

It shows a message in the activity indicator if the last attempt
to format a buffer failed.

It only keeps track of the last attempt, so any further formatting
that succeeds will reset or update the error message.

I chose to only keep track of that, because everything else (keeping
track of formatting state per buffer, per project, per worktree) seems
complicated with little benefit, since we'd have to keep track of that
state, update it, clean it, etc.

We can still do that should we decide that we need to keep track
of the state on a per-buffer basis, but I think for now this is a
good, simple solution.

This also changes the `OpenLog` action to scroll to the end of the
buffer
and to not mark the buffer as dirty.


Release Notes:

- Added message to activity indicator if last attempt to format a buffer
failed. Message will get reset when next formatting succeeds. Clicking
on message opens log with more information.
([#8072](https://github.com/zed-industries/zed/issues/8072) and
[#9061](https://github.com/zed-industries/zed/issues/9061)).
- Changed `zed: Open Log` action to not mark the opened log file as
dirty and to always scroll to the bottom of the log.


https://github.com/zed-industries/zed/assets/1185253/951fb9ac-8b8b-483a-a46d-712e52878a4d
2024-03-12 16:30:08 +01:00
Antonio Scandurra
39a0841ea8 Center dock resize handle hitboxes (#9225)
Also, add a `deferred` function which takes an element to paint after
the current element tree.

Release Notes:

- Improved the size and position of the hitbox for resizing left, right,
and bottom panels.
([#8855](https://github.com/zed-industries/zed/issues/8855))

Co-authored-by: Julia <julia@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
2024-03-12 15:42:18 +01:00
Antonio Scandurra
409aa513d4 Fix mouse interactions with the project and branch switchers (#9222)
Previously, we were considering the mouse to be "out" of a div when its
hitbox wasn't hovered. However, if a parent listened for
"mouse_down_out" and a child occluded the parent, the parent would
always think the mouse was out even when the user clicked the child.

This commit changes the definition of "mouse out" to simply mean "does
not contain the point", without accounting for occlusion.

Release Notes:

- N/A

Co-authored-by: Julia <julia@zed.dev>
2024-03-12 15:30:27 +01:00
Antonio Scandurra
d5796dc5eb Show only prefix/suffix if there are more than 12 breadcrumbs (#9220)
Fixes https://github.com/zed-industries/zed/issues/9079

This should fix the arena panic we were observing. I saw that breadcrumb
rendering was on the stack trace for some of the panics, so my suspicion
is that it's being caused by some people navigating into deeply nested
files.

Release Notes:

- Fixed a panic that could occur when displaying too many breadcrumbs.
([#9079](https://github.com/zed-industries/zed/issues/9079))
2024-03-12 14:33:12 +01:00
Thorsten Ball
9f396948bb Improve error messages when fetching single GitHub release (#9219)
Release Notes:

- N/A
2024-03-12 14:12:44 +01:00
Piotr Osiewicz
e103607134 copilot: Track focus of modal + close modal on ESC (#9217)
I've also made Copilot's modal regain focus whenever you click on it, as
otherwise there's nothing inside of it that can gain focus. Clicks do
not fall through a modal, which I think is nice.



Release Notes:

- Fixed the issue where pressing ESC (`menu::Cancel`) did not exit the
Copilot modal. Fixes #8852
2024-03-12 13:08:55 +01:00
Antonio Scandurra
0a341261d0 Insert hitbox when an interactive element can be scrolled (#9216)
Fixes https://github.com/zed-industries/zed/issues/9199


Release Notes:

- N/A
2024-03-12 12:24:15 +01:00
Bennet Bo Fenner
d362588055 markdown preview: highlight code blocks (#9087)
![image](https://github.com/zed-industries/zed/assets/53836821/e20acd87-9680-4e1c-818d-7ae900bf0e31)

Release Notes:

- Added syntax highlighting to code blocks in markdown preview
- Fixed scroll position in markdown preview when editing a markdown file
(#9208)
2024-03-12 12:54:12 +02:00
Remco Smits
e5bd9f184b Fix prettier plugins does not seem to be picked up (#9193)
This fixed the issue that prettier plugins were not picked up. The old
code would always send an empty array to the prettier plugin that
happens inside the `prettier_server.js`.

**Before**
The `options.plugins` key is an empty array, which is not correct.
```log
stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":[],"parser":"typescript","path":"/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx"}
```


https://github.com/zed-industries/zed/assets/62463826/52f2aad0-2f96-43a9-81ec-9d4630c495b2

**After**
The `options.plugins` contains the `prettier-plugin-organize-imports`
plugin as expected.
```log
stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"],"parser":"typescript","path":"/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx"}
```


https://github.com/zed-industries/zed/assets/62463826/9045028d-aeca-4df1-819c-01905d83216c


Release Notes:
- Fixed send plugins correctly to the prettier plugin
([#8841](https://github.com/zed-industries/zed/issues/8841)).
2024-03-12 11:38:30 +01:00
Thorsten Ball
98cf494057 Fix broken ESLint by pinning to 2.2.20-Insiders release (#9215)
This fixes #9213 by pinning ESLint to `2.2.20-Insiders` which is the
last known version to work well with Zed.

Once this fix is out, we can take a closer look at upgrading to 2.4.x or
even 3.x once that's out of prerelease.

Release Notes:

- Fixed ESLint integration being broken after Mar 7 2024 due to ESLint
3.0.1 alpha release being pushed.
([#9213](https://github.com/zed-industries/zed/issues/9213)).
2024-03-12 11:20:25 +01:00
Kirill Bulatov
3be1402a3d Fix the double click and update the default settings (#9214) 2024-03-12 12:15:55 +02:00
Ivan Žužak
44adb0a316 Detect URLs at beginning and end of buffer as well (#9212)
Release Notes:

- Fixed URL detection at very beginning and very end of buffer
([#9210](https://github.com/zed-industries/zed/issues/9210)).

| Before | After |
| ------ | ----- |
| ![Screenshot 2024-03-12 at 07 09
52](https://github.com/zed-industries/zed/assets/38924/5c0beb28-f63b-4455-a5cd-31cec2d9a775)
| ![Screenshot 2024-03-12 at 07 11
03](https://github.com/zed-industries/zed/assets/38924/116f76a2-21e8-4c77-ac6e-a4e3c594b09d)
|
2024-03-12 07:59:32 +01:00
Marshall Bowers
14a0d8039b ui: Center Checkbox within its container (#9201)
This PR fixes an issue with the `Checkbox` component where the checkbox
wasn't being centered within its container element.

The problem can be seen when applying a background color to the
container element:

#### Before

<img width="439" alt="Screenshot 2024-03-11 at 5 44 10 PM"
src="https://github.com/zed-industries/zed/assets/1486634/11704b1a-3c3e-4250-99c3-973fb442287a">

#### After

<img width="447" alt="Screenshot 2024-03-11 at 5 45 59 PM"
src="https://github.com/zed-industries/zed/assets/1486634/569a850b-4bd7-4711-8327-bf426fa5d265">

This resulted in issues where, under certain conditions, the checkbox
could get cut off, as seen in #8868.

Centering the checkbox fixes this issue:

<img width="305" alt="Screenshot 2024-03-11 at 5 51 00 PM"
src="https://github.com/zed-industries/zed/assets/1486634/14e5642f-59ad-4288-bc25-ea7da2a008a7">

Fixes #8868.

Release Notes:

- Fixed a positioning issue with checkboxes
([#8868](https://github.com/zed-industries/zed/issues/8868)).
2024-03-11 18:08:31 -04:00
Marshall Bowers
c0b1f74794 Inset ContextMenu headers (#9197)
This PR insets the headers within `ContextMenu`s to give them some more
breathing room.

#### Before

<img width="347" alt="Screenshot 2024-03-11 at 4 13 31 PM"
src="https://github.com/zed-industries/zed/assets/1486634/73a56d68-d40e-4396-b584-f443197b69d6">

#### After

<img width="354" alt="Screenshot 2024-03-11 at 4 12 43 PM"
src="https://github.com/zed-industries/zed/assets/1486634/44c12a07-0784-4c94-b194-245f5cf94b2b">

Release Notes:

- Added padding to headers in context menus.
2024-03-11 16:28:16 -04:00
Kirill Bulatov
02dcdd0228 Open excerpt on double click in multibuffer by default. (#9196)
Closes https://github.com/zed-industries/zed/issues/5275

Double click with `alt` modifier pressed will do the regular word
selection.

Adds a setting to disable this behavior and instead select a word, as in
the regular buffer.

```
// What to do when multibuffer is double clicked in some of its excerpts
// (parts of singleton buffers).
// May take 2 values:
//  1. Behave as a regular buffer and select the whole word.
//         "double_click_in_multibuffer": "select"
//  2. Open the excerpt clicked as a new buffer in the new tab (default).
//         "double_click_in_multibuffer": "open",
// For the case of "open", regular selection behavior can be achieved by holding `alt` when double clicking.
"double_click_in_multibuffer": "open",
```


Release Notes:

- Made multibuffer to open excerpts in new tabs on double click by
default (changing settings or keeping alt restores the word selection
behavior). ([5275](https://github.com/zed-industries/zed/issues/5275))
2024-03-11 22:06:06 +02:00
Marshall Bowers
25c471f9e4 Render + separators for keybindings on non-macOS platforms (#9194)
This PR adjusts the rendering of keybindings on non-macOS platforms to
have a `+` separator instead of just a blank space.

<img width="952" alt="Screenshot 2024-03-11 at 3 18 17 PM"
src="https://github.com/zed-industries/zed/assets/1486634/1573823d-4329-41f0-bef4-7a6c09f3e632">

<img width="584" alt="Screenshot 2024-03-11 at 3 16 25 PM"
src="https://github.com/zed-industries/zed/assets/1486634/aae41b22-dfde-40a6-9e0e-cee855522d3a">

Release Notes:

- N/A
2024-03-11 15:57:31 -04:00
Thorsten Ball
fe70a2646f Fix relative glob patterns not working for language servers (#9179)
If a language server would send us a glob pattern like `**/*.rb` or
`**/{package.json}` we'd end up ignoring it and never sending the
language server any notifications, because we try to `strip_prefix` the
projects absolute path from the pattern, BUT if that path is not in the
pattern, we'd return `None`.

This change fixes that.

Release Notes:

- Fixed language server glob patterns for file watching being ignored if
they were relative patterns.

Co-authored-by: Bennet <bennetbo@gmx.de>
Co-authored-by: Remco <djsmits12@gmail.com>
2024-03-11 20:39:07 +01:00
Thorsten Ball
b2981f4baa Fix completion-filtering by checking actual word boundaries & reduce Ruby word chars (#9170)
This fixes https://github.com/zed-industries/zed/issues/9069 by

1. reverting https://github.com/zed-industries/zed/issues/7819 
2. fixing completion filtering with regards to word boudaries

For (2) see explanation in commit message:

> Previously, this would only split words on upper-lower boundaries or
> on `_`/`-`.
> 
> The result was that we would filter out completions too aggressively.
> The filter works by taking a suggested completion, say `foo_bar_lol`,
split
> it up into words - `foo`, `bar, `lol` - and check whether any of the
words
> start with the same characters as what the user already typed: `fo`,
or `bar`,
> ...
> 
> In the case of Ruby, though, `:` wasn't considered a word boundary. If
the
> LSP would return `:foobar` when the user typed `:foo`, we'd check if
there are
> any completions that match `foo` (because that's the current word) but
> we'd compare against `foobar`, not `:` or `:foobar`.
> 
> With this change, we get more match candidates and thus more
completions in Ruby.

With that we can do (1) because we don't need these characters as word
characters anymore to trigger completions.

Release Notes:

- Fixed word boundaries in Ruby by restoring old behavior (`@`, `:`, ...
are no longer considered word characters)
([#9069](https://github.com/zed-industries/zed/issues/9069))
- Fixed completions being filtered out when they happened at word
boundaries on special characters (e.g. `:`)

---------

Co-authored-by: Max <max@zed.dev>
2024-03-11 20:38:37 +01:00
Marshall Bowers
f2aa183512 ui: Extend KeyBinding with support for displaying keybindings for other platforms (#9192)
This PR extends the `KeyBinding` component with support for displaying
keybindings for platforms other than macOS.

<img width="824" alt="Screenshot 2024-03-11 at 2 41 59 PM"
src="https://github.com/zed-industries/zed/assets/1486634/7108b17d-dfc3-42ee-9bfd-c58b334d7374">

Release Notes:

- N/A
2024-03-11 15:03:55 -04:00
Max Brunsfeld
dfcc143ead Rename 'project_core' crate to 'worktree', make it just about worktrees (#9189)
This is just a refactor. I noticed that we now have a `project_core`
crate, which mainly contains the `Worktree` type and its private
helpers, plus the project's settings.

In this PR, I've renamed that crate to `worktree` and did some minor
simplification to its module structure. I also extracted a new
`WorktreeSettings` settings type from the `ProjectSettings`, so that the
worktree settings could live in the worktree crate. This way, the crate
is now exclusively about worktree logic.

Release Notes:

- N/A
2024-03-11 11:35:27 -07:00
Antonio Scandurra
2b67bb27cf Occlude only modal and not the space around it used to center it 2024-03-11 18:13:00 +01:00
Antonio Scandurra
91a0923fc4 Fix a few regressions related to the flicker fix (#9190)
This pull request fixes
https://github.com/zed-industries/zed/issues/9187 and fixes also ix a
rendering problem that would show cursors on the same plane:


![image](https://github.com/zed-industries/zed/assets/482957/208304a4-286a-4fd9-a3d8-e2913e3a3dc7)


Release Notes:

- N/A
2024-03-11 18:07:26 +01:00
Ivan Žužak
b4ddc83e85 Allow overriding font style and weight via experimental.theme_overrides in settings (#9122)
Release Notes:

- Added support for overriding the current theme's syntax font styles
and weights in settings
([#9121](https://github.com/zed-industries/zed/issues/9121)).

| Before | After |
| ------ | ----- |
| ![Screenshot 2024-03-09 at 22 20
01@2x](https://github.com/zed-industries/zed/assets/38924/c693468d-1e04-45b4-b7c0-869e2a22a44c)
| ![Screenshot 2024-03-09 at 22 21
09@2x](https://github.com/zed-industries/zed/assets/38924/d8b09676-dd8b-46ac-8e9d-6cf2094a9c7e)
|
2024-03-11 12:21:37 -04:00
Vitor Ramos
3bd9d14420 linux: Fix panic missing screen mode for crtc specified mode ID (#9106)
Fix panic caused by missing screen mode for specified crtc mode id #9105
by searching over all crtcs instead of using the first one which may be
invalid.
2024-03-11 09:04:05 -07:00
charles-r-earp
95b311cb90 linux: gpui add Keysym::ISO_Left_Tab (#9126)
Fixes #9089.

On linux, pressing shift and tab together can potentially produce
`ISO_Left_Tab`. This PR maps this key to "tab" with the shift modifier,
similar to `SHIFT_TAB_KEY` in gpui::platform::mac::events.

Note: The [default linux
keymaps](https://github.com/zed-industries/zed/blob/main/assets/keymaps/default-linux.json)
have shift-tab mapped to editor::TabPrev and ctrl-[ mapped to
editor::Outdent. Both actions appear to have the same effect.

Release Notes:

- Support shift-tab on linux (#9089).
2024-03-11 09:03:15 -07:00
Antonio Scandurra
8eea281288 Show modals on top of zoomed pane (#9183)
Release Notes:

- N/A
2024-03-11 16:57:17 +01:00
Kirill Bulatov
373a4e7614 Properly display deleted diff hunks (#9182)
Follow-up of https://github.com/zed-industries/zed/pull/9068 

Release Notes:

- Fixed removal diff hunks not being displayed properly in the editor
2024-03-11 17:53:45 +02:00
Piotr Osiewicz
f9f9f0670f editor: Rearrange float operations in layout (#9176)
We were seeing weird layouts with large files, where - starting with
some verylargelineindex - lines were rendered at weird y offsets. It
turned out that in some cases we're doing operations on Pixel values of
different magnitude, which then led to wrong results in calculations.
This commit addresses some of these problems, visible at glance when
working with large plaintext files. I *did not* dig into things like
inlay hints or diagnostics to see if they are subject to the same
potential precision loss.

Fixes #5371 

Release Notes:

- Fixed editor layout for large files, where the lines might have been
laid out with incorrect Y offset from the top.
2024-03-11 16:46:20 +01:00
Joel Selvaraj
20d5f5e8da linux: wayland cursor fixes (#9047)
Release Notes:

- Fixed wayland cursor style handling


In upcoming Gnome 46, cursor icon names are considerably changing. For
example: this commit
74e9b79471
removed/modified a lot of cursor names. Then some of the names were
reintroduced in this commit
6f64dc55dc.
I also tried upcoming KDE Plasma 6. Some of the cursor names are not
used commonly between Gnome and KDE. From my analysis, these set of
cursor names should be more widely available in both previous and
upcoming release of Gnome and KDE.

Also, If a cursor style is not available, let's fallback to default
cursor style. This avoids scenarios where we get stuck with special
cursor styles like IBeam/Resize* because the current cursor style is not
available. This will lead to an unpleasant/broken experience. Falling
back to default cursor seems to be more acceptable.
2024-03-11 08:38:52 -07:00
Thorsten Ball
f066dd268f Fix race when language server registers for workspace/didChangeWatchedFiles (#9177)
This fixes #8896 by storing the `watched_paths` in a separate HashMap,
allowing us to handle the request even before we mark the language
server as running.

Downside is that we have yet another data structure for language
servers, but it also makes the `Running` enum case a bit smaller.

And it fixes the race condition.

Release Notes:

- Fixed language servers not being notified of file changes if language
server registers for file-notification right after starting up.
([#8896](https://github.com/zed-industries/zed/issues/8896)).

Co-authored-by: Bennet <bennetbo@gmx.de>
Co-authored-by: Remco <djsmits12@gmail.com>
2024-03-11 16:30:30 +01:00
Mart Zielman
0be20d0817 fix: vulkan dependencies in script/linux (#9116)
Just a quick pull request and a small fix, someone reported a dependency
was erroring for him, so I decided to open a small pull request. On top
of that, any `devel` header is not needed because Vulkan is only a
runtime dependency.

Release Notes:

- Fixed names of Vulkan dependencies that didn't exist
2024-03-11 08:29:06 -07:00
白山風露
a04932c4eb Windows: fix crash with unhandled window (#9164)
On Windows, some windows may be created that are not managed by the
application.
For example, the Japanese IME creates pop-ups like this one.

<img width="325" alt="image"
src="https://github.com/zed-industries/zed/assets/6465609/503aaa0a-7568-485a-a138-e689ae67001c">

The internal data associated with such a window is different from
`WindowsWindowInner` and will crash if referenced.
Therefore, before calling `try_get_window_inner`, it checks if it is an
owned window.


Release Notes:

- N/A
2024-03-11 08:28:18 -07:00
Antonio Scandurra
ceadb39c38 Prevent text from wrapping in code actions menu (#9178)
Right now we're basing the width of the menu on the longest code action
title. That is only an approximation and doesn't always coincide
perfectly with the true, longest code action.

Given that it's pretty close, however, this commit simply disables text
wrapping on the code action menu.

Release Notes:

- Fixed a rendering glitch that could cause code actions to not display
correctly ([#8341](https://github.com/zed-industries/zed/issues/8341))
2024-03-11 16:25:17 +01:00
白山風露
2244419dfd Add missed pad (#9175)
Sorry I missed explicitly `Quad::pad` insertion at #9172.

The struct layout is unchanged and does not affect the behavior.

Release Notes:

- N/A
2024-03-11 08:21:52 -07:00
Bennet Bo Fenner
a8fa1f7363 chat: fix emoji completions when word consists of emojis (#9107)
https://github.com/zed-industries/zed/assets/53836821/f4b31c47-d306-43f5-b971-0969f64a48f9

Fix for #9096 @JosephTLyons 

Release Notes:
- Fixed emoji completion not showing up when word contains only emojis
(#9096)
2024-03-11 09:08:18 -06:00
白山風露
eb5e18c66d Fix blade validation failure (#9172)
Fix: #9167

Release Notes:

- N/A
2024-03-11 08:06:20 -07:00
Antonio Scandurra
830e107921 Hide hover popover when mouse hovers over negative space (#9173)
Fixes https://github.com/zed-industries/zed/issues/8340

Release Notes:

- Fixed a bug that would cause hover information to not be dismissed
when hovering over negative space.
2024-03-11 15:29:44 +01:00
Piotr Osiewicz
45c4d35da8 rope: Preallocate chunks buffer
This commit also specializes 'fn push' for large text quantities. That specialized version uses a Vec instead of SmallVec.
This commit shaves off about ~100ms out of 800ms when loading a 600Mb text buffer.
2024-03-11 13:28:10 +01:00
Antonio Scandurra
298314d526 Fix regressions introduced by flicker fix (#9162)
This pull request fixes a couple of easy regressions we discovered right
after using #9012 on nightly:

- Popover buttons for a chat message were being occluded by the message
itself.
- Scrolling was not working on the `List` element.

Release Notes:

- N/A
2024-03-11 12:11:51 +01:00
Kirill Bulatov
2f6c78b0c0 Fix incorrect outline selections after submit (#9160)
Follow-up of https://github.com/zed-industries/zed/pull/9153

Release Notes:

- N/A
2024-03-11 12:07:42 +02:00
Antonio Scandurra
4700d33728 Fix flickering (#9012)
See https://zed.dev/channel/gpui-536

Fixes https://github.com/zed-industries/zed/issues/9010
Fixes https://github.com/zed-industries/zed/issues/8883
Fixes https://github.com/zed-industries/zed/issues/8640
Fixes https://github.com/zed-industries/zed/issues/8598
Fixes https://github.com/zed-industries/zed/issues/8579
Fixes https://github.com/zed-industries/zed/issues/8363
Fixes https://github.com/zed-industries/zed/issues/8207


### Problem

After transitioning Zed to GPUI 2, we started noticing that interacting
with the mouse on many UI elements would lead to a pretty annoying
flicker. The main issue with the old approach was that hover state was
calculated based on the previous frame. That is, when computing whether
a given element was hovered in the current frame, we would use
information about the same element in the previous frame.

However, inspecting the previous frame tells us very little about what
should be hovered in the current frame, as elements in the current frame
may have changed significantly.

### Solution

This pull request's main contribution is the introduction of a new
`after_layout` phase when redrawing the window. The key idea is that
we'll give every element a chance to register a hitbox (see
`ElementContext::insert_hitbox`) before painting anything. Then, during
the `paint` phase, elements can determine whether they're the topmost
and draw their hover state accordingly.

We are also removing the ability to give an arbitrary z-index to
elements. Instead, we will follow the much simpler painter's algorithm.
That is, an element that gets painted after will be drawn on top of an
element that got painted earlier. Elements can still escape their
current "stacking context" by using the new `ElementContext::defer_draw`
method (see `Overlay` for an example). Elements drawn using this method
will still be logically considered as being children of their original
parent (for keybinding, focus and cache invalidation purposes) but their
layout and paint passes will be deferred until the currently-drawn
element is done.

With these changes we also reworked geometry batching within the
`Scene`. The new approach uses an AABB tree to determine geometry
occlusion, which allows the GPU to render non-overlapping geometry in
parallel.

### Performance

Performance is slightly better than on `main` even though this new
approach is more correct and we're maintaining an extra data structure
(the AABB tree).


![before_after](https://github.com/zed-industries/zed/assets/482957/c8120b07-1dbd-4776-834a-d040e569a71e)

Release Notes:

- Fixed a bug that was causing popovers to flicker.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Thorsten <thorsten@zed.dev>
2024-03-11 10:45:57 +01:00
Thorsten Ball
9afd78b35e Add ESLint information to JavaScript docs (#9158)
Release Notes:

- N/A
2024-03-11 10:30:25 +01:00
Yanguk
9ff3cff6f8 Respect eslint.nodePath setting (#9073)
I'm using Yarn Plug'n'Play.
In this case, by default, eslint cannot find the path, so configuration
like `"eslint.nodePath": ".yarn/sdks"` is required.
So, I want to add this!

Release Notes:

- Added eslint config nodePath
2024-03-11 10:15:06 +01:00
Kainoa Kanter
d66f8f99bd docs: Move Linux tracking issue (#9130)
Release Notes:

- N/A
2024-03-11 10:08:14 +02:00
Hans
269848775c Fix Vim code formating (#9098)
- N/A
2024-03-11 10:03:51 +02:00
Andrew
39bd12a557 gpui: add set menus example (#9131)
Add an example showing how to add a menu item, register an action with
the `AppContext`, and successfully call the action.

Release Notes:

- N/A
2024-03-11 09:56:45 +02:00
Max
e1f8a1e8b2 Fix <!DOCTYPE html> syntax highlighting (#9108)
Release Notes:

- Added `<!DOCTYPE html>` syntax highlighting ([4318](https://github.com/zed-industries/zed/issues/4318))
2024-03-11 09:56:35 +02:00
Kirill Bulatov
41dc5fc412 Allow highlighting editor rows from multiple sources concurrently (#9153) 2024-03-11 02:17:32 +02:00
Thorsten Ball
f4a86e6fea Always single-quote directory when cd'ing to get shell env (#9145)
This avoids us potentially executing code (if someone were to name their
directory `$(echo you-are-pwned > /secure-files)`, for example).

Works with zsh, bash, fish, nushell. Tested locally with all of them.

Release Notes:

- N/A
2024-03-10 13:53:24 +01:00
Kirill Bulatov
597465b0f5 Slightly simplify editor highlights code (#9123)
Prepare for git diff hunk highlights by grouping all inlay highlight
properties into one struct, and removing the dead background highlight
code.


Release Notes:

- N/A
2024-03-10 00:38:45 +02:00
Max
ccc939124f Remove obsolete separator (#9117) 2024-03-09 15:33:19 -05:00
Joseph T. Lyons
a03fecafbb Remove feedback button from status bar (#9100)
This PR removes the feedback button from the status bar, as Nathan and I
discussed. We discussed the fact that we likely no longer need to take
up valuable screen real estate for this, with where Zed as at now.

This PR also moves the `Share Feedback...` collab menu item to the
`Help` menu, as that's where VS Code puts their action to send in-app
feedback (which might help with future discoverability) and renames it
to `Give Feedback...`, to make it consistent with the name of the
command palette action.

Release Notes:

- Removed the feedback button from the status bar.
2024-03-09 06:15:08 -05:00
Mikayla Maki
ca696fd5f6 Add rs-notify implementation of fs::watch (#9040)
This PR simplifies the Zed file system abstraction and implements
`Fs::watch` for linux and windows.

TODO:
- [x] Figure out why this fails to initialize the file watchers when we
have to initialize the config directory paths, but succeeds on
subsequent runs.
- [x] Fix macOS dependencies on old fsevents::Event crate

Release Notes:

- N/A
2024-03-08 22:18:44 -08:00
Jason Wen
456efb53ad windows: Add file dialog using IFileOpenDialog (#8919)
Release Notes:

- Added a file dialog for Windows
2024-03-08 20:07:48 -08:00
Adam
d4ec78f328 Add strikethrough to deprecated methods in CompletionsMenu (#9086)
Release Notes:

- Added ([#8390](https://github.com/zed-industries/zed/issues/8390)).
- Also Grays out deprecated methods

Before

<img width="730" alt="image"
src="https://github.com/zed-industries/zed/assets/71665039/8b5e8009-22c2-43f7-b85b-79e571a5d282">

After

<img width="773" alt="image"
src="https://github.com/zed-industries/zed/assets/71665039/0aff572b-6d3f-4ed9-b08b-d925ee650817">
2024-03-08 20:01:28 -08:00
bbb651
efe5203a09 GPUI: Wayland: Add fullscreen, minimize and avoid unnecessary resizes (#9060)
Release Notes:
- N/A
2024-03-08 19:52:36 -08:00
Kirill Bulatov
146971fb02 Splice remove suggesion hints when those are cleared in the editor. (#9088)
Closes https://github.com/zed-industries/zed/issues/6793

Release Notes:

- Fixed copilot suggestions not disappearing after disabling the tool
([6793](https://github.com/zed-industries/zed/issues/6793))
2024-03-09 02:00:01 +02:00
Kirill Bulatov
347178039c Add editor::RevertSelectedHunks to revert git diff hunks in the editor (#9068)
https://github.com/zed-industries/zed/assets/2690773/653b5658-e3f3-4aee-9a9d-0f2153b4141b

Release Notes:

- Added `editor::RevertSelectedHunks` (`cmd-alt-z` by default) for
reverting git hunks from the editor
2024-03-09 01:37:24 +02:00
Jadi
6a7a3b257a Add missing docstrings to settings.rs (#9054)
![image](https://github.com/zed-industries/zed/assets/1290639/46c13110-8506-4b03-91d4-b1cfcafe824a)

Add documentation for theme-related settings.

Release Notes:

- Add documentation for theme-related settings ([8383](https://github.com/zed-industries/zed/issues/8383))
2024-03-09 00:46:47 +02:00
Max Brunsfeld
8a6264d933 Provide wasm extensions with APIs needed for using pre-installed LSP binaries (#9085)
In this PR, we've added two new methods that LSP extensions can call:
* `shell_env()`, for retrieving the environment variables set in the
user's default shell in the worktree
* `which(command)`, for looking up paths to an executable (accounting
for the user's shell env in the worktree)

To test this out, we moved the `uiua` language support into an
extension. We went ahead and removed the built-in support, since this
language is extremely obscure. Sorry @mikayla-maki. To continue coding
in Uiua in Zed, for now you can `Add Dev Extension` from the extensions
pane, and select the `extensions/uiua` directory in the Zed repo. Very
soon, we'll support publishing these extensions so that you'll be able
to just install it normally.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-08 17:18:06 -05:00
Jason Lee
5abcc1c3c5 Let LineColumn on StatusBar as clickable to open GoToLineColumn (#9002)
Release Notes:

- Added to let LineColumn on StatusBar as clickable to open
GoToLineColumn.
- Added placeholder to GoToLineColumn input, and show help message on
input changed.

## Screenshot


![go-to-line-column](https://github.com/zed-industries/zed/assets/5518/90a4f644-07d4-4208-8caa-5510e1537f37)
2024-03-08 14:11:17 -07:00
Conrad Irwin
977af37cfe open zed urls (#9081)
Release Notes:

- Added support for opening files on the zed protocol `open
zed:///Users/example/Desktop/a.txt`
([#8482](https://github.com/zed-industries/zed/issues/8482)).
2024-03-08 13:44:01 -07:00
Evren Sen
1756c1fc1e Improve UI of popover buttons when hovering over chat messages (#9041)
### Before


https://github.com/zed-industries/zed/assets/146845123/4a16c1ce-a671-4e39-abc9-3a0cb25bc0cd

### After


https://github.com/zed-industries/zed/assets/146845123/cfab3d00-246e-427d-9c40-8ee520a0a186




Release Notes:
- Improved the UI of popover buttons when hovering over chat messages.
2024-03-08 12:46:51 -07:00
Marshall Bowers
be953b78ef Add script for setting up WASI dependencies (#9078)
This PR adds a script for setting up the WASI dependencies needed for
extensions.

These already get downloaded when needed when using Zed, but in the
tests the HTTP client is faked out, so if you don't already have them
installed the `test_extension_store_with_gleam_extension` test will
fail.

Release Notes:

- N/A
2024-03-08 14:05:29 -05:00
Max Brunsfeld
51ebe0eb01 Allow wasm extensions to do arbitrary file I/O in their own directory to install language servers (#9043)
This PR provides WASM extensions with write access to their own specific
working directory under the Zed `extensions` dir. This directory is set
as the extensions `current_dir` when they run. Extensions can return
relative paths from the `Extension::language_server_command` method, and
those relative paths will be interpreted relative to this working dir.

With this functionality, most language servers that we currently build
into zed can be installed using extensions.

Release Notes:

- N/A
2024-03-08 08:49:27 -08:00
张小白
a550b9cecf Impl prompts and savefile dialog on Windows (#9009)
### Description
This is a part of #8809 , and this PR dose not include `open file
dialog`, as I already saw two PRs impl this.



https://github.com/zed-industries/zed/assets/14981363/3223490a-de77-4892-986f-97cf85aec3ae




Release Notes:

- N/A
2024-03-08 08:14:47 -08:00
Piotr Osiewicz
bf295eac90 Task::spawn now takes an optional task name as an argument.
If it is not set, we fall back to opening a modal. This allows user to spawn tasks via keybind.
2024-03-08 15:28:42 +01:00
Piotr Osiewicz
fa5dfe19f8 Fix default tasks.json definition 2024-03-08 15:28:42 +01:00
Piotr Osiewicz
7b73e2824b fs: allocate backing storage once in Fs::load (#9020)
`futures_lite::AsyncReadExt::read_to_string` (that we use in
`RealFs::load`) explicitly does not allocate memory for String contents
up front, which leads to excessive reallocations. That reallocation time
is a significant contributor to the time we spend loading files (esp
large ones). For example, out of ~1s that it takes to open up a 650Mb
ASCII buffer on my machine (after changes related to fingerprinting from
#9007), 350ms is spent in `RealFs::load`.
This change slashes that figure to ~110ms, which is still *a lot*. About
60ms out of 110ms remaining is spent zeroing memory. Sadly,
`AsyncReadExt` API forces us to zero a buffer we're reading into
(whether it's via read_to_string or read_exact), but at the very least
this commit alleviates unnecessary reallocations.

We could probably use something like
[simdutf8](https://docs.rs/simdutf8/latest/simdutf8/) to speed up UTF8
validation in this method as well, though that takes only about ~18ms
out of 110ms, so while it is significant, I've left that out for now.
Memory zeroing is a bigger problem at this point.

Before:

![image](https://github.com/zed-industries/zed/assets/24362066/5e53c004-8a02-47db-bc75-04cb4113a6bc)

After:

![image](https://github.com/zed-industries/zed/assets/24362066/00099032-d647-4683-b290-eaeb969cac4a)

/cc @as-cii 

Release Notes:

- Improved performance when loading large files.
2024-03-08 14:40:26 +01:00
Kirill Bulatov
1081ba7a62 Adjust to newer logic from zed-industries/cargo-bundle (#9058)
Zed uses a fork of cargo-bundle, that got upstream changes and
9e185bd44d
into the deploy branch.

Remove a TODO and adjust the script to the new packaging logic.


Release Notes:

- N/A
2024-03-08 13:37:10 +02:00
Conrad Irwin
ed8aa6d200 Fix panic in layout_line when Y coordinate is too high (#9052)
Release Notes:

- N/A
2024-03-07 22:33:44 -07:00
Valentine Briese
af564242e1 Make comment above util::fs::remove_matching a doc comment (#9051)
Just this one little thing, noticed it while working on an unrelated
pull request.

Release Notes:

- N/A
2024-03-07 21:15:52 -08:00
EricApostal
aa7be4b5d8 Add clipboard support for Windows (#8978)
Release Notes:

- Added Read / Write clipboard support to Windows via copypasta

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-07 20:16:38 -08:00
Conrad Irwin
866d791760 Fix joining hosted projects (#9038)
Release Notes:

- N/A
2024-03-07 19:56:41 -07:00
Rom Grk
f67abd2943 vim: smartcase find option (#9033)
Release Notes:

- Added option `use_smartcase_find` to the vim-mode
2024-03-07 19:44:20 -07:00
Rom Grk
d247086b21 vim: subword motions (#8725)
Add subword motions to vim, inspired by
[nvim-spider](https://github.com/chrisgrieser/nvim-spider),
[CamelCaseMotion](https://github.com/bkad/CamelCaseMotion).


Release Notes:

- Added subword motions to vim
2024-03-07 19:36:12 -07:00
rauan
467a179837 Add Elixir symbols in outline view (#8761)
Release Notes:

- Improved: Add `@callback`, `@type` and `@typep` Elixir symbols in
outline view



https://github.com/zed-industries/zed/assets/14976415/208d3def-f49e-41e0-a306-fb8e00317e6b
2024-03-07 19:35:01 -07:00
Small White
b50f86735f Impl drag-drop action for Windows (#8959)
### Description

This is a part of #8809 



https://github.com/zed-industries/zed/assets/14981363/2b085b9d-8b83-4ac7-8b84-07c679760eba




Release Notes:

- N/A

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-07 15:59:48 -08:00
Small White
e85d484952 Fix terminal on Windows (#8999)
### Description

Since [this PR](https://github.com/alacritty/alacritty/pull/7796) has
been merged, so we can delete the `todo`s in `terminal` module.


Release Notes:

- N/A
2024-03-07 15:54:58 -08:00
Rom Grk
2d83580df4 linux: enable test TextSystem (#9037)
Make text tests work on linux.
2024-03-07 15:51:52 -08:00
白山風露
a90a667fd0 Windows: Add document (#8948)
Release Notes:

- N/A
2024-03-07 15:41:15 -08:00
Bing Wang
35c7b5d7dd Add vulkan linux dependency (#8932)
Release Notes:

- Fixed ([#8934](https://github.com/zed-industries/zed/issues/8934)).

Optionally, include screenshots / media showcasing your addition that
can be included in the release notes.

**or**

- N/A

Signed-off-by: pigletfly <wangbing.adam@gmail.com>
2024-03-07 15:40:27 -08:00
Kirill Bulatov
ffebe2e4a6 Initial Linux nightly bundles upload (#8913)
Changes Zed CI to build and upload Linux nightly bundles.

* `todo!(linux)` are replaced with `TODO linux` to make `todo!`-based
workflows more convenient
* renames `run-build-dmg` label into `run-bundling`, also renames a few
GH Actions entries to be more generic
* make another upload path for Linux, which keeps a separate file with SHA to version the nightly artifact.
* adds a `*.deb` package building with a couple of caveats, marked with
new `TODO linux` entries:

1. `cargo-bundle` is not very flexible, so it generates artifacts with
the structure and names that we're unable to alter before/during the
generation.
For that, a set of extra steps is made by repacking the *.deb package —
this is not very portable between different Linux distros, so later one
needs to find a way to combine multiple package types in this script.

2. `cargo-bundle` is not able to properly generate the *.msi bundle
despite declaring it in the features:
https://github.com/burtonageo/cargo-bundle/issues/116
Windows needs to invent its own way of bundling or fix the tool.

3. Both `cli` and `zed` binaries are added into the archive under
`/usr/local/bin/` path with their `-$channel` suffix
(-nightly/-preview/-dev/-stable) and a `/usr/local/bin/zed ->
/usr/local/bin/cli-nightly` symlink is made to make CLI work as Zed
launcher:
```
~/work/zed kb/linux-nightly:origin/kb/linux-nightly*​ ❯ dpkg -c target/zed_amd64.deb 
drwxr-xr-x allaptop/allaptop 0 2024-03-06 00:53 ./
drwxr-xr-x allaptop/allaptop 0 2024-03-06 00:53 ./usr/
drwxr-xr-x allaptop/allaptop 0 2024-03-06 00:53 ./usr/local/
drwxr-xr-x allaptop/allaptop 0 2024-03-06 00:53 ./usr/local/bin/
-rwxr-xr-x allaptop/allaptop 8746832 2024-03-06 00:53 ./usr/local/bin/cli-nightly
-rwxr-xr-x allaptop/allaptop 689078560 2024-03-06 00:53 ./usr/local/bin/zed-nightly
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/applications/
-rw-r--r-- allaptop/allaptop       153 2024-03-06 00:53 ./usr/share/applications/zed.desktop
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/hicolor/
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/hicolor/1024x1024@2x/
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/hicolor/1024x1024@2x/apps/
-rw-r--r-- allaptop/allaptop    716288 2024-03-06 00:53 ./usr/share/icons/hicolor/1024x1024@2x/apps/zed.png
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/hicolor/512x512/
drwxr-xr-x allaptop/allaptop         0 2024-03-06 00:53 ./usr/share/icons/hicolor/512x512/apps/
-rw-r--r-- allaptop/allaptop    239870 2024-03-06 00:53 ./usr/share/icons/hicolor/512x512/apps/zed.png
lrwxrwxrwx allaptop/allaptop         0 2024-03-06 00:53 ./usr/local/bin/zed -> /usr/local/bin/cli-nightly
```

But the CLI does not work under Linux yet and there's no way to install
that CLI from Zed now; Zed binary itself is not able to open
`file/location:12:34`-like things and set up the env properly, but is
able to start or open a directory.

So, this structure can be considered temporary and changed, if needed.

4. Zed Nightly on Linux does not know how to update itself, so all
nightly publishing is not picked up automatically.

5. Rust cache from `main` builds does not get shared between CI jobs,
due to being run in a different CI job that forms a different CI key, so
```
      - name: Cache dependencies
        uses: swatinem/rust-cache@v2
        with:
          save-if: ${{ false }}
```
would not work.
This makes Linux bundling jobs long.

Release Notes:

- N/A
2024-03-07 23:22:53 +02:00
Conrad Irwin
e85f190128 Fix 0 notes versions being always unread (#9030)
Co-Authored-By: Max <max@zed.dev>
Co-Authored-By: Nathan <nathan@zed.dev>

Release Notes:

- Fixed empty notes always showing as unread

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
2024-03-07 13:53:05 -07:00
Conrad Irwin
284a57d4d1 Fix panic in open urls (#9032)
Co-Authored-By: Nathan <nathan@zed.dev>

Release Notes:

- N/A

Co-authored-by: Nathan <nathan@zed.dev>
2024-03-07 13:52:50 -07:00
Rom Grk
9068911eb4 wayland: don't dispatch modifier key events (#9027)
Modifier keys are dispatched as events on wayland, unlike macos. This
prevents pending bindings from matching, because something like e.g. `g
shift-e` is received by the key matcher as `g shift shift-e`.
2024-03-07 12:42:48 -08:00
Max Brunsfeld
27518f4280 Fix extension store test failure on main due to wasi-sdk download 2024-03-07 10:53:28 -08:00
Conrad Irwin
86748a09e7 Denormalize buffer operations (#9026)
This should significantly reduce database load on redeploy.

Co-Authored-By: Max <max@zed.dev>
Co-Authored-By: Nathan <nathan@zed.dev>

Release Notes:

- Reduced likelihood of being disconnected during deploys

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
2024-03-07 11:35:47 -07:00
d1y
b5370cd15a Remove git_commit syntax highlighting from core Zed (#9025)
Fallback to extension
https://github.com/zed-industries/extensions/pull/307

Release Notes:

- Remove git_commit syntax highlighting from Zed core, `git-firefly` extension replaced that

Co-authored-by: William Desportes <williamdes@wdes.fr>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2024-03-07 20:23:44 +02:00
Kirpal Grewal
85e6bc94e9 Enable clippy::suspicious_to_owned (#9004)
Another small change: calling to owned on the `Cow` was cloning the
`Cow`, not its contents and so calling `clone` makes this more explicit
2024-03-07 11:30:40 -05:00
Yesterday17
105e654dce Include font_features in cache key for fonts (#8928)
## Release Notes

- Fixed font ligatures not always respecting the setting
([#4313](https://github.com/zed-industries/zed/issues/4313)).

## Preview


![20240306133121_rec_-convert](https://github.com/zed-industries/zed/assets/8667822/dc2aaa00-41d0-4fe9-8d9c-80e1f047894d)
2024-03-07 11:06:19 -05:00
Max
6b8984279f Pluralize and order user menu items for consistency (#9013)
Release Notes:

- N/A
2024-03-07 17:59:33 +02:00
Jason Lee
bc7fb9f253 Show tooltip with item paths for recent project picker items (#8987)
Before

![empty-tooltip](https://github.com/zed-industries/zed/assets/5518/4a00158c-5ae1-4ef9-8686-d4c188a99050)

After

![output](https://github.com/zed-industries/zed/assets/5518/b30f8272-485d-40e1-989a-facd122e96c8)

Release Notes:

- Fixed empty tooltip for recent projects picker items
2024-03-07 17:35:48 +02:00
Piotr Osiewicz
d450fde1ed language: Track buffer dirty state based on edits, not on file contents 2024-03-07 14:11:35 +01:00
Anthony Eid
4c9c9df730 Add ZED_SELECTED_TEXT variable to tasks (#8865)
Tasks are able to access a users selected text using the environment
variable "ZED_SELECTED_TEXT".

Release notes:

- Added ZED_SELECTED_TEXT task variable which contains contents of
selection
2024-03-07 11:59:25 +01:00
Piotr Osiewicz
3a9ec906af task: make ZED_FILE return abs path, for real this time (#9000)
Release Notes:

- Fixed ZED_FILE environment variable containing a relative path, not an
absolute one.
2024-03-07 11:50:07 +01:00
Floyd Wang
01fe3eec4d Fix project panel icon bouncing when renaming (#8988)
I found the project panel icon has a little bounce when I tried to
rename some files.

Release Notes:

- Fix project panel icon bouncing when renaming.

## Before



https://github.com/zed-industries/zed/assets/28998859/76f04c33-da68-40e2-9c83-045e78187679

**Set `buffer_line_height` to `standard`**


https://github.com/zed-industries/zed/assets/28998859/9a9eca93-5fda-4060-ba1d-0cd4e0486eb8



## After


https://github.com/zed-industries/zed/assets/28998859/29b49f1c-a9ae-4281-8921-8f1d8dd74262

**Set `buffer_line_height` to `standard`**


https://github.com/zed-industries/zed/assets/28998859/8f1ccbb5-fe0e-4905-97c4-cb7431e5dc46
2024-03-07 09:18:59 +01:00
Joseph T. Lyons
0a07746381 Delete tasks.md
Moved documentation to zed.dev
2024-03-07 01:08:20 -05:00
Joseph T. Lyons
026cdc617c Update tasks.md 2024-03-07 01:02:07 -05:00
Thorsten Ball
4238793d16 Add [x/]x to select larger/smaller syntax node in Vim (#8985)
`[x` will select the larger syntax node, `]x` the smaller one. Inspired
by https://github.com/tpope/vim-unimpaired.

Release Notes:

- Added `[x` and `]x` as default keybindings in Vim mode to select
larger and smaller syntax nodes respectively.
2024-03-07 06:53:17 +01:00
Conrad Irwin
1a9387035d Only 5s of data! (#8983)
This is still 200Mb in production, and takes several minutes to process
and download.

Release Notes:

- N/A
2024-03-06 21:35:46 -07:00
Conrad Irwin
4f53e6e9a0 Update cargo.lock 2024-03-06 20:55:34 -07:00
Conrad Irwin
75a42c27db Migrate from scrypt to sha256. (#8969)
This reduces the server time to compute the hash from 40ms to 5µs,
which should remove this as a noticable chunk of CPU time in production.

(An attacker who has access to our database will now need only 10^54
years of CPU time instead of 10^58 to brute force a token).

Release Notes:

- Improved sign in latency by 40ms.
2024-03-06 20:51:43 -07:00
Evren Sen
4d2156e2ad Improved message hovering in chat panel (#8977)
Highlights messages on hover and fixed a more concise position for the
popover menu button.

Before:


https://github.com/zed-industries/zed/assets/146845123/39cab30f-659f-4164-a4ac-1dfee796e016

<img width="368" alt="Screenshot 2024-03-07 at 01 08 24"
src="https://github.com/zed-industries/zed/assets/146845123/74f41243-2dc2-4839-a733-9db3109e4665">

<img width="313" alt="Screenshot 2024-03-07 at 01 04 39"
src="https://github.com/zed-industries/zed/assets/146845123/f66c764d-488a-4303-b66e-f75835df6949">

After:


https://github.com/zed-industries/zed/assets/146845123/ac059c0d-7b16-4fd5-bbd7-ca96e1a6dfe1


<img width="368" alt="Screenshot 2024-03-07 at 01 09 42"
src="https://github.com/zed-industries/zed/assets/146845123/fa8940f6-52b4-489d-b0d3-d0e9443e2de2">

<img width="313" alt="Screenshot 2024-03-07 at 01 04 31"
src="https://github.com/zed-industries/zed/assets/146845123/850226f3-2c70-4a90-bb35-4a4cb0b7a219">


Thank you for the help @ConradIrwin and @RemcoSmitsDev !


Release Notes:
- Improved message hovering in chat panel
2024-03-06 20:47:19 -07:00
L
9481b346e2 Fix issue template formatting (#8866)
Release Notes:
- N/A

Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
2024-03-06 22:11:48 -05:00
Mikayla Maki
8a92d28663 Remove todo! comments (#8981)
Switching fully to normal `todo` style

Release Notes:

- N/A
2024-03-06 18:25:20 -08:00
Bennet Bo Fenner
8be4b4d75d Support emoji shortcodes in chat (#8455)
Completes: https://github.com/zed-industries/zed/issues/7299

Suggestions


https://github.com/zed-industries/zed/assets/53836821/2a81ba89-4634-4d94-8370-6f76ff3e9403

Automatically replacing shortcodes without using the completions (only
enabled when `message_editor` > `auto_replace_emoji_shortcode` is
enabled in the settings):


https://github.com/zed-industries/zed/assets/53836821/10ef2b4b-c67b-4202-b958-332a37dc088e






Release Notes:

- Added autocompletion for emojis in chat when typing emoji shortcodes
([#7299](https://github.com/zed-industries/zed/issues/7299)).
- Added support for automatically replacing emoji shortcodes in chat
(e.g. typing "👋" will be converted to "👋")

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-03-06 19:18:29 -07:00
Mikayla Maki
c0edb5bd6c GPUI custom window prompts (#8980)
This adds a GPUI fallback for window prompts. Linux does not support
this feature by default, so we have to implement it ourselves.

This implementation also makes it possible for GPUI clients to override
the platform prompts with their own implementations.

This is just a first pass. These alerts are not keyboard accessible yet,
does not reflect the prompt level, they're implemented in-window, rather
than as popups, and the whole feature need a pass from a designer.
Regardless, this gets us one step closer to Linux support :)

<img width="650" alt="Screenshot 2024-03-06 at 5 58 08 PM"
src="https://github.com/zed-industries/zed/assets/2280405/972ebb55-fd1f-4066-969c-a87f63b22a6f">

Release Notes:

- N/A
2024-03-06 18:15:06 -08:00
bbb651
c8e03ce42a Wayland: Support integer scaling without wp_fractional_scale (#8886)
Release Notes:
- N/A

`DoubleBuffered` is not currently very necessary because we only care
about a single field `OutputState::scale` but I think it can be useful
for other objects as it's a fairly common pattern in wayland.
2024-03-06 18:13:23 -08:00
intigonzalez
74e7611ceb windows: get current display size (#8916)
For the moment the windows port has a single display with hard-coded
values.

This first PR is just to at least fetch the **actual size of the current
display**. The idea
is using this code as a first template to start getting familar with the
code base
and prepare the work for enumerating all displays.
2024-03-06 18:12:44 -08:00
Conrad Irwin
0b87be71e6 Make anchor_in_excerpt Optional (#8975)
We were seeing panics due to callers assuming they had valid
excerpt_ids, but that cannot easily be guaranteed across await points as
anyone may remove an excerpt.

Release Notes:

- Fixed a panic when hovering in a multibuffer
2024-03-06 18:55:36 -07:00
Kirill Bulatov
ae5ec9224c Small fixes to task modal & long commands (#8974)
* Show the entire task tooltip on terminal tab hover:
<img width="979" alt="Screenshot 2024-03-07 at 01 40 56"
src="https://github.com/zed-industries/zed/assets/2690773/bc274a5c-70f6-4f3d-87b4-04aff3594089">

* Scroll to the end of the query when a menu label is reused as a query:
<img width="658" alt="Screenshot 2024-03-07 at 01 41 03"
src="https://github.com/zed-industries/zed/assets/2690773/972857f4-36db-49dc-8fa1-dd15e0470660">

Release Notes:

- Improved task modal UX with long bash-like commands
2024-03-07 03:21:11 +02:00
Conrad Irwin
ca37d39109 add a script to get a flamegraph of collab in production (#8972)
Add `./script/collab-flamegraph` so you can profile in production (or
staging)

Release Notes:

- N/A
2024-03-06 16:39:48 -07:00
Max Brunsfeld
675ae24964 Add a command for building and installing a locally-developed Zed extension (#8781)
This PR adds an `zed: Install Local Extension` action, which lets you
select a path to a folder containing a Zed extension, and install that .
When you select a directory, the extension will be compiled (both the
Tree-sitter grammars and the Rust code for the extension itself) and
installed as a Zed extension, using a symlink.

### Details

A few dependencies are needed to build an extension:
* The Rust `wasm32-wasi` target. This is automatically installed if
needed via `rustup`.
* A wasi-preview1 adapter WASM module, for building WASM components with
Rust. This is automatically downloaded if needed from a `wasmtime`
GitHub release
* For building Tree-sitter parsers, a distribution of `wasi-sdk`. This
is automatically downloaded if needed from a `wasi-sdk` GitHub release.

The downloaded artifacts are cached in a support directory called
`Zed/extensions/build`.

### Tasks

UX

* [x] Show local extensions in the Extensions view
* [x] Provide a button for recompiling a linked extension
* [x] Make this action discoverable by adding a button for it on the
Extensions view
* [ ] Surface errors (don't just write them to the Zed log)

Packaging

* [ ] Create a separate executable that performs the extension
compilation. We'll switch the packaging system in our
[extensions](https://github.com/zed-industries/extensions) repo to use
this binary, so that there is one canonical definition of how to
build/package an extensions.

### Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-06 15:35:22 -08:00
Conrad Irwin
e273198ada Debounce language server updates (#8953)
We'll send at least one every 100ms, but may send more if other messages
are sent on the connection.

Release Notes:

- Fixed some slowness when collaborating with verbose language servers.
2024-03-06 15:58:22 -07:00
Small White
af87fb98d0 Implement more GPUI services on windows. (#8940)
### Description

This is a part of #8809 , impl the following functions:

- `os_version`
- `local_timezone`
- `double_click_interval`
- `set_cursor_style`
- `open_url`
- `reveal_path`

Release Notes:
- N/A

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-06 12:48:43 -08:00
Andrew Lygin
effc317a06 Fix project panel scrolling position restoration (#8961)
Project panel loses the last scrolling position every time the user
hides/shows it. This PR fixes the problem.

The reason of the problem is that `UniformListScrollHandle`, which is
intended to store the scrolling position between redrawings, is only
used for ad-hoc autoscrollings to the list items, while the
`interactivity.scroll_handle` that is responsible for the scrolling
position, doesn't survive the project panel hiding.

How the problem looks:


https://github.com/zed-industries/zed/assets/2101250/7c7e3da6-9a9d-4f28-a181-ee9547349d4c

Release Notes:

- Fixed scrolling position restoration in the Project Panel.
2024-03-06 12:00:51 -08:00
Max Brunsfeld
6bbd09e28e Emit the WorktreeUpdatedEntries event for all projects, not just local (#8963)
Fixes a regression introduced in
https://github.com/zed-industries/zed/pull/8846 (which hasn't yet been
released), in which the project panel didn't update correctly for remote
projects when collaborating.

Release Notes:

- N/A
2024-03-06 11:58:18 -08:00
Ezekiel Warren
06035dadea windows: more frequent frame requests (#8921)
Note rust analyzer running in background now without keyboard/mouse
movement.

![](https://media.discordapp.net/attachments/1208481909676576818/1214769879098597416/high-framerate-windows.gif?ex=65fa519c&is=65e7dc9c&hm=4c9ba72fa3c3c548964e46d9c07f0c0bf9545ed9a9ae11495101dcae5db06d59&=)

Release Notes:

- Improved frame rate on Windows
2024-03-06 11:54:33 -08:00
Small White
8357039419 Set the default DPI awareness for Zed (#8936)
### Description

This is a part of #8809 


Release Notes:
- N/A
2024-03-06 11:45:18 -08:00
Small White
59faef5800 Update mio (#8935)
### Description
This is a part of #8809 

Update mio from 0.8.8 to 0.8.11.

When using named pipes on Windows, mio will under some circumstances
return invalid tokens that correspond to named pipes that have already
been deregistered from the mio registry. The impact of this
vulnerability depends on how mio is used. For some applications, invalid
tokens may be ignored or cause a warning or a crash. On the other hand,
for applications that store pointers in the tokens, this vulnerability
may result in a use-after-free.

### Connections

[named-pipes: fix receiving IOCP events after deregister
#1760](https://github.com/tokio-rs/mio/pull/1760)

[Windows Named pipes invalid memory access
#6369](https://github.com/tokio-rs/tokio/issues/6369)


Release Notes:

- N/A
2024-03-06 11:32:46 -08:00
Ezekiel Warren
a0fac3866a prevent empty cwd in terminal view (#8924)
closes #8825

Release Notes:

- N/A
2024-03-06 11:26:16 -08:00
Edvard Høiby
8352f39ff9 Improve bindings to better match VS-Code (#8584)
Release Notes:

- Changed default keybindings in the VS Code keymap so that
`alt-[up|down]` now move lines up/down and`alt-shift-[up|down]`
duplicate lines up/down. Previous bindings for selecting larger/smaller
syntax nodes are now bound to `ctrl-shift-[left|right]`.
([#4652](https://github.com/zed-industries/zed/issues/4652))([#7151](https://github.com/zed-industries/zed/issues/7151))

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-03-06 11:16:14 -08:00
Joseph T. Lyons
850ddddcac v0.127.x dev 2024-03-06 12:30:14 -05:00
Conrad Irwin
563c4db350 Install perf tools in production containers (#8957)
Release Notes:

- N/A
2024-03-06 10:27:08 -07:00
Conrad Irwin
8eb0239d5a Remove console-subscriber (#8955)
It doubles CPU and RAM usage for not really enough benefit

Release Notes:

- N/A
2024-03-06 10:26:59 -07:00
Conrad Irwin
deb86a1ffc Fix ./script/symbolicate on Preview crashes (#8956)
Release Notes:

- N/A
2024-03-06 10:26:50 -07:00
Kirpal Grewal
b622dcbc64 Enable clippy::cast_abs_to_unsigned (#8912)
Thankfully this one is a simple, single change that also prevents
overflow in the `abs()`
2024-03-06 12:21:48 -05:00
Jason Lee
2f15676b7c Update App Menus to add ... for some modal action menu, and group menu items by type. (#8951)
Release Notes:

- Improved App Menu, add `...` for modal action menu, and group menu
items by type.

In macOS and Windows, the `...` suffix of menu item, is means that will
open a dialog.
2024-03-06 12:10:09 -05:00
Jason Lee
4a60326c1c Remove workspace border, avoid the main window having double borders (#8922)
Release Notes:

- Fixed main window border, avoid double borders.



## Diff (Left is Before, Right is After)


![SCR-20240306-g2v](https://github.com/zed-industries/zed/assets/5518/b13bab55-9d74-4181-ae43-e338bb6f7112)

![SCR-20240306-g0x](https://github.com/zed-industries/zed/assets/5518/af9d4190-a974-4c26-8466-dce1c78c3f31)




Reference to Safari:

![SCR-20240306-ejo](https://github.com/zed-industries/zed/assets/5518/14c41898-8218-4bec-8574-8915a7186926)


## More Theme tests

![SCR-20240306-g0d](https://github.com/zed-industries/zed/assets/5518/8938671e-bc7c-4a6a-8c06-0992beb92bb1)

![SCR-20240306-g0j](https://github.com/zed-industries/zed/assets/5518/73a68663-70f5-4f83-aea0-2079236079e7)

![SCR-20240306-g0q](https://github.com/zed-industries/zed/assets/5518/0a2b4905-3dd1-4081-b538-a78728470004)



![SCR-20240306-fu9](https://github.com/zed-industries/zed/assets/5518/dd3a9e2c-ea28-46c6-a993-047dae8b2d8f)
2024-03-06 10:03:59 -05:00
Jason Lee
567fee4219 Update Project search to Project Search. (#8943)
Release notes:

- N/A
2024-03-06 15:23:55 +01:00
Max Brunsfeld
6036830049 Throttle the sending of UpdateFollowers messages (#8918)
## Problem

We're trying to figure out why we sometimes see high latency when
collaborating, even though the collab server logs indicate that messages
are not taking long to process.

We think that high volumes of certain types of messages, including
`UpdateFollowers` may cause a lot of messages to queue up, causing
delays before collab sees certain messages.

## Fix

This PR reduces the number of `UpdateFollowers` messages that clients
send to collab when scrolling around or moving the cursor, using a
time-based throttle.

The downside of this change is that scrolling will not be as smooth when
following someone. The advantage is that it will be much easier to keep
up with the stream of updates, since they will be sent much less
frequently.

## Release Notes:

- Fixed slowness that could occur when collaborating due to excessive
messages being sent to support following.

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-03-06 14:58:41 +01:00
Antonio Scandurra
c8383e3b18 Use a string for ZED_LOAD_BALANCER_SIZE_UNIT in k8s template
Co-Authored-By: Thorsten <thorsten@zed.dev>
2024-03-06 11:03:14 +01:00
Antonio Scandurra
334c3c670b Use a string for ZED_LOAD_BALANCER_SIZE_UNIT
Co-Authored-By: Thorsten <thorsten@zed.dev>
2024-03-06 10:52:35 +01:00
Antonio Scandurra
e3a7192c11 Give a name to load balancers and increase node count for production (#8939)
Release Notes:

- N/A

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-03-06 10:38:17 +01:00
Hans
6327f3ced8 Modify the link to the latest (#8925)
Fixed the link for Vue LSP server

Release Notes:

- N/A
2024-03-06 08:02:24 +02:00
Conrad Irwin
c58422cb3f Fix YAML indentation 2024-03-05 22:11:58 -07:00
Conrad Irwin
6d53846824 0-downtime collab deploys? (#8926)
Before this change Kubernetes would send a SIGTERM to the old server
before the new one was ready. Now it will wait.

From my reading it seems like startupProbe should not be necessary if we
have a
readinessProbe; but from testing it seems like without startupProbe we
still
drop requests when using `rollout restart`

Release Notes:

- Fixed connectivity issues during Zed deploys.
2024-03-05 21:58:00 -07:00
Max Brunsfeld
01e5e4224a Fix numeric sign of queue duration in logs 2024-03-05 16:00:03 -08:00
Max Brunsfeld
4de80688b9 Revert "Install perf on collab image (#8910)"
Keep the removal of the collab resource requests.

This reverts commit ce6bde5a24.
2024-03-05 15:23:15 -08:00
Max Brunsfeld
ce6bde5a24 Install perf on collab image (#8910)
Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-03-05 14:59:31 -08:00
Max Brunsfeld
35c516fda9 Log the time incoming RPC messages were queued (#8909)
Release Notes:

- N/A

Co-authored-by: Conrad <conrad@zed.dev>
2024-03-05 14:40:09 -08:00
Kirpal Grewal
bca98caa07 Enable clippy::unnecessary_to_owned (#8908)
lint for `unnecessary_to_owned` and fix the sole violation in the
codebase
2024-03-05 17:28:58 -05:00
Max Brunsfeld
b68a277b5e Fix tracing subscriber after introducing Tokio-console (#8907)
We've also upgraded `Axum` in order to avoid having two versions of that
library in Collab (one due to Tokio-console).

Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-03-05 14:11:33 -08:00
Kirill Bulatov
703c9655a0 Always resolve code action if needed (#8904)
Follow-up of https://github.com/zed-industries/zed/pull/8874 and
https://github.com/zed-industries/zed/pull/7635
Closes https://github.com/zed-industries/zed/issues/7609

* mentions all `lsp::CodeActions` properties in the Zed client resolve
capabilities to remove more json out of general actions request
potentially
* removes odd `CodeActions.data` field checks, as that field is opaque
and is intended to store data, needed by the langserver to resolve this
code action
* if any `CodeAction` lacks either `command` or `edits` fields, tries to
resolve the action

This all effectively causes Zed to always fire an action resolve
request, since we update actions list (replacing the resolved actions
with the new, unresolved ones) via `refresh_code_actions`

9e66d48ccd/crates/editor/src/editor.rs (L3650)
that is being called on selections change and the actions menu open.

Yet, we do not query the resolve until the action is either applied
(selected in the list), or called for formatting, so it seems to be fine
to resolve them always, as it's not a frequent operation such as
reacting to every keystroke.


Release Notes:

- Fixed certain code actions not being resolved properly ([7609](https://github.com/zed-industries/zed/issues/7609))

---------

Co-authored-by: Derrick Laird <swampdonk@gmail.com>
2024-03-05 23:42:12 +02:00
Marshall Bowers
addfcdea8d Enable clippy::implied_bounds_in_impls (#8906)
This PR enables the
[`clippy::implied_bounds_in_impls`](https://rust-lang.github.io/rust-clippy/master/index.html#/implied_bounds_in_impls)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-05 16:04:55 -05:00
Conrad Irwin
d112bcfadf Fix project subscription order (#8900)
Co-Authored-By: Antonio <as-cii@zed.dev>

Release Notes:

- Fixed a bug that prevents project joining

Co-authored-by: Antonio <as-cii@zed.dev>
2024-03-05 13:34:25 -07:00
Marshall Bowers
9e66d48ccd Enable clippy::cmp_owned (#8899)
This PR enables the
[`clippy::cmp_owned`](https://rust-lang.github.io/rust-clippy/master/index.html#/cmp_owned)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-05 14:36:53 -05:00
Joseph T. Lyons
d98b61e3d6 Improve wording on recent projects placeholder instructions 2024-03-05 13:51:25 -05:00
Joseph T. Lyons
ad0c5731e5 Update config.yml 2024-03-05 13:23:17 -05:00
Conrad Irwin
cfffa29f9a Enable tokio-console (#8897)
Release Notes:

- Added tokio-console in production
2024-03-05 10:56:14 -07:00
白山風露
9a2ed4bf1a Windows: use folders under AppData (#8828)
To be honest, I am not sure how to use these directories. But since it
is difficult to change these later, if we are going to change them, I
think it is time to do.

Release Notes:

- N/A
2024-03-05 09:48:27 -08:00
Marshall Bowers
b6af393e6d Enable clippy::borrow_deref_ref (#8894)
This PR enables the
[`clippy::borrow_deref_ref`](https://rust-lang.github.io/rust-clippy/master/index.html#/borrow_deref_ref)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-05 12:24:54 -05:00
Owen Law
a25edcc5a8 Add libxcb-devel build dep to void linux script (#8872)
Added missing libxcb-devel to build dependency script for void-linux.
2024-03-05 09:16:08 -08:00
Marshall Bowers
22fe03913c Move Clippy configuration to the workspace level (#8891)
This PR moves the Clippy configuration up to the workspace level.

We're using the [`lints`
table](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table)
to configure the Clippy ruleset in the workspace's `Cargo.toml`.

Each crate in the workspace now has the following in their own
`Cargo.toml` to inherit the lints from the workspace:

```toml
[lints]
workspace = true
```

This allows for configuring rust-analyzer to show Clippy lints in the
editor by using the following configuration in your Zed `settings.json`:

```json
{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "check": {
          "command": "clippy"
        }
      }
    }
  }
```

Release Notes:

- N/A
2024-03-05 12:01:17 -05:00
Dzmitry Malyshau
52f750b216 Update blade to latest: work around Intel+NVidia driver bug (#8811)
Picks up https://github.com/kvark/blade/pull/92
Should unblock some of the unhappy users.
Upstream bug - https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688

Release Notes:
- N/A
2024-03-05 08:48:34 -08:00
Ezekiel Warren
36c4831806 windows: mouse and keyboard (#8791)
Windows mouse and keyboard working! I also tweaked the message loop so
that it didn't get stuck. The peek message loop was almost never
returning for me during testing.

Release Notes:

- Added windows mouse and keyboard support

![windows-mouse-and-keyboard](https://github.com/zed-industries/zed/assets/1284289/08578fbf-0cb2-4e44-bab1-3c4f0291ea4b)
2024-03-05 08:35:07 -08:00
Nathan Sobo
7c9f680b1b Request more resources for collab pods on Kubernetes (#8890)
Worried that if we don't do this, they don't give us enough. We're
maxing out the pod's CPU but the node is barely sweating.

Release Notes:

- N/A
2024-03-05 09:15:08 -07:00
Thorsten Ball
2b8b913b6b Use correct worktree when getting permalink to line (#8888)
Previously this code would call `project.visible_worktrees(cx).next`
which might not necessarily return the worktree matching the currently
open file.

What this change does is it adds `get_repo` method on `Project` that
allows us to get the `GitRepository` for the current buffer.

Release Notes:

- Fixed `open permalink to line` not working when multiple folders are
added to the project.

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-03-05 16:59:00 +01:00
Dzmitry Malyshau
d286c56ebb Optimize rustybuzz and ttf-parser in Dev (#8873)
This PR improves the `draw()` time from hundreds to about 30ms, so
roughly 10x.
It makes Zed quite usable in Dev profile.

Release Notes:
- N/A
2024-03-05 06:37:28 -08:00
Jason Lee
0b34b1de7b Fix first/last item margin on scroll (#8880)
![output](https://github.com/zed-industries/zed/assets/5518/e39a3600-99c4-4d3c-baee-efd53a474f38)

Before:

https://github.com/zed-industries/zed/assets/5518/f7a4563a-504a-4a41-bfd4-21e9439cd02b

After:

https://github.com/zed-industries/zed/assets/5518/0ba41527-46fd-404f-8207-1b8c5cf37434


Release Notes:

- Fixed first and last item margin when scroll view has padding
2024-03-05 15:54:48 +02:00
Thorsten Ball
537d92533c Backport code_actions_on_format docs and update them (#8881)
Release Notes:

- N/A
2024-03-05 11:06:49 +01:00
Jason Lee
fae5e83d93 Fix all Picker Item cursor to use Pointer. (#8877)
Before:

https://github.com/zed-industries/zed/assets/5518/84874858-7847-4fa4-b7a3-41ecc65a2f7d

After: 

https://github.com/zed-industries/zed/assets/5518/d395ea96-aa26-4de1-8bfc-73cc43ee75cf


Release Notes:

- Made picker items to use `Pointer` cursor style
2024-03-05 11:32:57 +02:00
Jason Lee
6a268e959f Improve VCS Menu header top margin. (#8879)
## Before

![SCR-20240305-nga](https://github.com/zed-industries/zed/assets/5518/e814d770-a5b1-4289-acc4-808bf7d96690)

![SCR-20240305-nge](https://github.com/zed-industries/zed/assets/5518/abba4f7c-7e6c-447f-8e4f-fbecdf802f62)

## After

![SCR-20240305-nfp](https://github.com/zed-industries/zed/assets/5518/5539b15c-c67d-466b-9c46-44e488788b04)

![SCR-20240305-nfu](https://github.com/zed-industries/zed/assets/5518/5cfdf861-b55c-4f1e-a41f-dcd42a449488)

Release Notes:

- Improve VCS Menu header top margin, and use `TextMuted` color for
matched count label.
2024-03-05 10:19:52 +01:00
Kirill Bulatov
4b2e774594 Fix license generation and Closure LSP repo link (#8876)
Release Notes:

- N/A
2024-03-05 10:43:02 +02:00
Conrad Irwin
e0c66b30c8 Fix panic in enclosing bracket ranges (#8870)
This function was operating in the wrong co-ordinate space (c.f. #8081)

Release Notes:

- Fixed a panic on `ctrl-m` in a multibuffer
2024-03-04 21:27:01 -07:00
Conrad Irwin
27c5343707 hosted projects (#8627)
- **Allow joining a hosted project**

You can't yet do anything in a hosted project, but you can join it and
look how empty it is.

Release Notes:

- N/A
2024-03-04 19:17:40 -07:00
Quadri A. Adekunle
4167c66b86 macOS: Fix center window with fixed bounds size (#8475)
This PR fixes window showing up in the center of the monitor when
`center: true` option is provided.

The idea is to set the `window_wize` when creating the `window` using
`native_window.initWithContentRect_styleMask_backing_defer_screen_()`

Before: 

<img width="851" alt="SCR-20240227-qokf"
src="https://github.com/zed-industries/zed/assets/20229808/27494966-2e97-4771-8837-ccb6658ced78">

After:

<img width="1132" alt="SCR-20240227-qlmg"
src="https://github.com/zed-industries/zed/assets/20229808/439568da-d380-4331-8d19-cd501f211c4c">


Release Notes:

- N/A
2024-03-04 17:08:29 -07:00
Noritada Kobayashi
d223fe446d vim: Add support for ap and ip paragraph text objects (#7687)
This PR adds support for `ap`/`ip` text objects in Vim mode and allows
users to perform paragraph-based operations.

Cases where compatibility with Neovim's behavior is checked, cases where
there are known differences in behavior with Neovim (cases where the
landing position is other than the beginning of the line), and cases
where the Neovim behavior in the test suite seems strange are separated
in the test code so that they can be identified.

Release Notes:

- Added support for `ap` and `ip` paragraph text objects in Vim mode
([#7359](https://github.com/zed-industries/zed/issues/7359)).
2024-03-04 16:39:02 -07:00
snorkypie
b742db65fe vim: Support keybinding z. (#8702)
`z.` is similar to zz but moves the cursor to the first non-blank
character.

From the documentation:
```
z.   Redraw, line [count] at center of window (default cursor line). Put cursor at first non-blank in the line.
zz   Like "z.", but leave the cursor in the same column.
```

Release Notes:

- Support the `z.` vim keybinding: Center cursor in window and put
cursor at first non-blank
2024-03-04 16:34:42 -07:00
Conrad Irwin
f53823c840 Remove release channel from Zed URLs (#8863)
Also adds a new command `cli: Register Zed Scheme` that will cause URLs
to be opened in the current zed version, and we call this implicitly if
you install the CLI

Also add some status reporting to install cli

Fixes: #8857



Release Notes:

- Added success/error reporting to `cli: Install Cli`
([#8857](https://github.com/zed-industries/zed/issues/8857)).
- Removed `zed-{preview,nightly,dev}:` url schemes (used by channel
links)
- Added `cli: Register Zed Scheme` to control which zed handles the
`zed://` scheme (defaults to the most recently installed, or
the version that you last used `cli: Install Cli` with)
2024-03-04 16:08:47 -07:00
Piotr Osiewicz
2201b9b116 task: Add task contexts (#8675)
This PR supplements tasks with additional environment variables; ideally
we'll be able to write a task like:
`cargo test -p $ZED_CURRENT_PACKAGE -- $ZED_CURRENT_FUNCTION`
- [x] Flesh out multibuffer interactions
- [x] Add ZED_SYMBOL detection based on tree-sitter queries
- [ ] Add release note and demo
- [x] Figure out a solution for rerun dilemma - should `task: rerun`
reevaluate contexts for tasks?

This PR introduced the following variables:
- ZED_COLUMN - current line column
- ZED_ROW - current line row
and the following, which are available for buffers with associated
files:
- ZED_WORKTREE_ROOT - absolute path to the root of the current worktree.
- ZED_FILE - absolute path to the file
- ZED_SYMBOL - currently selected symbol; should match the last symbol
shown in a symbol breadcrumb (e.g. `mod tests > fn test_task_contexts`
should be equal to ZED_SYMBOL of `test_task_contexts`). Note that this
isn't necessarily a test function or a function at all.

Also, you can use them in `cwd` field of definitions (note though that
we're using https://docs.rs/subst/latest/subst/#features for that, so
don't expect a full shell functionality to work); the syntax should
match up with your typical Unix shell.


Release Notes:

- Added task contexts, which are additional environment variables set by
Zed for task execution; task content is dependent on the state of the
editor at the time the task is spawned.

---------

Co-authored-by: Anthony <anthonyeid7@protonmail.com>
2024-03-04 21:04:53 +01:00
Conrad Irwin
b2f18cfe71 Ensure followed cursors are always visible (#8849)
Before this change they would disappear if you blurred the pane.

Release Notes:

- Fixed an issue where the followed users' cursor would disappear if you
blurred the pane.
2024-03-04 12:39:08 -07:00
Joseph T. Lyons
95e532c56d Add option to sign in to copilot from welcome screen (#8853)
Fixes: https://github.com/zed-industries/zed/issues/8851


https://github.com/zed-industries/zed/assets/19867440/5d391289-34e8-4abc-9337-b7e253f4e513

Release Notes:

- Added GitHub Copilot sign in on welcome screen
([#8851](https://github.com/zed-industries/zed/issues/8851)).
2024-03-04 14:38:28 -05:00
Andrew Lygin
d7b5c883fe Optimize project panel subscriptions (#8846)
The project panel now both observes all the project updates and
subscribes to project events it's interested in. The observing handler
updates the list of visible entries on any notification, which looks
pretty excessive.

This PR removes the observer completely, and adds missing event handlers
to the subscription, thus removing unnecessary work.

Release Notes:

- N/A
2024-03-04 20:56:17 +02:00
Marshall Bowers
78fa596839 Enable clippy::crate_in_macro_def (#8845)
This PR enables the
[`clippy::crate_in_macro_def`](https://rust-lang.github.io/rust-clippy/master/index.html#/crate_in_macro_def)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 13:37:23 -05:00
Marshall Bowers
1dd4c1b057 Enable clippy::redundant_closure_call (#8840)
This PR enables the
[`clippy::redundant_closure_call`](https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_closure_call)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 12:38:18 -05:00
Marshall Bowers
9ea50ed649 Enable clippy::iter_overeager_cloned (#8839)
This PR enables the
[`clippy::iter_overeager_cloned`](https://rust-lang.github.io/rust-clippy/master/index.html#/iter_overeager_cloned)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 12:22:11 -05:00
Thorsten Ball
9c6a0d98ed Set working directory for project to project path (#8837)
This fixes #8823 by setting the current working directory we use when
launching our own `prettier` process via `node` to the project path.

Why does this fix it?

We already *did* read the correct configuration options for `prettier`
from any configuration files, we also correctly inferred which
`prettier` plugins to use, but somehow when running

    ./node_modules/.bin/prettier my-file.tsx

produced different results compared to `prettier` in Zed.

But we *do* pass the right options to `prettier.format` when calling it
here:
996f1036fc/crates/prettier/src/prettier_server.js (L177-L190)

I checked those against the `prettier --loglevel=debug` output: they're
the same.

Turns out that the difference is we launch our `prettier_server.js` (a
JavaScript shim that wraps `prettier`-the-library in a language server
interface) not in the project path.

So somewhere inside `prettier.format` something is `require`d and fails
because we're not in that project directory. But when you run
`./node_modules/.bin/prettier` you are.

With the fix here, `prettier` now correctly picks up the tailwind plugin
that didn't seem to work in #8823. It probably fixes a bunch of other
oddities that folks reported with `prettier` too.



Release Notes:

- Fixed `prettier` integration not correctly picking up `prettier`
plugins, because it didn't run in the project's root path when invoked.
([#8823](https://github.com/zed-industries/zed/issues/8823)).
2024-03-04 18:06:55 +01:00
Christian Bergschneider
09760340ca linux: remove todo for credential implementation (#8834)
As commented
[here](https://github.com/zed-industries/zed/pull/8035#issuecomment-1976894590),
this is already done.



Release Notes:
- N/A
2024-03-04 08:57:56 -08:00
Marshall Bowers
12980dd88f Enable clippy::derivable_impls (#8836)
This PR enables the
[`clippy::derivable_impls`](https://rust-lang.github.io/rust-clippy/master/index.html#/derivable_impls)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 11:47:07 -05:00
Marshall Bowers
a860530a2e Assign OpenAI model based on Azure OpenAI deployment ID (#8835)
Following up on #8646, this PR makes it so we select an OpenAI model
based on the deployment ID when using Azure OpenAI.

Release Notes:

- N/A
2024-03-04 11:19:32 -05:00
Rom Grk
996f1036fc linux: clipboard (#8822)
Linux clipboard implementation with `copypasta`.


Release Notes:

- Added linux clipboard support
2024-03-04 08:00:24 -08:00
Marshall Bowers
33ef5b7731 Enable clippy::iter_kv_map (#8832)
This PR enables the
[`clippy::iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/iter_kv_map)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 10:54:33 -05:00
Marshall Bowers
16be391211 Enable clippy::needless_update (#8830)
This PR enables the
[`clippy::needless_update`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_update)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 10:35:07 -05:00
Thorben Kröger
94593dca4b clangd: download the correct binary on Linux (#8820)
Release Notes:

- Fixed clangd LSP download not working on Linux
2024-03-04 16:58:58 +02:00
Piotr Osiewicz
98a1e87fbe task: Spawn static tasks in separate shell (#8827)
That way one can use environment variables in task definitions.

Fixes: #8660

/cc @SomeoneToIgnore it looks like we don't ever set `separate_shell` to
false anymore, it might be worth streamlining?

Release Notes:

- Fixed static tasks not being run under a separate shell.
- Removed `separate_shell` setting from task definitions. It is now a default for tasks defined in tasks.json file.
2024-03-04 15:57:30 +01:00
Thorsten Ball
6121c286b7 Fix argument order when printing prettier debug info (#8826)
Release Notes:


- N/A
2024-03-04 15:37:50 +01:00
Rom Grk
c91969d828 linux/wayland: prevent possible panic (#8824)
Prevent a panic from arising from this case:
https://github.com/zed-industries/zed/pull/8632#discussion_r1510015928

It's not really safe to dispatch any action before dropping the state
borrow, because it may need to be modified.
2024-03-04 05:57:47 -08:00
Jason Lee
538298378a Return "open in new window" as default in recent projects (#8798)
https://github.com/zed-industries/zed/assets/5518/8bbd13a7-9144-48b0-9bc8-6651725476f8

Closes https://github.com/zed-industries/zed/issues/8651

Reworks `recent_projects::OpenRecent` action with collab projects in mind:
* keep the "open in new window" behavior for corresponding menu and command entries
* use new, "reuse current window" behavior in the recent projects picker up in the toolbar

This way, old Zed behavior is not customizable, kept as original in all main use cases — so that projects shared via remote entities: a channel and a call, are never accidentally closed, breaking the sharing. 

Release Notes:

- Return "open in new window" as default in recent projects
2024-03-04 11:42:30 +02:00
Ole Herman Schumacher Elgesem
3a184bbadd Docs: Made "Configuring Zed" a link (#8790)
Seems like this was intended to be a link (?). Easier to click it than
find the section in the navigation.



Release Notes:

- N/A
2024-03-04 09:54:29 +01:00
Stanislav Alekseev
38f106cde3 Add a fish-specific fix for #8633 (#8659)
Release Notes:
- Fixed detection of `direnv` not working in `fish` when an LSP adapter
(`gopls`, for example) tries to detect user-installed binaries. (#8633)

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-03-04 09:30:49 +01:00
Mikayla Maki
20acc123af Implement 'format without save' (#8806)
This solves a major usability problem in Zed, that there's no way to
temporarily disable auto formatting without toggling the whole feature
off.

fixes https://github.com/zed-industries/zed/issues/5230

Release Notes:

- Added a new `workspace::SaveWithoutFormatting`, bound to `cmd-k s`, to
save a file without invoking the auto formatter.
2024-03-03 21:47:34 -08:00
Niklas Wimmer
ff65008316 linux: add credentials impl via oo7 (#8035)
This change implements gpui's credentials API for the linux platform,
using the [`oo7`](https://lib.rs/crates/oo7) library.

We had a short discussion on Discord about where to store credentials
and landed on the two dbus APIs
[`org.freedesktop.Secrets`](https://specifications.freedesktop.org/secret-service/latest/index.html)
and
[`org.freedesktop.portal.Secrets`](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Secret.html).
The first one provides access to a more or less general purpose
keystore, the second provides a way of obtaining a unique masterkey
which in turn can be used for encrypting stuff and storing it to disk
(especially interesting for sandboxed apps, think flatpak/snap).

I decided to give the implementation a try with `oo7`, which uses the
portal if the app is sandboxed and the secret service otherwise. If we
do not want to use that library, we would probably have to more or less
copy its functionality anyways. I also heard rumors of eventually
changing the credentials API and I think this implementation serves as a
starting point to discuss the need for this?

With a working credentials implementation the sign in button now works
(it panicked before).

Todos:
- [x] implement keystore unlocking
- [x] try the change with oo7's tracing enabled?
- [x] test the password deletion

Release Notes:

- N/A

---------

Signed-off-by: Niklas Wimmer <mail@nwimmer.me>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-03 13:54:06 -08:00
feelamee
1442fcb497 Add doas support in script/linux (#8788)
Release Notes:
- n/a
2024-03-03 13:44:39 -08:00
feelamee
49f378ead3 Fix name of zstd package in Arch Linux repos (#8789)
Fixed name of [zstd](https://archlinux.org/packages/core/x86_64/zstd/)
package in Arch Linux repos in script for installing deps, required for
building Zed on linux

Release Notes:

- N/A
2024-03-03 13:26:09 -08:00
Mikayla Maki
0717d30389 Move windows up to workspace dependency (#8786)
This way we can keep track of what we're using.

Release Notes:

- N/A
2024-03-03 11:58:31 -08:00
Ezekiel Warren
36d9b3d483 windows: get pid with win32 api (#8785)
While trying to get mouse/keyboard support in for Windows I ran into a
stack overflow issue related to the pid being `-1`. Getting the proper
process ID seems to fix it.

Release Notes:

- Fixed stack overflow on Windows
2024-03-03 11:42:36 -08:00
Maharshi Basu
a5eab29662 Implement all_font_families for the LinuxTextSystem (#8331)
Implemented the function to get all font family names for
`LinuxTextSystem` which was previously kept as `unimplemented`.

Release Notes:

- N/A

Change Explanation:

- We get the
[`&Database`](https://docs.rs/fontdb/0.16.1/fontdb/struct.Database.html)
struct from the
[`FontSystem`](https://docs.rs/cosmic-text/latest/cosmic_text/struct.FontSystem.html)
by using the `.db` method.
- From the `Database` struct we get the
[`FaceInfo`](https://docs.rs/fontdb/0.16.1/fontdb/struct.FaceInfo.html)
which the provides a method to get the family
names([`families`](https://docs.rs/fontdb/0.16.1/fontdb/struct.FaceInfo.html#structfield.families))
- The `families` function returns a tuple of Vec. The tuple consists of
the `String` containing the name and the
[`Language`](https://docs.rs/fontdb/0.16.1/fontdb/enum.Language.html)
struct.

*It is noted that for the `families` function, the first family is
always `English US` unless it is unavailable*

Since the empty function provided
[here](https://github.com/zed-industries/zed/blob/main/crates/gpui/src/platform/linux/text_system.rs#L75)
explicitly declares a `Vec<String>` as the return type so I am
prioritizing the `English US` font family unless advised otherwise by
the reviewer.

---------

Signed-off-by: Maharshi Basu <basumaharshi10@gmail.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-03 11:28:53 -08:00
Joel Selvaraj
6a6dbe3aa1 linux: wayland: implement cursor style handling (#8632)
Release Notes:

- Implemented cursor style changing in wayland


[zed_cursor_wayland.webm](https://github.com/zed-industries/zed/assets/12579216/cbc03f85-41c1-4687-88b5-2aa5612d7129)

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-03-03 11:28:20 -08:00
aryal
37ffa86043 Add libzstd to script/linux (#8780)
add a missing dependency to linux script
2024-03-03 11:21:36 -08:00
Ömer Sinan Ağacan
9095a6b04e Replace todo calls with error values in linux/platform (#8531)
We currently use a mix of unimplemented methods with empty bodies and
`todo!()` calls in linux/platform.

`todo!()`s cause crashes in runtime with accidental key presses or
clicks.

To avoid this, this PR replaces `todo!()`s in linux/platform with error
values.

This helps when working on Zed itself, testing PRs etc.

Release Notes:

- N/A
2024-03-03 11:18:08 -08:00
白山風露
69e0474ebb Windows gpui platform (#8490)
First implementation of gpui platform for Windows.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-03 10:53:22 -08:00
Marshall Bowers
a88df2c103 Enable clippy::default_constructed_unit_structs (#8778)
This PR enables the
[`clippy::default_constructed_unit_structs`](https://rust-lang.github.io/rust-clippy/master/index.html#/default_constructed_unit_structs)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 12:07:53 -05:00
Marshall Bowers
53630dc74c Enable clippy::needless_lifetimes (#8777)
This PR enables the
[`clippy::needless_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_lifetimes)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 11:52:58 -05:00
Marshall Bowers
1fa9496334 Enable clippy::explicit_counter_loop (#8776)
This PR enables the
[`clippy::explicit_counter_loop`](https://rust-lang.github.io/rust-clippy/master/index.html#/explicit_counter_loop)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 11:40:22 -05:00
Jonathan
08f9c3f568 Accept partial copilot suggestions (#8682)
Fixes https://github.com/zed-industries/zed/issues/8020
 
This PR adds a new shortcut cmd-right, if a copilot suggestion exists.
The suggestions is accepted word by word.
It emulates the behaviour of VS Code's Github Copilot implementation.


Release Notes:

- Added ability to accept partial copilot suggestions ([8020](https://github.com/zed-industries/zed/issues/8020))
2024-03-03 18:24:48 +02:00
Marshall Bowers
56f0418c93 Enable clippy::needless_option_as_deref (#8775)
This PR enables the
[`clippy::needless_option_as_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_option_as_deref)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 11:16:27 -05:00
Marshall Bowers
2964a01d73 Enable clippy::identity_op (#8773)
This PR enables the
[`clippy::identity_op`](https://rust-lang.github.io/rust-clippy/master/index.html#/identity_op)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 11:05:08 -05:00
Marshall Bowers
83f6a1ea49 Enable clippy::vec_init_then_push (#8771)
This PR enables the
[`clippy::vec_init_then_push`](https://rust-lang.github.io/rust-clippy/master/index.html#/vec_init_then_push)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:53:23 -05:00
Marshall Bowers
6685d3ac97 Enable clippy::redundant_guards (#8770)
This PR enables the
[`clippy::redundant_guards`](https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_guards)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:43:13 -05:00
Marshall Bowers
bfc648553f Enable clippy::bool_comparison (#8769)
This PR enables the
[`clippy::bool_comparison`](https://rust-lang.github.io/rust-clippy/master/index.html#/bool_comparison)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:34:30 -05:00
Marshall Bowers
5fad319cb5 Enable clippy::expect_fun_call (#8768)
This PR enables the
[`clippy::expect_fun_call`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_fun_call)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:27:37 -05:00
Marshall Bowers
fe04f69caf Enable clippy::useless_conversion (#8767)
This PR enables the
[`clippy::useless_conversion`](https://rust-lang.github.io/rust-clippy/master/index.html#/useless_conversion)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:22:55 -05:00
geekvest
20d133322a Fix some comments (#8760)
Release Notes:

- N/A

Signed-off-by: geekvest <cuimoman@sohu.com>
2024-03-03 07:55:42 -05:00
Marshall Bowers
a6dbaac653 Enable clippy::needless_question_mark (#8759)
This PR enables the
[`clippy::needless_question_mark`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_question_mark)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 23:40:39 -05:00
Marshall Bowers
33790b81fc Enable clippy::useless_format (#8758)
This PR enables the
[`clippy::useless_format`](https://rust-lang.github.io/rust-clippy/master/index.html#/useless_format)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 23:31:58 -05:00
Marshall Bowers
373e18bc88 Enable clippy::unnecessary_unwrap (#8756)
This PR enables the
[`clippy::unnecessary_unwrap`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_unwrap)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 23:10:56 -05:00
Marshall Bowers
191fcf67d1 Enable clippy::nonminimal_bool (#8755)
This PR enables the
[`clippy::nonminimal_bool`](https://rust-lang.github.io/rust-clippy/master/index.html#/nonminimal_bool)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 22:57:37 -05:00
Marshall Bowers
2f876471a1 Enable clippy::extra_unused_lifetimes (#8754)
This PR enables the
[`clippy::extra_unused_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#/extra_unused_lifetimes)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 22:43:00 -05:00
Marshall Bowers
659974411d Enable clippy::explicit_auto_deref (#8753)
This PR enables the
[`clippy::explicit_auto_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#/explicit_auto_deref)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 22:30:18 -05:00
Marshall Bowers
6a9e8faad2 Enable clippy::unnecessary_operation (#8752)
This PR enables the
[`clippy::unnecessary_operation`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_operation)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 22:19:56 -05:00
Marshall Bowers
ea68f86476 Enable clippy::option_map_unit_fn (#8751)
This PR enables the
[`clippy::option_map_unit_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#/option_map_unit_fn)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 22:08:37 -05:00
Marshall Bowers
d19957b705 Enable clippy::redundant_locals (#8750)
This PR enables the
[`clippy::redundant_locals`](https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_locals)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:57:40 -05:00
Marshall Bowers
328c8a94b3 Enable clippy::search_is_some (#8748)
This PR enables the
[`clippy::search_is_some`](https://rust-lang.github.io/rust-clippy/master/index.html#/search_is_some)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:46:30 -05:00
Marshall Bowers
3ab16d8012 Enable clippy::option_as_ref_deref (#8747)
This PR enables the
[`clippy::option_as_ref_deref`](https://rust-lang.github.io/rust-clippy/master/index.html#/option_as_ref_deref)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:36:42 -05:00
Marshall Bowers
ca9d5a2f6b Enable clippy::needless_borrowed_reference (#8746)
This PR enables the
[`clippy::needless_borrowed_reference`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_borrowed_reference)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:24:56 -05:00
Marshall Bowers
bd00aed7db Enable clippy::drain_collect (#8745)
This PR enables the
[`clippy::drain_collect`](https://rust-lang.github.io/rust-clippy/master/index.html#/drain_collect)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:14:42 -05:00
Marshall Bowers
4097e8870b Enable clippy::needless_arbitrary_self_type (#8743)
This PR enables the
[`clippy::needless_arbitrary_self_type`](https://rust-lang.github.io/rust-clippy/master/index.html#/needless_arbitrary_self_type)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 21:04:49 -05:00
Marshall Bowers
008c5053e6 Enable clippy::unit_arg (#8742)
This PR enables the
[`clippy::unit_arg`](https://rust-lang.github.io/rust-clippy/master/index.html#/unit_arg)
rule and suppresses the false positive that it flags.

Release Notes:

- N/A
2024-03-02 20:59:41 -05:00
Marshall Bowers
2bfc646f33 Enable clippy::filter_map_identity (#8741)
This PR enables the
[`clippy::filter_map_identity`](https://rust-lang.github.io/rust-clippy/master/index.html#/filter_map_identity)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 20:48:29 -05:00
Marshall Bowers
3e287911c3 Enable clippy::unnecessary_find_map (#8740)
This PR enables the
[`clippy::unnecessary_find_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_find_map)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 20:39:03 -05:00
Marshall Bowers
503bebaacc Enable clippy::manual_flatten (#8739)
This PR enables the
[`clippy::manual_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#/manual_flatten)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 20:28:26 -05:00
Marshall Bowers
f79f56f8b4 Enable clippy::unnecessary_filter_map (#8738)
This PR enables the
[`clippy::unnecessary_filter_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_filter_map)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 20:16:54 -05:00
Marshall Bowers
a17c207217 Enable clippy::manual_find (#8737)
This PR enables the
[`clippy::manual_find`](https://rust-lang.github.io/rust-clippy/master/index.html#/manual_find)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 20:03:49 -05:00
Marshall Bowers
fc8e515fe8 Enable clippy::too_many_arguments (#8734)
This PR enables the
[`clippy::too_many_arguments`](https://rust-lang.github.io/rust-clippy/master/index.html#/too_many_arguments)
rule.

I opted to add `#[allow(clippy::too_many_arguments)]` on the individual
violations, as reworking them to take fewer arguments is a more involved
task.

Release Notes:

- N/A
2024-03-02 18:42:05 -05:00
Marshall Bowers
eaf2fbb21b Enable clippy::map_flatten (#8733)
This PR enables the
[`clippy::map_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#/map_flatten)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 18:24:22 -05:00
Marshall Bowers
8bc35c33c5 Enable clippy::to_string_in_format_args (#8732)
This PR enables the
[`clippy::to_string_in_format_args`](https://rust-lang.github.io/rust-clippy/master/index.html#/to_string_in_format_args)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 18:13:49 -05:00
Marshall Bowers
52052f342b Enable clippy::map_identity (#8731)
This PR enables the
[`clippy::map_identity`](https://rust-lang.github.io/rust-clippy/master/index.html#/map_identity)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 18:02:39 -05:00
Marshall Bowers
d7962aa2d3 Add license to Gleam extension (#8730)
This PR adds a license to the Gleam extension crate, since the bundling
script was unhappy that it didn't have one.

Since extensions like this one may ultimately live outside of Zed
itself, I went with the Apache 2.0 license.

Release Notes:

- N/A
2024-03-02 17:56:57 -05:00
Marshall Bowers
9735912965 Enable clippy::clone_on_copy (#8728)
This PR enables the
[`clippy::clone_on_copy`](https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_copy)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 17:37:48 -05:00
Marshall Bowers
5935681c5c Enable clippy::single_char_pattern (#8727)
This PR enables the
[`clippy::single_char_pattern`](https://rust-lang.github.io/rust-clippy/master/index.html#/single_char_pattern)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 17:04:59 -05:00
Marshall Bowers
12440d5e0d terminal: Make rgb_for_index take a u8 instead of a &u8 (#8726)
This PR makes the `rgb_for_index` take a `u8` instead of a `&u8`.

`u8` is `Copy` and is only 1 byte, so there really isn't any reason to
pass a reference to it.

Release Notes:

- N/A
2024-03-02 16:51:46 -05:00
Marshall Bowers
4b81b15cad Enable clippy::useless_conversion (#8724)
This PR enables the
[`clippy::useless_conversion`](https://rust-lang.github.io/rust-clippy/master/index.html#/useless_conversion)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 16:31:47 -05:00
Marshall Bowers
87efb75e53 Enable clippy::bind_instead_of_map (#8723)
This PR enables the
[`clippy::bind_instead_of_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/bind_instead_of_map)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-02 16:10:34 -05:00
Marshall Bowers
bf666af3a2 Deny all Clippy warnings (#8720)
This PR makes Clippy deny all warnings across the workspace.

We now enumerate all of the rules that have violations and temporarily
allow them, with the goal being to drive the list down over time.

On Windows we don't yet use `--deny warnings`, as the Windows build
still has some warnings.

Release Notes:

- N/A
2024-03-02 15:51:01 -05:00
Marshall Bowers
c9a509c805 Add cargo xtask clippy (#8722)
This PR sets up a `cargo xtask clippy` command for running `cargo
clippy` with our defined set of options.

The intent is to make this easier to manage as we start enabling more
Clippy rules.

Release Notes:

- N/A
2024-03-02 14:46:02 -05:00
Marshall Bowers
c19587d4e4 Fix Clippy warnings in util crate (#8721)
This PR fixes a number of Clippy warnings in the `util` crate.

Release Notes:

- N/A
2024-03-02 13:06:35 -05:00
Marshall Bowers
0ac203bde0 Fix Clippy warnings in client crate (#8719)
This PR fixes a number of Clippy warnings in the `client` crate.

Release Notes:

- N/A
2024-03-02 12:33:02 -05:00
Tommi Pisto
5de7492146 Add flex_wrap_* and content_* to GPUI (#8710)
Now with GPUI you can auto-layout something like this:

<img width="560" alt="Screenshot 2024-03-02 at 13 56 50"
src="https://github.com/zed-industries/zed/assets/226244/8ec4b683-dd7d-41f8-8b09-4be66ecec9a0">
2024-03-02 11:29:44 -05:00
Marshall Bowers
f9dc871422 Fix Clippy warnings in theme crate (#8715)
This PR fixes a number of Clippy warnings in the `theme` crate.

Release Notes:

- N/A
2024-03-02 11:11:08 -05:00
Zephaniah Ong
6fcd57ac53 Expose more errors from rust-analyzer on invalid Cargo.toml contents (#8356)
Release Notes:

- Fixed ([#7574](https://github.com/zed-industries/zed/issues/7574)).
2024-03-02 10:07:25 +02:00
Liam Murphy
0903062933 Fix unsafe precondition violation when building with nightly rustc (#8691)
Fixes #8658

Release Notes:

- N/A
2024-03-02 08:01:44 +01:00
Marshall Bowers
e5e6c7f09d Fix Clippy warnings in fuzzy crate (#8701)
This PR fixes a number of Clippy warnings in the `fuzzy` crate.

Release Notes:

- N/A
2024-03-02 01:02:34 -05:00
Marshall Bowers
ca2cda8d2a Remove unneeded 'static lifetimes on &strs in constants (#8698)
This PR removes unneeded `'static` lifetimes on `&str`s stored in
`const` declarations.

This addresses some Clippy lints about
[`redundant_static_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_static_lifetimes).

In item-level `const` declarations we can rely on lifetime elision and
use the default `'static` lifetime.

Note that associated constants still require an explicit `'static`
lifetime, as explained in
https://github.com/rust-lang/rust/issues/115010.

Release Notes:

- N/A
2024-03-02 00:40:49 -05:00
Marshall Bowers
5c2bd816ae Fix Clippy warnings in settings crate (#8700)
This PR fixes a number of Clippy warnings in the `settings` crate.

Release Notes:

- N/A
2024-03-02 00:29:29 -05:00
Marshall Bowers
26fdd149e1 Fix Clippy warnings in fs (#8696)
This PR fixes various Clippy warnings in the `fs` crate.

Release Notes:

- N/A
2024-03-01 23:22:22 -05:00
Marshall Bowers
486f0ae454 Remove expects when constructing Clickhouse client (#8697)
This PR removes the `expect`s when constructing the Clickhouse client
while still retaining the less-noisy behavior from before.

Release Notes:

- N/A
2024-03-01 23:10:02 -05:00
Marshall Bowers
cfe90c37fc Document release_channel crate (#8695)
This PR documents the `release_channel` crate.

Release Notes:

- N/A
2024-03-01 22:05:46 -05:00
Marshall Bowers
e3608af992 Use long flags in script/clippy for readability (#8694)
This PR modifies the `script/clippy` script to use long flags, as these
are better for readability.

Release Notes:

- N/A
2024-03-01 21:25:06 -05:00
Marshall Bowers
8c3ae8b264 Upgrade bitflags to v2.4.2 (#8693)
This PR upgrades our [`bitflags`](https://crates.io/crates/bitflags)
dependency to v2.4.2.

This also fixes an error that was seen when running `clippy`:

```
error: &-masking with zero
  --> crates/fsevent/src/fsevent.rs:19:1
   |
19 | / bitflags! {
20 | |   #[repr(C)]
21 | |   pub struct StreamFlags: u32 {
22 | |     const NONE = 0x00000000;
...  |
46 | |   }
47 | | }
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask
   = note: `#[deny(clippy::bad_bit_mask)]` on by default
   = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Fixes #8681.

Release Notes:

- N/A
2024-03-01 21:07:39 -05:00
Marshall Bowers
b2cc617886 Allow overriding player colors via experimental.theme_overrides (#8692)
This PR extends the `experimental.theme_overrides` to allow overriding
the player colors.

Release Notes:

- Added the ability to override player colors using
`experimenta.theme_overrides`.
2024-03-01 20:33:37 -05:00
Brian Donovan
a84a3c0ebe docs: Fix "it's" typos that should be "its" (#8690)
These all meant to use the possessive "its" rather than the contraction
of "it is".
2024-03-01 20:32:27 -05:00
aryal
03f18053bb Add Void Linux support to script/linux (#8664)
add support for the xbps package manager in the system library setup
script
2024-03-01 16:47:59 -08:00
Dzmitry Malyshau
26103e8bb9 Clean up and refactor X11 refresh loop (alternative) (#8655)
Associates every window with its own refresh event. Removes the use of
X11 present.
Alternative to #8592.
Instead of doing the rendering on idle and then involving a hack for
polling X11 events, this PR just tries to do the rendering inside the
main loop. This guarantees that we continue to poll for events after the
draw, and not get screwed by the driver talking to X11 via the same file
descriptor.

Release Notes:
- N/A
2024-03-01 16:43:24 -08:00
Kirill Bulatov
b7784d414a When clicking the checkbox, toggle open the LSP trace logs (#8689)
Before this change, enabling LSP trace checkbox closed the panel and
toggled the server logs on.
Now, the newly enabled trace logs are shown instead.

Release Notes:

- Improved LSP logs checkbox behavior
2024-03-02 02:03:30 +02:00
Max Brunsfeld
268fa1cbaf Add initial support for defining language server adapters in WebAssembly-based extensions (#8645)
This PR adds **internal** ability to run arbitrary language servers via
WebAssembly extensions. The functionality isn't exposed yet - we're just
landing this in this early state because there have been a lot of
changes to the `LspAdapter` trait, and other language server logic.

## Next steps

* Currently, wasm extensions can only define how to *install* and run a
language server, they can't yet implement the other LSP adapter methods,
such as formatting completion labels and workspace symbols.
* We don't have an automatic way to install or develop these types of
extensions
* We don't have a way to package these types of extensions in our
extensions repo, to make them available via our extensions API.
* The Rust extension API crate, `zed-extension-api` has not yet been
published to crates.io, because we still consider the API a work in
progress.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-01 16:00:55 -08:00
Ben Hamment
f3f2225a8e Improve Ruby Grammar for superclasses (#8544)
Release Notes:

- Improved Ruby grammar to allow targeting of super classes including
namespaces classes
2024-03-01 16:08:03 -07:00
Tim Havlicek
242f032d74 Fix documentation for use_system_clipboard (#8635)
Release Notes:

- Fixed documentation for vim.use_system_clipboard
2024-03-01 15:44:09 -07:00
Conrad Irwin
5523a510c5 Allow reconnect before disconnect (#8684)
Co-Authored-By: Max <max@zed.dev>



Release Notes:

- Improved handling of reconnections during calls

---------

Co-authored-by: Max <max@zed.dev>
2024-03-01 15:41:32 -07:00
Kirill Bulatov
3efb871cd4 Add a way to change what menu::Confirm does in the recent projects modal (#8688)
Follow-up of
https://github.com/zed-industries/zed/issues/8651#issuecomment-1973411072

Zed current default is still to reuse the current window, but now it's
possible to do
```json
"alt-cmd-o": [
  "projects::OpenRecent",
  {
    "create_new_window": true
  }
]
```
and change this.

menu::Secondary confirm does the action with opposite window creation
strategy.

Release Notes:

- Improved open recent projects flexibility: settings can change whether
`menu::Confirm` opens a new window or reuses the old one
2024-03-02 00:28:51 +02:00
Andrew Lygin
37f7957826 Setting to show/hide terminal title (#8559)
This PR adds settings for hiding title (breadcrumbs) from the terminal
toolbar. If the title is hidden, the toolbar disappears completely.

Example:

```json
"terminal": {
  "toolbar": {
    "title": true,
  }
}
```

[The PR that added the "toolbar"
setting](https://github.com/zed-industries/zed/pull/7338) didn't affect
toolbars of the terminals that are placed in the editor pane. This PR
fixes that.


Release Notes:

- Added support for configuring the terminal toolbar ([8125](https://github.com/zed-industries/zed/issues/8125))
2024-03-01 23:37:02 +02:00
Conrad Irwin
400fb12f7e Make collab quieter on startup (#8685)
Fix initialization of minio to happen on service start instead of
bootstrap,
don't log errors if extensions are empty or if clickhouse is disabled

Release Notes:

- N/A
2024-03-01 13:39:13 -07:00
Conrad Irwin
64460e492a Upload crashes to collab directly (#8649)
This lets us run rustc_demangle on the backtrace, which helps the Slack
view significantly.

We're also now uploading files to digital ocean's S3 equivalent (with a
1 month expiry) instead of to Slack.

This PR paves the way for (but does not yet implement) sending this data
to clickhouse too.

Release Notes:

- N/A
2024-03-01 13:23:44 -07:00
Kirill Bulatov
cdf702aeff Prompt to save files on recent project selection (#8673) 2024-03-01 18:48:06 +02:00
Marshall Bowers
91d1146d97 Replace lazy_static! with OnceLock in collab crate (#8677)
This PR replaces a `lazy_static!` usage in the `collab` crate with
`OnceLock` from the standard library.

This allows us to drop the `lazy_static` dependency from this crate.

Release Notes:

- N/A
2024-03-01 11:24:53 -05:00
Wind
9723ca95e3 Vim mode: make motion::EndOfLine works with times. (#8591)
Release Notes:

- Fixed `$` in Vim mode not taking a numeric argument (i.e. `2$` or
`4$`) ([#8007](https://github.com/zed-industries/zed/issues/8007)).

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-03-01 14:00:31 +01:00
Andrew Lygin
aeed9d0d8b Scroll project search results to the top (#8329)
Scroll project search results to the top after every new search.

Release Notes:

- Fixed autoscrolling of the project search results ([8237](https://github.com/zed-industries/zed/issues/8237))
2024-03-01 11:40:57 +02:00
Flo
d6492d091d Implement workspace_configuration for Dart LSP (#8568)
This PR addressed https://github.com/zed-industries/zed/issues/8558 and
allows the [Dart Client Workspace
Configuration](https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration).

Differing from the issue, the settings are used from the LSP settings
section, example:

```
{
 "lsp": {
    "dart": {
      "settings": {
        "lineLength": 200
      }
    }
  }
}
```

Note: this only works for the global settings (not folder specific)


Release Notes:

- Fixed missing client workspace configuration of Dart LSP. Those can
now be configured by setting `{"lsp": {"dart": { "settings: {
"your-settings-here": "here"} } }` in the Zed settings.
([#8858](https://github.com/zed-industries/zed/issues/8558)).
2024-03-01 10:22:43 +01:00
Spence
34de33ef72 Editor: Add shortcut to toggle line numbers (#8642)
Following #7665, I've added a keymap to quickly hide and show gutter
line numbers.

`ctrl-l` and `cmd-l` were taken, so I've bound it to `cmd-;`. 



https://github.com/zed-industries/zed/assets/138762/365d2a7c-b775-4486-8389-edafe59b2a87

Release notes:

- Added `editor: toggle line numbers` command and default keybindings
(`cmd-;` on macOS).

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-03-01 10:09:21 +01:00
Marshall Bowers
7f5aa1fca6 Replace lazy_static! with OnceLock in time_format crate (#8648)
This PR replaces a `lazy_static!` usage in the `time_format` crate with
`OnceLock` from the standard library.

This allows us to drop the `lazy_static` dependency from this crate.

Release Notes:

- N/A
2024-02-29 23:58:45 -05:00
Marshall Bowers
0d0ce95eae Replace lazy_static! with OnceLock in ai crate (#8647)
This PR replaces a `lazy_static!` usage in the `ai` crate with
`OnceLock` from the standard library.

This allows us to drop the `lazy_static` dependency from this crate.

Release Notes:

- N/A
2024-02-29 23:37:20 -05:00
Marshall Bowers
eb1ab69606 Wire up Azure OpenAI completion provider (#8646)
This PR wires up support for [Azure
OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview)
as an alternative AI provider in the assistant panel.

This can be configured using the following in the settings file:

```json
{
  "assistant": {
    "provider": {
      "type": "azure_openai",
      "api_url": "https://{your-resource-name}.openai.azure.com",
      "deployment_id": "gpt-4",
      "api_version": "2023-05-15"
    }
  },
}
```

You will need to deploy a model within Azure and update the settings
accordingly.

Release Notes:

- N/A
2024-02-29 22:01:33 -05:00
Nikita Orlov
7c1ef966f3 Zig outline view (#8122)
Release Notes:

- Added Zig outline view, related #7357 
- 
<img width="762" alt="image"
src="https://github.com/zed-industries/zed/assets/13052752/a879cd98-d5e0-446e-aaed-504528b99552">
2024-02-29 17:24:35 -08:00
Nathan Sobo
4cc4f08a53 Remove ! from todo!() in comments (#8643)
This practice makes it difficult to locate todo!s in my code when I'm
working. Let's take out the bang if we want to keep doing this.

Release Notes:

- N/A
2024-02-29 18:19:05 -07:00
Marshall Bowers
dab886f479 Stub out support for Azure OpenAI (#8624)
This PR stubs out support for [Azure
OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview)
within the `OpenAiCompletionProvider`.

It still requires some additional wiring so that it is accessible, but
the necessary hooks should be in place now.

Release Notes:

- N/A
2024-02-29 13:02:08 -05:00
Sai Gokula Krishnan
cbcd011a36 Improve matches on command palette (#8515)
Release Notes:

- Fixed consecutive spaces in command palette influencing selection.
#8184

Optionally, include screenshots / media showcasing your addition that
can be included in the release notes.



https://github.com/zed-industries/zed/assets/25414681/a4682247-f52c-4ab9-a32a-51ab5cf3dbcc
2024-02-29 18:31:13 +01:00
Conrad Irwin
b3b94e64ba Ensure panel and pane sizes are integral (#8619)
Fixes: #8050

For some reason that we didn't investigate, if you have view caching
enabled,
and you have non-integer sized bounds, and you are right aligning
things, the
co-ordinates can differ by +/- 1px when using the cached view.

The easiest fix for now is to just not do that.

Co-Authored-By: Antonio <as-cii@zed.dev>

Release Notes:

- Fixed the pane icons flickering
([#8050](https://github.com/zed-industries/zed/issues/8050)).

Co-authored-by: Antonio <as-cii@zed.dev>
2024-02-29 09:16:42 -07:00
Rajesh Malviya
db9cc42245 Support Sourcehut & Codeberg in permalinks (#8616)
Updates #5110 

Release Notes:

- Added support for repositories hosted on `git.sr.ht` (Sourcehut) and
`codeberg.org` to the `editor: copy permalink to line` and `editor: open
permalink to line` actions
([#5110](https://github.com/zed-industries/zed/issues/5110)).

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-02-29 11:13:37 -05:00
Marshall Bowers
faa6f979be Restore signature of build_permalink (#8609)
This PR restores the original signature of `build_permalink`, which
intentionally uses a params struct to avoid mixing up the various `&str`
params that could otherwise be accidentally provided in the wrong order
without being caught by the compiler.

Release Notes:

- N/A
2024-02-29 08:52:09 -05:00
Thorsten Ball
dc7befb884 Bind ctrl-w to DeleteToPreviousWordStart (#8606)
Even though I use Vim mode, I'd love to have this in the command
palette/fuzzy finder. It's an Emacs keybinding, but also supported by
macOS nearly everywhere.

Release Notes:

- N/A
2024-02-29 14:11:36 +01:00
Thorsten Ball
519655297a Support Bitbucket.org in permalinks (#8601)
This adds support for Bitbucket.org/Bitbucket Cloud repositories to the
`editor: copy permalink to line` and `editor: open permalink to line`
actions.

Fixes #5110.



Release Notes:

- Added support for repositories hosted on Bitbucket.org (Bitbucket
Cloud) to the `editor: copy permalink to line` and `editor: open
permalink to line` actions.
([#5110](https://github.com/zed-industries/zed/issues/5110)).
2024-02-29 14:11:30 +01:00
Jason Lee
47bcb305af Use Pointer cursor style on Recent Projects, VCS Menu. (#8595)
Release Notes:

- Improved to use `Pointer` style cursor on VCS and Recent Projects
menu.



https://github.com/zed-industries/zed/assets/5518/4f638c6a-00b8-4fa8-b469-4d3109827bc2
2024-02-29 12:27:56 +01:00
Kirill Bulatov
953bc5eee2 Fix post-merge issue from the old branch PR (#8590)
Follow-up of https://github.com/zed-industries/zed/pull/6924/files that
had old code in CI that worked, but fresh `main` had different code that
needed small changes.


Release Notes:

- N/A
2024-02-29 11:46:00 +02:00
Yangze Luo
c94852b843 Go to reference when there's only one (#6924)
Fixes #4796

- Improved Go To Definition usability when there's a single reference ([4796](https://github.com/zed-industries/zed/issues/4796))

---------

Co-authored-by: Kirill Bulatov <kirill@zed.com>
2024-02-29 11:11:16 +02:00
Thorsten Ball
81886a9baf Fix default Vim keybinds for GoTo(Type)DefinitionSplit (#8587)
Follow-up to #8574

Release Notes:

- N/A
2024-02-29 10:06:17 +01:00
Jason Lee
225dd0f9a0 Improve extensions UI detail (#8578)
Release Notes:

- Improved "Extensions" UI details to tidy layout, add border, add
placeholder to search input.


## Before


![SCR-20240229-fbk](https://github.com/zed-industries/zed/assets/5518/a62608e2-8f79-48fe-9e1c-87d6eb59ddc9)

## After


![SCR-20240229-fhz](https://github.com/zed-industries/zed/assets/5518/d5c97711-ff93-4944-8e23-39b60dda88fc)

![SCR-20240229-fg9](https://github.com/zed-industries/zed/assets/5518/a24ad839-3b69-4ca7-813f-00375a81a008)

![SCR-20240229-fbb](https://github.com/zed-industries/zed/assets/5518/ff45d6c3-93a3-431c-81f5-edc9e7aa68d6)

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-02-28 22:34:40 -05:00
Conrad Irwin
778b6fb27b Add OpenExcerptsSplit (#8574)
I would like to keep diagnostics open on one side, and process them on
the other.


Release Notes:

- Added `editor::OpenExcerptsSplit` (bound to `cmd-k enter`) to open the
selected excerpts in the adjacent pane
- vim: Added `ctrl-w d`, `ctrl-w shift-d` and `ctrl-w space` for
`editor::GoTo{,Type}Definition` and `editor::OpenExcerptsSplit`
2024-02-28 19:23:36 -07:00
Kirill Bulatov
b7429bf29d Added menu::UseSelectedQuery command that populates task modal query with the selected task name (#8572) 2024-02-29 02:20:43 +02:00
Conrad Irwin
9bd5ebb74b Revert "Introduce a new ToggleGraphicsProfiler command (#7607)" (#8567)
This reverts commit 0cebf68306.

Although this thing is very cool, it is a top source of crashes.

Example crash:
```
Segmentation fault: 11 on thread 26
  objc_retain +16
  invocation function for block in Overlay::onCommandBufferCommit(id<MTLCommandBuffer>) +60
  MTLDispatchListApply +52
```

Release Notes:

- Removed "Toggle Graphics Profiler" as it crashes too much.
2024-02-28 16:39:51 -07:00
Kirill Bulatov
ac30ded80e Allow .zed/tasks.json local configs (#8536)
![image](https://github.com/zed-industries/zed/assets/2690773/e1511777-b4ca-469e-8636-1e513b615368)

Follow-up of
https://github.com/zed-industries/zed/issues/7108#issuecomment-1960746397

Makes more clear where each task came from, auto (re)load
.zed/config.json changes, properly filtering out other worktree tasks.

Release Notes:

- Added local task configurations
2024-02-29 01:18:13 +02:00
Rom Grk
7f954cbbb8 linux: improve key translation (#8560)
This PR brings linux XKB key translation more in line with the macOS
logic, which fixes quite a few key bindings.
2024-02-28 15:13:02 -08:00
Rajas Paranjpe
c07237df33 Add other vkcube command to Linux docs (#8543)
Add other vkcube command to Linux docs

Release Notes: 

- N/A
2024-02-28 15:07:28 -08:00
hamza72x
387c161d8c Add libssl-dev for apt dependencies (#8512)
While building on Ubuntu (arm64). I had to manually install
`libssl-dev`.
Just added that in `script/linux`.
2024-02-28 15:06:11 -08:00
Roman
b76e0d997e Linux: Rewrite the event loop using calloop (#8314)
This PR unifies the event loop code for Wayland and X11. On Wayland,
blocking dispatch is now used. On X11, the invisible window is no longer
needed.

Release Notes:

- N/A

---------

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
Co-authored-by: Tadeo Kondrak <me@tadeo.ca>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
Co-authored-by: julia <julia@zed.dev>
2024-02-28 14:59:11 -08:00
Conrad Irwin
198dfe0097 Maybe make cherry-pick-bot better 2024-02-28 15:26:30 -07:00
Conrad Irwin
16eb17e2f8 Enable cherry-pick-bot (#8561)
You will now be able to say `/cherry-pick v0.123.x` to cherry-pick to a
different branch.

Release Notes:

- N/A
2024-02-28 15:19:16 -07:00
Conrad Irwin
014e6f66bb gpui: Don't impl IntoElement on () (#8555)
Although it's kinda cute, rust makes it too easy to accidentally return
() from a function.

/cc @nathansobo

Release Notes:

- N/A
2024-02-28 15:19:05 -07:00
Max Brunsfeld
9e4b3ce94c Avoid an unwrap when loading languages (#8562)
We couldn't reproduce the panic, but I believe it was possible when
uninstalling an extension while one if its grammars was still loading.

Release Notes:
- Fixed a crash that could happen when uninstalling a language extension
while its grammar was loading.

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-02-28 14:08:45 -08:00
Joseph T. Lyons
4a4ca2c3b8 Fix view release notes locally (#8553)
🤦‍♂️

Release Notes:

- N/A
2024-02-28 15:50:10 -05:00
Conrad Irwin
495de89747 Fix update notifications (#8554)
Fixes: #7597

Release Notes:

- Fixed update notifications
([#7597](https://github.com/zed-industries/zed/issues/7597)).
2024-02-28 13:43:54 -07:00
Conrad Irwin
6a3ac94eea Fix logic for view to send on Follow (#8549)
Before this we would erronously send no view in some cases.

Release Notes:

- N/A
2024-02-28 12:52:03 -07:00
Joseph T. Lyons
6e04c1f924 v0.126.x dev 2024-02-28 13:13:51 -05:00
Antonio Scandurra
57f5f128f3 Fix flickering cursor style when a pane was zoomed (#8546)
Release Notes:

- N/A

Co-authored-by: Max Brunsfeld <max@zed.dev>
2024-02-28 18:50:48 +01:00
Thorsten Ball
7efa8d079d Do not set rules by default for eslint (#8545)
Follow-up to and fix for #8537.

Turns out that if you set `rules: []` it doesn't mean "no matchers", but
it means "no rules". So let's not set a default here.

Release Notes:

- N/A, see #8537

Co-authored-by: Conrad <conrad@zed.dev>
2024-02-28 18:39:54 +01:00
Andrew Lygin
d0ffd51bb1 Optimize file finder subscriptions (#8343)
Fixes #7519 

Optimizes file finder subscriptions &mdash; it now only subscribes to
worktrees updates instead of all project updates.

Project panel could also be optimized this way, I guess.

Release Notes:

- Fix selection resets in the file finder during language server
startup ([7519](https://github.com/zed-industries/zed/issues/7519))
2024-02-28 19:02:21 +02:00
Antonio Scandurra
7aba9eb4b7 Introduce a short-term solution for flickering (#8542)
This uses bounds checking alone to determine hover state to avoid
flicker. It's a short-term solution because the rendering is incorrect.
We think this is better than flickering though and buys us some time as
we work on a more robust solution overall.

Release Notes:

- Fixed flickering when hovering.

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-02-28 17:57:20 +01:00
Hugo Urías
517ea734ee Add Coffeescript, Scala, FSharp, TCL and Nim icons and add SQL as "storage" (#8447)
I would like to add these file icons all from the source svgrepo.com and
with a size of 14x14. Also I've modified file_types.json in order to add
the file types and path to the image aswell as added SQL as a storage
type so it's linked to an icon.

Here is how these new changes would look like:
<img width="240" alt="Captura de pantalla 2024-02-26 a las 19 30 33"
src="https://github.com/zed-industries/zed/assets/93369643/73e50e4a-bfe8-4239-b919-280150051e36">

Release Notes:

- Added icons for Coffeescript, F#, Nim, Scala, and TCL files.
- Updated icon for SQL files.
2024-02-28 11:09:29 -05:00
Thorsten Ball
a52177fd39 Allow users to configure ESLint codeActionOnSave settings (#8537)
This fixes #8533 by allowing users to specify the settings that are
passed to ESLint on workspace initialization.

Example Zed `settings.json` to enable `fixAll` for eslint when
saving/formatting, but only for the `import/order` rule:

```json
{
  "languages": {
    "JavaScript": {
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  },
  "lsp": {
    "eslint": {
      "settings": {
        "codeActionOnSave": {
          "rules": ["import/order"]
        }
      }
    },
  }
}
```

The possible settings are described in the README of `vscode-eslint`
here:
https://github.com/Microsoft/vscode-eslint?tab=readme-ov-file#settings-options

- `eslint.codeActionsOnSave.enable` (default: `true`, config key in Zed:
`lsp.eslint.settings.codeActionOnSave.enable`)
- `eslint.codeActionsOnSave.mode` (default: not set by Zed, config key
in Zed: `lsp.eslint.settings.codeActionOnSave.mode`)
- `eslint.codeActionsOnSave.rules` (default: `[]`, config key in Zed:
`lsp.eslint.settings.codeActionOnSave.rules`)

Yes, in the readme it's plural: `codeActionsOnSave`, but since
`eslint-vscode` we're using this old release:


https://github.com/microsoft/vscode-eslint/releases/tag/release%2F2.2.20-Insider

We use the singular version:
https://github.com/microsoft/vscode-eslint/blob/release/2.2.20-Insider/server/src/eslintServer.ts#L461

Our schema looks like this:

```json
{
  "lsp": {
    "eslint": {
      "settings": {
        "codeActionOnSave": {
          "enable": true,
          "rules": ["import/order"],
          "mode": "all"
        }
      }
    },
  }
}
```

We should probably fix this and upgrade to the newest version of ESLint.

Release Notes:

- Added ability for users to configure settings for ESLint's
`codeActionOnSave`, e.g. specifying `rules` that should be respected
when also using `"code_actions_on_format": {"source.fixAll.eslint":
true}`. These settings can be passed to ESLint as part of the `"lsp"`
part of the Zed settings. Example: `{"lsp": {"eslint": {"settings":
{"codeActionOnSave": { "rules": ["import/order"] }}}}}`
([#8533](https://github.com/zed-industries/zed/issues/8533)).

Demo:


https://github.com/zed-industries/zed/assets/1185253/5c0cf900-9acb-4a70-b89d-49b6eeb6f0e4
2024-02-28 17:04:36 +01:00
Dedar Alam
893e55ff96 Downscale source file icons to 14x14 (#8521)
Update file icon size to 14 * 14
- css 
- bun 
- erlang 
- terraform 
- php 
- haskell

Release Notes:

- N/A
2024-02-28 11:04:27 -05:00
Thorsten Ball
f8959834c4 Add ability to run ESLint (and other non-primary language server) code actions on format (#8496)
This PR does two things to fix
https://github.com/zed-industries/zed/issues/4325:

1. It changes the way `code_actions_on_format` works to send the
possibly configured code actions to _all_ (and not just the primary)
languages servers. That means configured code actions can now be sent to
ESLint, tailwind, ... and other language servers.
2. It enables `codeActionsOnSave` by default for ESLint. That does
**not** mean that by default we will run something on save, but only
that we enable it for ESLint.

Users can then configure their Zed to run the `eslint` code action on
format. Example, for JavaScript:

```json
    {
      "languages": {
        "JavaScript": {
          "code_actions_on_format": {
            "source.fixAll.eslint": true
          }
        },
      }
    }
```

Release Notes:

- Added ability to run ESLint fixes when formatting a buffer. Code
actions configured in
[`code_actions_on_format`](https://zed.dev/docs/configuring-zed#code-actions-on-format)
are now being sent to _all_ language servers connected to a buffer, not
just the primary one. So if a user now sets `"code_actions_on_format": {
"source.fixAll.eslint": true }` in their Zed settings, the
`source.fixAll.eslint` code action will be sent to ESLint, which is not
a primary language server. Since the formatter (prettier, or external
commands, or another language server, ...) still runs, it's important
that these code actions and the formatter don't clash.
([#4325](https://github.com/zed-industries/zed/issues/4325)).

Demo:



https://github.com/zed-industries/zed/assets/1185253/9ef03ad5-1f5c-4d46-b72a-eef611e32f39
2024-02-28 13:55:20 +01:00
Kirill Bulatov
2e516261fe Add tests on inventory task sorting 2024-02-28 14:13:40 +02:00
Kirill Bulatov
ca092fb694 Move NumericPrefixWithSuffix into utils 2024-02-28 14:13:40 +02:00
Kirill Bulatov
96d9df073e Sort tasks modal entries by last used time 2024-02-28 14:13:40 +02:00
Thorsten Ball
9f7e625d37 Fix formatting of code in prettier crate (#8526)
Came across this code, saw lots of blue squiggly lines, saw a chance to
simplify the code a little bit and reduce indentation.

(Kinda ironic that I'm the one formatting the prettier code, right?)

Release Notes:

- N/A
2024-02-28 12:51:08 +01:00
590 changed files with 35039 additions and 16786 deletions

View File

@@ -10,3 +10,6 @@
# in one spot, that's going to trigger a rebuild of all of the artifacts. Using ci-config.toml we can define these overrides for CI in one spot and not worry about it.
[build]
rustflags = ["-D", "warnings"]
[alias]
xtask = "run --package xtask --"

View File

@@ -1,3 +1,6 @@
[build]
# v0 mangling scheme provides more detailed backtraces around closures
rustflags = ["-C", "symbol-mangling-version=v0"]
rustflags = ["-C", "symbol-mangling-version=v0", "--cfg", "tokio_unstable"]
[alias]
xtask = "run --package xtask --"

View File

@@ -32,9 +32,9 @@ body:
required: false
- type: textarea
attributes:
label: |
If applicable, attach your `~/Library/Logs/Zed/Zed.log` file to this issue.
label: If applicable, attach your `~/Library/Logs/Zed/Zed.log` file to this issue.
description: |
Drag Zed.log into the text input below.
If you only need the most recent lines, you can run the `zed: open log` command palette action to see the last 1000.
description: Drag Zed.log into the text input below
validations:
required: false

View File

@@ -31,9 +31,9 @@ body:
required: false
- type: textarea
attributes:
label: |
If applicable, attach your `~/Library/Logs/Zed/Zed.log` file to this issue.
label: If applicable, attach your `~/Library/Logs/Zed/Zed.log` file to this issue.
description: |
Drag Zed.log into the text input below.
If you only need the most recent lines, you can run the `zed: open log` command palette action to see the last 1000.
description: Drag Zed.log into the text input below
validations:
required: false

View File

@@ -1,16 +1,17 @@
blank_issues_enabled: false
contact_links:
- name: Language Request
url: https://github.com/zed-industries/extensions/issues/new?assignees=&labels=language&projects=&template=1_language_request.yml&title=%3Cname_of_language%3E
about: Request a language in the extensions repository
- name: Theme Request
url: https://github.com/zed-industries/extensions/issues/new?assignees=&labels=theme&projects=&template=0_theme_request.yml&title=%3Cname_of_theme%3E+theme
about: Request a theme in the extensions repository
- name: Top-Ranking Issues
url: https://github.com/zed-industries/zed/issues/5393
about: See an overview of the most popular Zed issues
- name: Platform Support
url: https://github.com/zed-industries/zed/issues/5391
about: A quick note on platform support
- name: Positive Feedback
url: https://github.com/zed-industries/zed/discussions/5397
about: A central location for kind words about Zed
- name: Language Request
url: https://github.com/zed-industries/extensions/issues/new?assignees=&labels=language&projects=&template=1_language_request.yml&title=%3Cname_of_language%3E
about: Request a language in the extensions repository
- name: Theme Request
url: https://github.com/zed-industries/extensions/issues/new?assignees=&labels=theme&projects=&template=0_theme_request.yml&title=%3Cname_of_theme%3E+theme
about: Request a theme in the extensions repository
- name: Top-Ranking Issues
url: https://github.com/zed-industries/zed/issues/5393
about: See an overview of the most popular Zed issues
- name: Platform Support
url: https://github.com/zed-industries/zed/issues/5391
about: A quick note on platform support
- name: Positive Feedback
url: https://github.com/zed-industries/zed/discussions/5397
about: A central location for kind words about Zed

2
.github/cherry-pick-bot.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
enabled: true
preservePullRequestTitle: true

View File

@@ -87,8 +87,7 @@ jobs:
submodules: "recursive"
- name: cargo clippy
shell: bash -euxo pipefail {0}
run: script/clippy
run: cargo xtask clippy
- name: Run tests
uses: ./.github/actions/run_tests
@@ -99,7 +98,7 @@ jobs:
- name: Build other binaries and features
run: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"
# todo!(linux): Actually run the tests
# todo(linux): Actually run the tests
linux_tests:
name: (Linux) Run Clippy and tests
runs-on: ubuntu-latest
@@ -120,13 +119,12 @@ jobs:
run: script/linux
- name: cargo clippy
shell: bash -euxo pipefail {0}
run: script/clippy
run: cargo xtask clippy
- name: Build Zed
run: cargo build -p zed
# todo!(windows): Actually run the tests
# todo(windows): Actually run the tests
windows_tests:
name: (Windows) Run Clippy and tests
runs-on: windows-latest
@@ -143,18 +141,17 @@ jobs:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo clippy
shell: bash -euxo pipefail {0}
run: script/clippy
run: cargo xtask clippy
- name: Build Zed
run: cargo build -p zed
bundle:
name: Bundle macOS app
bundle-mac:
name: Create a macOS bundle
runs-on:
- self-hosted
- bundle
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
needs: [macos_tests]
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
@@ -209,12 +206,12 @@ jobs:
- name: Generate license file
run: script/generate-licenses
- name: Create app bundle
run: script/bundle
- name: Create macOS app bundle
run: script/bundle-mac
- name: Upload app bundle to workflow run if main branch or specific label
uses: actions/upload-artifact@v3
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
uses: actions/upload-artifact@v4
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
with:
name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
path: target/release/Zed.dmg
@@ -229,3 +226,81 @@ jobs:
body: ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bundle-deb:
name: Create a *.deb Linux bundle
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
needs: [linux_tests]
env:
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
clean: false
submodules: "recursive"
- name: Cache dependencies
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Configure linux
shell: bash -euxo pipefail {0}
run: script/linux
- name: Determine version and release channel
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
set -eu
version=$(script/get-crate-version zed)
channel=$(cat crates/zed/RELEASE_CHANNEL)
echo "Publishing version: ${version} on release channel ${channel}"
echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
expected_tag_name=""
case ${channel} in
stable)
expected_tag_name="v${version}";;
preview)
expected_tag_name="v${version}-pre";;
nightly)
expected_tag_name="v${version}-nightly";;
*)
echo "can't publish a release on channel ${channel}"
exit 1;;
esac
if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
exit 1
fi
# TODO linux : Find a way to add licenses to the final bundle
# - name: Generate license file
# run: script/generate-licenses
- name: Create Linux *.deb bundle
run: script/bundle-linux
- name: Upload app bundle to workflow run if main branch or specific label
uses: actions/upload-artifact@v4
if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
with:
name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.deb
path: target/release/*.deb
# TODO linux : make it stable enough to be uploaded as a release
# - uses: softprops/action-gh-release@v1
# name: Upload app bundle to release
# if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
# with:
# draft: true
# prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
# files: target/release/Zed.dmg
# body: ""
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -28,8 +28,7 @@ jobs:
uses: ./.github/actions/check_style
- name: Run clippy
shell: bash -euxo pipefail {0}
run: script/clippy
run: cargo xtask clippy
tests:
name: Run tests
@@ -105,8 +104,12 @@ jobs:
set -eu
if [[ $GITHUB_REF_NAME = "collab-production" ]]; then
export ZED_KUBE_NAMESPACE=production
export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=10
export ZED_API_LOAD_BALANCER_SIZE_UNIT=2
elif [[ $GITHUB_REF_NAME = "collab-staging" ]]; then
export ZED_KUBE_NAMESPACE=staging
export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=1
export ZED_API_LOAD_BALANCER_SIZE_UNIT=1
else
echo "cowardly refusing to deploy from an unknown branch"
exit 1
@@ -121,11 +124,13 @@ jobs:
export ZED_IMAGE_ID="registry.digitalocean.com/zed/collab:${GITHUB_SHA}"
export ZED_SERVICE_NAME=collab
export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT
envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"
export ZED_SERVICE_NAME=api
export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_API_LOAD_BALANCER_SIZE_UNIT
envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"

View File

@@ -32,8 +32,7 @@ jobs:
uses: ./.github/actions/check_style
- name: Run clippy
shell: bash -euxo pipefail {0}
run: script/clippy
run: cargo xtask clippy
tests:
name: Run tests
if: github.repository_owner == 'zed-industries'
@@ -51,8 +50,8 @@ jobs:
- name: Run tests
uses: ./.github/actions/run_tests
bundle:
name: Bundle app
bundle-mac:
name: Create a macOS bundle
if: github.repository_owner == 'zed-industries'
runs-on:
- self-hosted
@@ -78,9 +77,6 @@ jobs:
clean: false
submodules: "recursive"
- name: Limit target directory size
run: script/clear-target-dir-if-larger-than 100
- name: Set release channel to nightly
run: |
set -eu
@@ -91,8 +87,50 @@ jobs:
- name: Generate license file
run: script/generate-licenses
- name: Create app bundle
run: script/bundle
- name: Create macOS app bundle
run: script/bundle-mac
- name: Upload Zed Nightly
run: script/upload-nightly
run: script/upload-nightly macos
bundle-deb:
name: Create a *.deb Linux bundle
if: github.repository_owner == 'zed-industries'
runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
needs: tests
env:
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
clean: false
submodules: "recursive"
- name: Cache dependencies
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Configure linux
shell: bash -euxo pipefail {0}
run: script/linux
- name: Set release channel to nightly
run: |
set -euo pipefail
version=$(git rev-parse --short HEAD)
echo "Publishing version: ${version} on release channel nightly"
echo "nightly" > crates/zed/RELEASE_CHANNEL
# TODO linux : find a way to add licenses to the final bundle
# - name: Generate license file
# run: script/generate-licenses
- name: Create Linux *.deb bundle
run: script/bundle-linux
- name: Upload Zed Nightly
run: script/upload-nightly linux-deb

2
.gitignore vendored
View File

@@ -10,6 +10,7 @@
/assets/*licenses.md
**/venv
.build
*.wasm
Packages
*.xcodeproj
xcuserdata/
@@ -22,3 +23,4 @@ DerivedData/
.pytest_cache
.venv
.blob_store
.vscode

1884
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,7 @@ members = [
"crates/diagnostics",
"crates/editor",
"crates/extension",
"crates/extension_api",
"crates/extensions_ui",
"crates/feature_flags",
"crates/feedback",
@@ -53,7 +54,6 @@ members = [
"crates/picker",
"crates/prettier",
"crates/project",
"crates/project_core",
"crates/project_panel",
"crates/project_symbols",
"crates/quick_action_bar",
@@ -89,8 +89,14 @@ members = [
"crates/vim",
"crates/welcome",
"crates/workspace",
"crates/worktree",
"crates/zed",
"crates/zed_actions",
"extensions/gleam",
"extensions/uiua",
"tooling/xtask",
]
default-members = ["crates/zed"]
resolver = "2"
@@ -102,6 +108,7 @@ assets = { path = "crates/assets" }
assistant = { path = "crates/assistant" }
audio = { path = "crates/audio" }
auto_update = { path = "crates/auto_update" }
base64 = "0.13"
breadcrumbs = { path = "crates/breadcrumbs" }
call = { path = "crates/call" }
channel = { path = "crates/channel" }
@@ -152,7 +159,7 @@ plugin = { path = "crates/plugin" }
plugin_macros = { path = "crates/plugin_macros" }
prettier = { path = "crates/prettier" }
project = { path = "crates/project" }
project_core = { path = "crates/project_core" }
worktree = { path = "crates/worktree" }
project_panel = { path = "crates/project_panel" }
project_symbols = { path = "crates/project_symbols" }
quick_action_bar = { path = "crates/quick_action_bar" }
@@ -191,33 +198,43 @@ zed_actions = { path = "crates/zed_actions" }
anyhow = "1.0.57"
async-compression = { version = "0.4", features = ["gzip", "futures-io"] }
async-fs = "1.6"
async-recursion = "1.0.0"
async-tar = "0.4.2"
async-trait = "0.1"
blade-graphics = { git = "https://github.com/kvark/blade", rev = "e9d93a4d41f3946a03ffb76136290d6ccf7f2b80" }
blade-macros = { git = "https://github.com/kvark/blade", rev = "e9d93a4d41f3946a03ffb76136290d6ccf7f2b80" }
bitflags = "2.4.2"
blade-graphics = { git = "https://github.com/kvark/blade", rev = "43721bf42d298b7cbee2195ee66f73a5f1c7b2fc" }
blade-macros = { git = "https://github.com/kvark/blade", rev = "43721bf42d298b7cbee2195ee66f73a5f1c7b2fc" }
blade-rwh = { package = "raw-window-handle", version = "0.5" }
cap-std = "2.0"
chrono = { version = "0.4", features = ["serde"] }
clap = "4.4"
clickhouse = { version = "0.11.6" }
ctor = "0.2.6"
core-foundation = { version = "0.9.3" }
core-foundation-sys = "0.8.6"
derive_more = "0.99.17"
emojis = "0.6.1"
env_logger = "0.9"
futures = "0.3"
futures-lite = "1.13"
git2 = { version = "0.15", default-features = false }
globset = "0.4"
hex = "0.4.3"
ignore = "0.4.22"
indoc = "1"
# We explicitly disable http2 support in isahc.
isahc = { version = "1.7.2", default-features = false, features = ["static-curl", "text-decoding"] }
isahc = { version = "1.7.2", default-features = false, features = [
"static-curl",
"text-decoding",
] }
itertools = "0.11.0"
lazy_static = "1.4.0"
linkify = "0.10.0"
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
ordered-float = "2.1.1"
palette = { version = "0.7.5", default-features = false, features = ["std"] }
parking_lot = "0.11.1"
parking_lot = "0.12.1"
profiling = "1"
postage = { version = "0.5", features = ["futures-traits"] }
pretty_assertions = "1.3.0"
@@ -233,18 +250,26 @@ semver = "1.0"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_derive = { version = "1.0", features = ["deserialize_in_place"] }
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
serde_json_lenient = { version = "0.1", features = ["preserve_order", "raw_value"] }
serde_json_lenient = { version = "0.1", features = [
"preserve_order",
"raw_value",
] }
serde_repr = "0.1"
sha2 = "0.10"
shellexpand = "2.1.0"
smallvec = { version = "1.6", features = ["union"] }
smol = "1.2"
strum = { version = "0.25.0", features = ["derive"] }
sysinfo = "0.29.10"
subtle = "2.5.0"
sysinfo = "0.30.7"
tempfile = "3.9.0"
thiserror = "1.0.29"
tiktoken-rs = "0.5.7"
time = { version = "0.3", features = ["serde", "serde-well-known", "formatting"] }
time = { version = "0.3", features = [
"serde",
"serde-well-known",
"formatting",
] }
toml = "0.8"
tower-http = "0.4.4"
tree-sitter = { version = "0.20", features = ["wasm"] }
@@ -261,7 +286,6 @@ tree-sitter-elixir = { git = "https://github.com/elixir-lang/tree-sitter-elixir"
tree-sitter-elm = { git = "https://github.com/elm-tooling/tree-sitter-elm", rev = "692c50c0b961364c40299e73c1306aecb5d20f40" }
tree-sitter-embedded-template = "0.20.0"
tree-sitter-erlang = "0.4.0"
tree-sitter-gitcommit = { git = "https://github.com/gbprod/tree-sitter-gitcommit" }
tree-sitter-gleam = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "58b7cac8fc14c92b0677c542610d8738c373fa81" }
tree-sitter-glsl = { git = "https://github.com/theHamsta/tree-sitter-glsl", rev = "2a56fb7bc8bb03a1892b4741279dd0a8758b7fb3" }
tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" }
@@ -269,6 +293,7 @@ tree-sitter-gomod = { git = "https://github.com/camdencheek/tree-sitter-go-mod"
tree-sitter-gowork = { git = "https://github.com/d1y/tree-sitter-go-work" }
tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "8a99848fc734f9c4ea523b3f2a07df133cbbcec2" }
tree-sitter-hcl = { git = "https://github.com/MichaHoffmann/tree-sitter-hcl", rev = "v1.1.0" }
rustc-demangle = "0.1.23"
tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }
tree-sitter-html = "0.19.0"
tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "40a81c01a40ac48744e0c8ccabbaba1920441199" }
@@ -289,17 +314,45 @@ tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev =
tree-sitter-svelte = { git = "https://github.com/Himujjal/tree-sitter-svelte", rev = "bd60db7d3d06f89b6ec3b287c9a6e9190b5564bd" }
tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }
tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }
tree-sitter-uiua = { git = "https://github.com/shnarazk/tree-sitter-uiua", rev = "21dc2db39494585bf29a3f86d5add6e9d11a22ba" }
tree-sitter-vue = { git = "https://github.com/zed-industries/tree-sitter-vue", rev = "6608d9d60c386f19d80af7d8132322fa11199c42" }
tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "f545a41f57502e1b5ddf2a6668896c1b0620f930" }
tree-sitter-zig = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "0d08703e4c3f426ec61695d7617415fff97029bd" }
unindent = "0.1.7"
unicase = "2.6"
url = "2.2"
uuid = { version = "1.1.2", features = ["v4"] }
wasmtime = "18.0"
wasmparser = "0.121"
wasm-encoder = "0.41"
wasmtime = { version = "18.0", default-features = false, features = ["async", "demangle", "runtime", "cranelift", "component-model"] }
wasmtime-wasi = "18.0"
which = "6.0.0"
wit-component = "0.20"
sys-locale = "0.3.1"
[workspace.dependencies.windows]
version = "0.53.0"
features = [
"implement",
"Wdk_System_SystemServices",
"Win32_Graphics_Gdi",
"Win32_Graphics_DirectComposition",
"Win32_UI_Controls",
"Win32_UI_WindowsAndMessaging",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_Shell",
"Win32_System_Com",
"Win32_System_SystemInformation",
"Win32_System_SystemServices",
"Win32_System_Time",
"Win32_Security",
"Win32_System_Com",
"Win32_System_Com_StructuredStorage",
"Win32_System_Threading",
"Win32_System_DataExchange",
"Win32_System_Ole",
"Win32_System_Com",
]
[patch.crates-io]
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "e4a23971ec3071a09c1e84816954c98f96e98e52" }
# Workaround for a broken nightly build of gpui: See #7644 and revisit once 0.5.3 is released.
@@ -309,7 +362,7 @@ pathfinder_simd = { git = "https://github.com/servo/pathfinder.git", rev = "e4fc
split-debuginfo = "unpacked"
debug = "limited"
# todo!(linux) - Remove this
# todo(linux) - Remove this
[profile.dev.package.blade-graphics]
split-debuginfo = "off"
debug = "full"
@@ -317,6 +370,8 @@ debug = "full"
[profile.dev.package]
taffy = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
rustybuzz = { opt-level = 3 }
ttf-parser = { opt-level = 3 }
wasmtime-cranelift = { opt-level = 3 }
[profile.release]
@@ -324,5 +379,40 @@ debug = "limited"
lto = "thin"
codegen-units = 1
[workspace.lints.clippy]
dbg_macro = "deny"
todo = "deny"
# These are all of the rules that currently have violations in the Zed
# codebase.
#
# We'll want to drive this list down by either:
# 1. fixing violations of the rule and begin enforcing it
# 2. deciding we want to allow the rule permanently, at which point
# we should codify that separately above.
#
# This list shouldn't be added to; it should only get shorter.
# =============================================================================
# There are a bunch of rules currently failing in the `style` group, so
# allow all of those, for now.
style = "allow"
# Individual rules that have violations in the codebase:
almost_complete_range = "allow"
arc_with_non_send_sync = "allow"
await_holding_lock = "allow"
borrowed_box = "allow"
derive_ord_xor_partial_ord = "allow"
eq_op = "allow"
let_underscore_future = "allow"
map_entry = "allow"
never_loop = "allow"
non_canonical_clone_impl = "allow"
non_canonical_partial_ord_impl = "allow"
reversed_empty_ranges = "allow"
single_range_in_vec_init = "allow"
type_complexity = "allow"
[workspace.metadata.cargo-machete]
ignored = ["bindgen", "cbindgen", "prost_build", "serde"]

View File

@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1.2
FROM rust:1.76-bullseye as builder
FROM rust:1.76-bookworm as builder
WORKDIR app
COPY . .
@@ -20,9 +20,10 @@ RUN --mount=type=cache,target=./target \
cp /app/target/release/collab /app/collab
# Copy collab server binary to the runtime image
FROM debian:bullseye-slim as runtime
FROM debian:bookworm-slim as runtime
RUN apt-get update; \
apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates
apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates \
linux-perf binutils
WORKDIR app
COPY --from=builder /app/collab /app/collab
COPY --from=builder /app/crates/collab/migrations /app/migrations

View File

@@ -1,3 +1,3 @@
collab: RUST_LOG=${RUST_LOG:-warn,tower_http=info,collab=info} cargo run --package=collab serve
livekit: livekit-server --dev
blob_store: MINIO_ROOT_USER=the-blob-store-access-key MINIO_ROOT_PASSWORD=the-blob-store-secret-key minio server .blob_store
blob_store: ./script/run-local-minio

View File

@@ -10,7 +10,7 @@ You can [download](https://zed.dev/download) Zed today for macOS (v10.15+).
Support for additional platforms is on our [roadmap](https://zed.dev/roadmap):
- Linux ([tracking issue](https://github.com/zed-industries/zed/issues/5395))
- Linux ([tracking issue](https://github.com/zed-industries/zed/issues/7015))
- Windows ([tracking issue](https://github.com/zed-industries/zed/issues/5394))
- Web ([tracking issue](https://github.com/zed-industries/zed/issues/5396))
@@ -23,6 +23,7 @@ brew install zed
- [Building Zed for macOS](./docs/src/developing_zed__building_zed_macos.md)
- [Building Zed for Linux](./docs/src/developing_zed__building_zed_linux.md)
- [Building Zed for Windows](./docs/src/developing_zed__building_zed_windows.md)
- [Running Collaboration Locally](./docs/src/developing_zed__local_collaboration.md)
## Contributing

View File

@@ -1,3 +1,6 @@
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M12 22.596c6.628 0 12-4.338 12-9.688 0-3.318-2.057-6.248-5.219-7.986-1.286-.715-2.297-1.357-3.139-1.89C14.058 2.025 13.08 1.404 12 1.404c-1.097 0-2.334.785-3.966 1.821a49.92 49.92 0 0 1-2.816 1.697C2.057 6.66 0 9.59 0 12.908c0 5.35 5.372 9.687 12 9.687v.001ZM10.599 4.715c.334-.759.503-1.58.498-2.409 0-.145.202-.187.23-.029.658 2.783-.902 4.162-2.057 4.624-.124.048-.199-.121-.103-.209a5.763 5.763 0 0 0 1.432-1.977Zm2.058-.102a5.82 5.82 0 0 0-.782-2.306v-.016c-.069-.123.086-.263.185-.172 1.962 2.111 1.307 4.067.556 5.051-.082.103-.23-.003-.189-.126a5.85 5.85 0 0 0 .23-2.431Zm1.776-.561a5.727 5.727 0 0 0-1.612-1.806v-.014c-.112-.085-.024-.274.114-.218 2.595 1.087 2.774 3.18 2.459 4.407a.116.116 0 0 1-.049.071.11.11 0 0 1-.153-.026.122.122 0 0 1-.022-.083 5.891 5.891 0 0 0-.737-2.331Zm-5.087.561c-.617.546-1.282.76-2.063 1-.117 0-.195-.078-.156-.181 1.752-.909 2.376-1.649 2.999-2.778 0 0 .155-.118.188.085 0 .304-.349 1.329-.968 1.874Zm4.945 11.237a2.957 2.957 0 0 1-.937 1.553c-.346.346-.8.565-1.286.62a2.178 2.178 0 0 1-1.327-.62 2.955 2.955 0 0 1-.925-1.553.244.244 0 0 1 .064-.198.234.234 0 0 1 .193-.069h3.965a.226.226 0 0 1 .19.07c.05.053.073.125.063.197Zm-5.458-2.176a1.862 1.862 0 0 1-2.384-.245 1.98 1.98 0 0 1-.233-2.447c.207-.319.503-.566.848-.713a1.84 1.84 0 0 1 1.092-.11c.366.075.703.261.967.531a1.98 1.98 0 0 1 .408 2.114 1.931 1.931 0 0 1-.698.869v.001Zm8.495.005a1.86 1.86 0 0 1-2.381-.253 1.964 1.964 0 0 1-.547-1.366c0-.384.11-.76.32-1.079.207-.319.503-.567.849-.713a1.844 1.844 0 0 1 1.093-.108c.367.076.704.262.968.534a1.98 1.98 0 0 1 .4 2.117 1.932 1.932 0 0 1-.702.868Z"/>
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 7 13.179688 C 10.867188 13.179688 14 10.652344 14 7.53125 C 14 5.59375 12.800781 3.886719 10.957031 2.871094 C 10.207031 2.453125 9.617188 2.078125 9.125 1.769531 C 8.199219 1.179688 7.628906 0.820312 7 0.820312 C 6.359375 0.820312 5.636719 1.277344 4.6875 1.882812 C 4.148438 2.230469 3.601562 2.558594 3.042969 2.871094 C 1.199219 3.886719 0 5.59375 0 7.53125 C 0 10.652344 3.132812 13.179688 7 13.179688 Z M 6.183594 2.75 C 6.378906 2.308594 6.476562 1.828125 6.472656 1.34375 C 6.472656 1.261719 6.589844 1.234375 6.605469 1.328125 C 6.992188 2.953125 6.082031 3.757812 5.40625 4.027344 C 5.335938 4.054688 5.292969 3.953125 5.347656 3.902344 C 5.703125 3.582031 5.988281 3.191406 6.183594 2.75 Z M 7.382812 2.691406 C 7.328125 2.214844 7.171875 1.757812 6.925781 1.347656 L 6.925781 1.335938 C 6.886719 1.265625 6.976562 1.183594 7.035156 1.234375 C 8.179688 2.46875 7.796875 3.609375 7.359375 4.183594 C 7.3125 4.242188 7.226562 4.179688 7.25 4.109375 C 7.394531 3.652344 7.4375 3.167969 7.382812 2.691406 Z M 8.417969 2.363281 C 8.183594 1.949219 7.863281 1.589844 7.480469 1.308594 L 7.480469 1.300781 C 7.414062 1.253906 7.464844 1.140625 7.546875 1.175781 C 9.058594 1.808594 9.164062 3.03125 8.980469 3.746094 C 8.976562 3.761719 8.964844 3.777344 8.953125 3.785156 C 8.921875 3.808594 8.882812 3.800781 8.863281 3.773438 C 8.851562 3.757812 8.847656 3.742188 8.847656 3.722656 C 8.800781 3.246094 8.65625 2.78125 8.417969 2.363281 Z M 5.453125 2.691406 C 5.09375 3.007812 4.703125 3.132812 4.25 3.273438 C 4.179688 3.273438 4.132812 3.230469 4.15625 3.167969 C 5.179688 2.636719 5.542969 2.207031 5.90625 1.546875 C 5.90625 1.546875 5.996094 1.480469 6.015625 1.597656 C 6.015625 1.773438 5.8125 2.371094 5.453125 2.691406 Z M 8.335938 9.246094 C 8.253906 9.597656 8.0625 9.914062 7.789062 10.152344 C 7.589844 10.355469 7.324219 10.480469 7.039062 10.511719 C 6.746094 10.484375 6.472656 10.359375 6.265625 10.152344 C 5.996094 9.914062 5.808594 9.597656 5.726562 9.246094 C 5.71875 9.203125 5.734375 9.160156 5.761719 9.128906 C 5.792969 9.101562 5.835938 9.085938 5.875 9.089844 L 8.1875 9.089844 C 8.230469 9.085938 8.269531 9.101562 8.300781 9.132812 C 8.328125 9.160156 8.34375 9.203125 8.335938 9.246094 Z M 5.152344 7.976562 C 4.714844 8.273438 4.128906 8.210938 3.761719 7.832031 C 3.390625 7.445312 3.335938 6.855469 3.625 6.40625 C 3.746094 6.21875 3.917969 6.074219 4.121094 5.992188 C 4.320312 5.90625 4.542969 5.882812 4.757812 5.925781 C 4.972656 5.96875 5.167969 6.078125 5.320312 6.234375 C 5.636719 6.5625 5.730469 7.046875 5.558594 7.46875 C 5.476562 7.675781 5.335938 7.851562 5.152344 7.976562 Z M 10.109375 7.980469 C 9.671875 8.273438 9.085938 8.210938 8.71875 7.832031 C 8.511719 7.617188 8.398438 7.332031 8.398438 7.035156 C 8.398438 6.8125 8.464844 6.589844 8.585938 6.40625 C 8.707031 6.21875 8.878906 6.074219 9.082031 5.988281 C 9.28125 5.90625 9.503906 5.882812 9.71875 5.925781 C 9.933594 5.972656 10.128906 6.078125 10.285156 6.238281 C 10.597656 6.566406 10.691406 7.050781 10.515625 7.472656 C 10.433594 7.679688 10.292969 7.855469 10.109375 7.980469 Z M 10.109375 7.980469 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -1,4 +1,6 @@
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M24.235 6.519l-16.47-0.004 0.266 3.277 12.653 0.002-0.319 3.394h-8.298l0.3 3.215h7.725l-0.457 4.403-3.636 1.005-3.694-1.012-0.235-2.637h-3.262l0.362 4.817 6.829 2.128 6.714-1.912 1.521-16.675zM2.879 1.004h26.242l-2.387 26.946-10.763 3.045-10.703-3.047z"></path>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 10.601562 2.851562 L 3.398438 2.851562 L 3.511719 4.285156 L 9.050781 4.285156 L 8.910156 5.769531 L 5.28125 5.769531 L 5.410156 7.175781 L 8.789062 7.175781 L 8.589844 9.101562 L 7 9.542969 L 5.382812 9.097656 L 5.28125 7.945312 L 3.851562 7.945312 L 4.011719 10.054688 L 7 10.984375 L 9.9375 10.148438 Z M 1.257812 0.4375 L 12.742188 0.4375 L 11.695312 12.226562 L 6.988281 13.558594 L 2.304688 12.226562 Z M 1.257812 0.4375 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 730 B

View File

@@ -1 +1,12 @@
<svg height="64" viewBox="0 0 128 128" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="0" x2="128" y1="128" y2="0"><stop offset="0" stop-color="#333"/><stop offset="1" stop-color="#5d5d5d"/></linearGradient><path d="m12.239265 30.664279h14.960911c-5.59432 5.460938-7.654216 10.692785-10.342106 18.023379-3.200764 8.729348-.549141 29.987457 3.815534 37.55289 2.943384 5.101853 6.282685 8.994876 8.233522 11.095173h-16.667861zm89.614855 0h13.90661v66.671442h-13.55518c1.31391-1.750328 3.43934-4.534454 5.12085-6.426163 2.32782-2.618784 4.97023-6.978412 4.97023-6.978412l-16.015202-8.133112s-5.48977 11.600331-15.964999 15.964998c-10.475214 4.364666-19.784679-.838179-25.604243-7.530659-5.819578-6.692502-5.82371-22.14014-5.82371-22.14014h60.797524c1.16391-14.839892-2.63216-21.249816-4.66901-25.90547-.91799-2.098266-1.89261-3.810819-3.16287-5.522484zm-38.356164 1.757154c.35429-.01632.731685-.0092 1.104497 0 11.930114.290977 13.053143 12.802122 13.053143 12.802122h-27.311192s2.170772-12.298638 13.153552-12.802122z" fill="url(#a)"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<defs>
<linearGradient id="linear0" gradientUnits="userSpaceOnUse" x1="0" y1="128" x2="128" y2="0" gradientTransform="matrix(0.109375,0,0,0.109375,0,0)">
<stop offset="0" style="stop-color:rgb(20%,20%,20%);stop-opacity:1;"/>
<stop offset="1" style="stop-color:rgb(36.470588%,36.470588%,36.470588%);stop-opacity:1;"/>
</linearGradient>
</defs>
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:url(#linear0);" d="M 1.339844 3.355469 L 2.976562 3.355469 C 2.363281 3.953125 2.136719 4.523438 1.84375 5.324219 C 1.492188 6.28125 1.785156 8.605469 2.261719 9.433594 C 2.582031 9.992188 2.949219 10.417969 3.160156 10.644531 L 1.339844 10.644531 Z M 11.140625 3.355469 L 12.660156 3.355469 L 12.660156 10.644531 L 11.179688 10.644531 C 11.324219 10.453125 11.554688 10.148438 11.738281 9.941406 C 11.992188 9.65625 12.28125 9.179688 12.28125 9.179688 L 10.53125 8.289062 C 10.53125 8.289062 9.929688 9.558594 8.785156 10.035156 C 7.640625 10.515625 6.621094 9.945312 5.984375 9.214844 C 5.347656 8.480469 5.347656 6.792969 5.347656 6.792969 L 11.996094 6.792969 C 12.125 5.167969 11.710938 4.46875 11.484375 3.957031 C 11.386719 3.726562 11.277344 3.542969 11.140625 3.355469 Z M 6.945312 3.546875 C 6.984375 3.542969 7.023438 3.546875 7.066406 3.546875 C 8.371094 3.578125 8.492188 4.945312 8.492188 4.945312 L 5.507812 4.945312 C 5.507812 4.945312 5.742188 3.601562 6.945312 3.546875 Z M 6.945312 3.546875 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -27,6 +27,7 @@
"css": "css",
"csv": "storage",
"cts": "typescript",
"coffee": "coffeescript",
"dart": "dart",
"dat": "storage",
"db": "storage",
@@ -48,6 +49,7 @@
"fmp": "storage",
"fp7": "storage",
"frm": "storage",
"fs": "fsharp",
"gdb": "storage",
"gif": "image",
"gitattributes": "vcs",
@@ -104,6 +106,7 @@
"myd": "storage",
"myi": "storage",
"nu": "terminal",
"nim": "nim",
"odp": "document",
"ods": "document",
"odt": "document",
@@ -138,6 +141,9 @@
"sqlite": "storage",
"svelte": "template",
"svg": "image",
"sc": "scala",
"scala": "scala",
"sql": "storage",
"swift": "swift",
"tf": "terraform",
"tfvars": "terraform",
@@ -148,6 +154,7 @@
"ttf": "font",
"tsx": "code",
"txt": "document",
"tcl": "tcl",
"vue": "vue",
"wav": "audio",
"webm": "video",
@@ -189,6 +196,9 @@
"css": {
"icon": "icons/file_icons/css.svg"
},
"coffeescript": {
"icon": "icons/file_icons/coffeescript.svg"
},
"dart": {
"icon": "icons/file_icons/dart.svg"
},
@@ -222,6 +232,9 @@
"font": {
"icon": "icons/file_icons/font.svg"
},
"fsharp": {
"icon": "icons/file_icons/fsharp.svg"
},
"haskell": {
"icon": "icons/file_icons/haskell.svg"
},
@@ -258,6 +271,9 @@
"ocaml": {
"icon": "icons/file_icons/ocaml.svg"
},
"nim": {
"icon": "icons/file_icons/nim.svg"
},
"phoenix": {
"icon": "icons/file_icons/phoenix.svg"
},
@@ -288,6 +304,9 @@
"storage": {
"icon": "icons/file_icons/database.svg"
},
"scala": {
"icon": "icons/file_icons/scala.svg"
},
"swift": {
"icon": "icons/file_icons/swift.svg"
},
@@ -306,6 +325,9 @@
"typescript": {
"icon": "icons/file_icons/typescript.svg"
},
"tcl": {
"icon": "icons/file_icons/tcl.svg"
},
"vcs": {
"icon": "icons/file_icons/git.svg"
},

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 3.324219 3.496094 C 1.507812 5.40625 0.0273438 6.984375 0.0273438 6.996094 C 0.0273438 7.015625 1.511719 8.59375 3.332031 10.503906 L 6.632812 13.980469 L 6.632812 10.472656 L 4.984375 8.734375 L 3.332031 6.996094 L 4.984375 5.257812 L 6.632812 3.519531 L 6.628906 1.773438 L 6.621094 0.0273438 Z M 3.324219 3.496094 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 7.125 1.773438 L 7.125 3.492188 L 8.769531 5.222656 C 9.675781 6.171875 10.421875 6.96875 10.425781 6.984375 C 10.433594 7.003906 9.691406 7.800781 8.78125 8.761719 L 7.125 10.503906 L 7.125 13.972656 L 7.214844 13.890625 C 7.296875 13.820312 8.203125 12.90625 9.167969 11.910156 C 9.398438 11.671875 9.605469 11.464844 9.621094 11.449219 C 9.671875 11.402344 11.261719 9.789062 11.601562 9.4375 C 11.773438 9.261719 11.957031 9.082031 12 9.035156 C 12.046875 8.988281 12.433594 8.59375 12.863281 8.160156 C 13.289062 7.726562 13.722656 7.289062 13.824219 7.183594 L 14.007812 6.996094 L 13.808594 6.796875 C 13.179688 6.167969 12.527344 5.503906 11.820312 4.785156 C 11.574219 4.53125 11.105469 4.058594 10.785156 3.734375 C 10.460938 3.414062 9.871094 2.8125 9.472656 2.402344 C 9.074219 1.996094 8.609375 1.515625 8.4375 1.339844 C 8.265625 1.160156 7.910156 0.800781 7.652344 0.539062 C 7.394531 0.273438 7.167969 0.0585938 7.15625 0.0585938 C 7.132812 0.0585938 7.125 0.59375 7.125 1.773438 Z M 7.125 1.773438 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 5.453125 5.757812 C 4.308594 6.964844 4.285156 6.992188 4.332031 7.050781 C 4.359375 7.082031 4.886719 7.636719 5.5 8.289062 L 6.621094 9.464844 L 6.628906 8.222656 C 6.632812 7.539062 6.632812 6.429688 6.628906 5.753906 L 6.621094 4.527344 Z M 5.453125 5.757812 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 32 32"
version="1.1"
id="svg977"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs981" />
<path
id="path973"
d="M 10.699219 8.9003906 L 10.699219 9 C 12.199219 11.3 13.800781 13.600391 15.300781 15.900391 L 15.300781 16 C 13.800781 18.3 12.199219 20.600391 10.699219 22.900391 L 10.699219 23 L 14.199219 23 L 14.300781 22.900391 C 15.200781 21.500391 16.199609 20.099219 17.099609 18.699219 C 17.199609 18.599219 17.099219 18.599219 17.199219 18.699219 C 18.099219 20.099219 19.1 21.500391 20 22.900391 L 20.099609 23 L 23.599609 23 C 21.699609 20 19.699219 17.099609 17.699219 14.099609 C 16.499219 12.399609 15.399219 10.600391 14.199219 8.9003906 L 10.699219 8.9003906 z M 6 9 C 7.6 11.3 9.0996094 13.6 10.599609 16 L 10.599609 16.099609 C 9.4996094 17.799609 8.4007813 19.399609 7.3007812 21.099609 C 6.8007813 21.699609 6.4 22.4 6 23 L 6 23.099609 L 9.5 23.099609 C 11.1 20.699609 12.699219 18.399609 14.199219 16.099609 L 14.199219 16 C 13.499219 14.8 12.700391 13.7 11.900391 12.5 C 11.100391 11.4 10.399609 10.199609 9.5996094 9.0996094 L 9.5 9 L 6 9 z M 18.199219 13 L 18.199219 13.099609 C 18.699219 13.899609 19.199219 14.600391 19.699219 15.400391 L 26 15.400391 L 26 13 L 18.199219 13 z M 20.5 16.599609 L 20.5 16.699219 C 21 17.499219 21.5 18.2 22 19 L 26 19 L 26 16.599609 L 20.5 16.599609 z " />
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 4.679688 3.894531 L 4.679688 3.9375 C 5.335938 4.945312 6.039062 5.949219 6.695312 6.957031 L 6.695312 7 C 6.039062 8.007812 5.335938 9.011719 4.679688 10.019531 L 4.679688 10.0625 L 6.210938 10.0625 L 6.257812 10.019531 C 6.648438 9.40625 7.085938 8.792969 7.480469 8.179688 C 7.523438 8.136719 7.480469 8.136719 7.523438 8.179688 C 7.917969 8.792969 8.355469 9.40625 8.75 10.019531 L 8.792969 10.0625 L 10.324219 10.0625 C 9.492188 8.75 8.617188 7.480469 7.742188 6.167969 C 7.21875 5.425781 6.738281 4.636719 6.210938 3.894531 Z M 2.625 3.9375 C 3.324219 4.945312 3.980469 5.949219 4.636719 7 L 4.636719 7.042969 C 4.15625 7.789062 3.675781 8.488281 3.195312 9.230469 C 2.976562 9.492188 2.800781 9.800781 2.625 10.0625 L 2.625 10.105469 L 4.15625 10.105469 C 4.855469 9.054688 5.554688 8.050781 6.210938 7.042969 L 6.210938 7 C 5.90625 6.476562 5.554688 5.992188 5.207031 5.46875 C 4.855469 4.988281 4.550781 4.460938 4.199219 3.980469 L 4.15625 3.9375 Z M 7.960938 5.6875 L 7.960938 5.730469 C 8.179688 6.082031 8.398438 6.386719 8.617188 6.738281 L 11.375 6.738281 L 11.375 5.6875 Z M 8.96875 7.261719 L 8.96875 7.304688 C 9.1875 7.65625 9.40625 7.960938 9.625 8.3125 L 11.375 8.3125 L 11.375 7.261719 Z M 8.96875 7.261719 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 7.054688 1.691406 C 7.054688 1.691406 6.519531 2.148438 5.972656 2.59375 C 5.410156 2.578125 4.304688 2.710938 3.710938 2.945312 C 3.15625 2.570312 2.671875 2.15625 2.671875 2.15625 C 2.671875 2.15625 2.257812 2.917969 2 3.367188 C 1.613281 3.585938 1.226562 3.832031 0.882812 4.160156 C 0.480469 3.988281 0.015625 3.78125 0 3.777344 C 0.53125 4.921875 0.886719 6.070312 1.863281 6.761719 C 3.410156 4.144531 10.601562 4.386719 12.183594 6.746094 C 13.203125 6.175781 13.597656 4.953125 14 3.820312 C 13.957031 3.835938 13.410156 4.03125 13.058594 4.175781 C 12.84375 3.929688 12.347656 3.550781 12.0625 3.367188 C 11.847656 2.949219 11.628906 2.539062 11.402344 2.128906 C 11.402344 2.128906 10.941406 2.496094 10.402344 2.902344 C 9.675781 2.757812 8.800781 2.585938 8.0625 2.628906 C 7.71875 2.320312 7.382812 2.011719 7.054688 1.691406 Z M 0.550781 6.210938 L 1.828125 9.519531 C 4.046875 12.652344 9.707031 12.867188 12.175781 9.582031 C 12.757812 8.171875 13.546875 6.191406 13.546875 6.191406 C 12.914062 7.199219 11.882812 7.890625 11.246094 8.261719 C 10.796875 8.527344 9.757812 8.6875 9.757812 8.6875 L 7.023438 7.171875 L 4.277344 8.65625 C 4.277344 8.65625 3.25 8.480469 2.785156 8.25 C 1.847656 7.714844 1.214844 7.078125 0.550781 6.210938 Z M 0.550781 6.210938 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1 +1,6 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="512" height="512"><path d="M170.322 349.808c-2.4-15.66-9-28.38-25.020-34.531-6.27-2.4-11.7-6.78-17.88-9.54-7.020-3.15-14.16-6.15-21.57-8.1-5.61-1.5-10.83 1.020-14.16 5.94-3.15 4.62-0.87 8.97 1.77 12.84 2.97 4.35 6.27 8.49 9.6 12.57 5.52 6.78 11.37 13.29 16.74 20.161 5.13 6.57 9.51 13.86 8.76 22.56-1.65 19.080-10.29 34.891-24.21 47.76-1.53 1.38-4.23 2.37-6.21 2.19-8.88-0.96-16.95-4.32-23.46-10.53-7.47-7.11-6.33-15.48 2.61-20.67 2.13-1.23 4.35-2.37 6.3-3.87 5.46-4.11 7.29-11.13 4.32-17.22-1.41-2.94-3-6.12-5.34-8.25-11.43-10.41-22.651-21.151-34.891-30.63-29.671-23.041-44.91-53.52-47.251-90.421-2.64-40.981 6.87-79.231 28.5-114.242 8.19-13.29 17.73-25.951 32.37-32.52 9.96-4.47 20.88-6.99 31.531-9.78 29.311-7.71 58.89-13.5 89.401-8.34 26.28 4.41 45.511 17.94 54.331 43.77 5.79 16.89 7.17 34.35 5.37 52.231-3.54 35.131-29.49 66.541-63.331 75.841-14.67 4.020-22.68 1.77-31.5-10.44-6.33-8.79-11.58-18.36-17.25-27.631-0.84-1.38-1.44-2.97-2.16-4.44-0.69-1.47-1.44-2.88-2.16-4.35 2.13 15.24 5.67 29.911 13.98 42.99 4.5 7.11 10.5 12.36 19.29 13.14 32.34 2.91 59.641-7.71 79.021-33.721 21.69-29.101 26.461-62.581 20.19-97.831-1.23-6.96-3.3-13.77-4.77-20.7-0.99-4.47 0.78-7.77 5.19-9.33 2.040-0.69 4.14-1.26 6.18-1.68 26.461-5.7 53.221-7.59 80.191-4.86 30.601 3.060 59.551 11.46 85.441 28.471 40.531 26.67 65.641 64.621 79.291 110.522 1.98 6.66 2.28 13.95 2.46 20.971 0.12 4.68-2.88 5.91-6.45 2.97-3.93-3.21-7.53-6.87-10.92-10.65-3.15-3.57-5.67-7.65-8.73-11.4-2.37-2.94-4.44-2.49-5.58 1.17-0.72 2.22-1.35 4.41-1.98 6.63-7.080 25.26-18.24 48.3-36.33 67.711-2.52 2.73-4.77 6.78-5.070 10.38-0.78 9.96-1.35 20.13-0.39 30.060 1.98 21.331 5.070 42.57 7.47 63.871 1.35 12.030-2.52 19.11-13.83 23.281-7.95 2.91-16.47 5.040-24.87 5.64-13.38 0.93-26.88 0.27-40.32 0.27-0.36-15 0.93-29.731-13.17-37.771 2.73-11.13 5.88-21.69 7.77-32.49 1.56-8.97 0.24-17.79-6.060-25.14-5.91-6.93-13.32-8.82-20.101-4.86-20.43 11.91-41.671 11.97-63.301 4.17-9.93-3.6-16.86-1.56-22.351 7.5-5.91 9.75-8.4 20.7-7.74 31.771 0.84 13.95 3.27 27.75 5.13 41.64 1.020 7.77 0.15 9.78-7.56 11.76-17.13 4.35-34.56 4.83-52.081 3.42-0.93-0.090-1.86-0.48-2.46-0.63-0.87-14.55 0.66-29.671-16.68-37.411 7.68-16.29 6.63-33.18 3.99-50.070l-0.060-0.15zM66.761 292.718c2.55-2.4 4.59-6.15 5.31-9.6 1.8-8.64-4.68-20.22-12.18-23.43-3.99-1.74-7.47-1.11-10.29 2.070-6.87 7.77-13.65 15.63-20.401 23.521-1.14 1.35-2.16 2.94-2.97 4.53-2.7 5.19-1.11 8.97 4.65 10.38 3.48 0.87 7.080 1.050 10.65 1.56 9.3-0.9 18.3-2.46 25.23-9v-0.030zM67.541 206.347c-0.030-6.18-5.19-11.34-11.28-11.37-6.27-0.030-11.67 5.58-11.46 11.76 0.27 6.21 5.43 11.19 11.61 11.070 6.24-0.090 11.22-5.19 11.16-11.43l-0.030-0.030z"></path></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 4.65625 9.566406 C 4.589844 9.136719 4.410156 8.789062 3.972656 8.621094 C 3.800781 8.554688 3.652344 8.433594 3.484375 8.359375 C 3.292969 8.273438 3.097656 8.191406 2.894531 8.136719 C 2.742188 8.097656 2.597656 8.167969 2.507812 8.300781 C 2.421875 8.425781 2.484375 8.546875 2.554688 8.652344 C 2.636719 8.769531 2.726562 8.882812 2.816406 8.996094 C 2.96875 9.179688 3.128906 9.359375 3.277344 9.546875 C 3.417969 9.726562 3.535156 9.925781 3.515625 10.164062 C 3.46875 10.6875 3.234375 11.117188 2.851562 11.46875 C 2.8125 11.507812 2.738281 11.535156 2.683594 11.53125 C 2.441406 11.503906 2.21875 11.410156 2.042969 11.242188 C 1.835938 11.046875 1.867188 10.820312 2.113281 10.675781 C 2.171875 10.644531 2.230469 10.613281 2.285156 10.570312 C 2.433594 10.457031 2.484375 10.265625 2.402344 10.101562 C 2.367188 10.019531 2.320312 9.933594 2.257812 9.875 C 1.945312 9.589844 1.636719 9.296875 1.304688 9.035156 C 0.492188 8.40625 0.0742188 7.574219 0.0117188 6.5625 C -0.0585938 5.445312 0.199219 4.398438 0.792969 3.441406 C 1.015625 3.078125 1.277344 2.730469 1.675781 2.550781 C 1.949219 2.429688 2.246094 2.359375 2.539062 2.285156 C 3.339844 2.074219 4.148438 1.914062 4.984375 2.054688 C 5.703125 2.175781 6.226562 2.546875 6.46875 3.253906 C 6.625 3.714844 6.664062 4.191406 6.617188 4.679688 C 6.519531 5.640625 5.808594 6.5 4.882812 6.753906 C 4.484375 6.863281 4.261719 6.804688 4.023438 6.46875 C 3.847656 6.230469 3.707031 5.96875 3.550781 5.714844 C 3.527344 5.675781 3.511719 5.632812 3.492188 5.59375 C 3.472656 5.550781 3.453125 5.511719 3.433594 5.472656 C 3.492188 5.890625 3.585938 6.292969 3.816406 6.648438 C 3.9375 6.84375 4.101562 6.988281 4.34375 7.007812 C 5.226562 7.085938 5.972656 6.796875 6.503906 6.085938 C 7.097656 5.289062 7.226562 4.375 7.054688 3.410156 C 7.019531 3.21875 6.964844 3.035156 6.925781 2.84375 C 6.898438 2.722656 6.945312 2.632812 7.066406 2.589844 C 7.121094 2.570312 7.179688 2.554688 7.234375 2.542969 C 7.960938 2.386719 8.691406 2.335938 9.429688 2.410156 C 10.265625 2.496094 11.054688 2.722656 11.765625 3.191406 C 12.871094 3.917969 13.558594 4.957031 13.933594 6.210938 C 13.988281 6.394531 13.996094 6.59375 14 6.785156 C 14.003906 6.914062 13.921875 6.945312 13.824219 6.867188 C 13.714844 6.777344 13.617188 6.679688 13.523438 6.574219 C 13.4375 6.476562 13.371094 6.367188 13.285156 6.261719 C 13.222656 6.183594 13.164062 6.195312 13.132812 6.296875 C 13.113281 6.355469 13.097656 6.414062 13.078125 6.476562 C 12.886719 7.167969 12.582031 7.796875 12.085938 8.328125 C 12.015625 8.402344 11.957031 8.511719 11.949219 8.613281 C 11.925781 8.882812 11.910156 9.164062 11.9375 9.433594 C 11.992188 10.015625 12.074219 10.597656 12.140625 11.179688 C 12.179688 11.507812 12.070312 11.703125 11.761719 11.816406 C 11.546875 11.894531 11.3125 11.953125 11.082031 11.972656 C 10.71875 11.996094 10.347656 11.976562 9.980469 11.976562 C 9.96875 11.566406 10.003906 11.164062 9.621094 10.945312 C 9.695312 10.640625 9.78125 10.351562 9.832031 10.058594 C 9.875 9.8125 9.839844 9.570312 9.667969 9.371094 C 9.503906 9.179688 9.304688 9.128906 9.117188 9.238281 C 8.558594 9.5625 7.976562 9.5625 7.386719 9.351562 C 7.113281 9.253906 6.925781 9.308594 6.773438 9.554688 C 6.613281 9.824219 6.546875 10.121094 6.5625 10.425781 C 6.585938 10.804688 6.652344 11.183594 6.703125 11.5625 C 6.730469 11.777344 6.707031 11.832031 6.496094 11.886719 C 6.027344 12.003906 5.550781 12.015625 5.074219 11.976562 C 5.046875 11.976562 5.023438 11.964844 5.007812 11.960938 C 4.980469 11.5625 5.023438 11.148438 4.550781 10.9375 C 4.761719 10.492188 4.730469 10.03125 4.660156 9.570312 Z M 1.824219 8.003906 C 1.894531 7.9375 1.949219 7.835938 1.96875 7.742188 C 2.019531 7.503906 1.84375 7.1875 1.636719 7.101562 C 1.527344 7.054688 1.433594 7.070312 1.355469 7.15625 C 1.167969 7.371094 0.984375 7.585938 0.796875 7.800781 C 0.765625 7.835938 0.738281 7.882812 0.71875 7.925781 C 0.644531 8.066406 0.6875 8.167969 0.84375 8.207031 C 0.941406 8.230469 1.039062 8.238281 1.136719 8.25 C 1.390625 8.226562 1.636719 8.183594 1.824219 8.003906 Z M 1.847656 5.640625 C 1.847656 5.472656 1.703125 5.332031 1.539062 5.332031 C 1.367188 5.332031 1.21875 5.484375 1.226562 5.652344 C 1.230469 5.824219 1.375 5.957031 1.542969 5.957031 C 1.714844 5.953125 1.847656 5.8125 1.847656 5.644531 Z M 1.847656 5.640625 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 11.214844 0.015625 C 11.214844 1.125 5.859375 1.976562 2.785156 2.179688 L 2.785156 5.335938 C 4.082031 5.421875 5.789062 5.628906 7.324219 5.917969 C 5.789062 6.207031 4.082031 6.410156 2.785156 6.492188 L 2.785156 9.648438 C 4.082031 9.734375 5.785156 9.9375 7.320312 10.226562 C 5.785156 10.515625 4.082031 10.71875 2.785156 10.804688 L 2.785156 13.988281 L 4.308594 13.765625 C 7.152344 13.339844 10.285156 12.53125 11.214844 11.820312 L 11.214844 8.632812 C 11.214844 8.433594 10.851562 8.21875 10.265625 8 C 10.675781 7.832031 11.003906 7.667969 11.214844 7.507812 L 11.214844 4.324219 C 11.214844 4.125 10.855469 3.90625 10.277344 3.6875 C 10.683594 3.523438 11.003906 3.355469 11.214844 3.195312 Z M 10.269531 8.339844 C 10.6875 8.503906 10.839844 8.617188 10.890625 8.664062 C 10.855469 8.734375 10.726562 8.871094 10.359375 9.050781 C 10.300781 9.078125 10.238281 9.105469 10.183594 9.128906 C 9.550781 9.402344 8.570312 9.667969 7.320312 9.90625 C 6.707031 9.792969 6.046875 9.6875 5.382812 9.597656 C 7.25 9.261719 9.09375 8.796875 10.269531 8.339844 Z M 10.277344 4.027344 C 10.691406 4.195312 10.839844 4.308594 10.890625 4.355469 C 10.863281 4.40625 10.78125 4.5 10.578125 4.625 L 10.574219 4.625 C 10.535156 4.648438 10.488281 4.675781 10.441406 4.699219 C 9.839844 5.011719 8.765625 5.324219 7.335938 5.59375 C 6.71875 5.480469 6.058594 5.375 5.394531 5.285156 C 7.269531 4.953125 9.097656 4.492188 10.277344 4.027344 Z M 10.277344 4.027344 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:4;" d="M 21.946429 2.875 C 21.982143 5.348214 21.910714 7.785714 19.776786 10.107143 L 19.696429 10.196429 L 19.8125 10.196429 L 20.6875 10.205357 C 19.267857 13.160714 18.348214 16.098214 16.303571 19.035714 L 16.232143 19.142857 L 16.357143 19.125 L 17.4375 18.919643 C 16.883929 20.598214 15.607143 21.946429 13.955357 22.571429 C 13.5625 17.116071 16.285714 12.303571 18.598214 7.5 L 18.607143 7.491071 L 18.517857 7.428571 C 14.732143 11.660714 13.026786 17.625 12.383929 22.553571 C 11.285714 21.901786 10.5 20.821429 10.241071 19.5625 L 11.133929 19.946429 L 11.232143 19.982143 L 11.214286 19.883929 C 10.526786 16.857143 11.589286 14.678571 12.607143 11.830357 L 13.348214 12.321429 L 13.4375 12.383929 L 13.4375 12.276786 C 13.375 9.964286 14.9375 7.633929 17.008929 5.553571 L 17.294643 6.321429 L 17.339286 6.419643 L 17.392857 6.321429 L 18.026786 5.267857 C 18.973214 3.991071 20.375 3.133929 21.946429 2.875 Z M 21.946429 2.875 " transform="matrix(0.4375,0,0,0.4375,0,0)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:4;" d="M 21.946429 2.875 C 20.375 3.133929 18.973214 3.991071 18.017857 5.258929 L 18.017857 5.267857 L 17.392857 6.321429 L 17.339286 6.419643 L 17.294643 6.321429 L 17 5.544643 C 14.928571 7.625 13.366071 9.955357 13.419643 12.267857 L 13.419643 12.375 L 13.339286 12.3125 L 12.598214 11.821429 C 11.571429 14.669643 10.517857 16.848214 11.196429 19.875 L 11.223214 19.973214 L 11.125 19.9375 L 10.241071 19.5625 C 10.241071 19.580357 10.25 19.598214 10.25 19.616071 C 10.517857 20.839286 11.294643 21.901786 12.375 22.544643 C 12.428571 22.160714 12.482143 21.776786 12.544643 21.383929 C 11 17.767857 12.348214 15.107143 12.955357 12.723214 L 13.892857 13.258929 C 13.758929 11.026786 15.080357 8.607143 16.785714 6.508929 L 17.285714 7.375 C 18.553571 4.767857 19.5625 3.723214 21.946429 2.875 Z M 21.946429 2.875 " transform="matrix(0.4375,0,0,0.4375,0,0)"/>
<path style="fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:4;" d="M 22.517857 2 L 22.464286 2.008929 C 20.383929 2.375 18.339286 3.133929 17.446429 4.973214 L 17.071429 4.3125 L 17.035714 4.25 L 16.991071 4.303571 C 15.883929 5.357143 14.892857 6.526786 14.044643 7.803571 C 13.339286 8.723214 12.919643 9.839286 12.839286 11 L 12.303571 10.339286 L 12.25 10.267857 L 12.214286 10.348214 C 11.508929 11.857143 10.9375 13.428571 10.517857 15.044643 C 10.116071 16.25 10.0625 17.535714 10.366071 18.767857 L 9.482143 18.258929 L 9.410714 18.214286 L 9.401786 18.294643 C 9.223214 20.151786 9.982143 21.973214 11.419643 23.142857 L 10.455357 23.383929 L 10.25 23.428571 L 10.455357 23.482143 C 10.973214 23.598214 11.464286 23.794643 11.901786 24.089286 C 12.3125 24.383929 12.508929 24.892857 12.419643 25.383929 L 12.419643 28.098214 L 12.428571 28.116071 L 13.651786 29.857143 L 13.75 30 L 13.75 25.723214 C 13.839286 25.178571 14.053571 24.678571 14.366071 24.232143 C 14.660714 23.910714 15.071429 23.723214 15.5 23.696429 L 15.678571 23.678571 L 15.517857 23.598214 L 14.875 23.303571 C 16.714286 22.035714 18.035714 20.142857 18.571429 17.982143 L 18.589286 17.892857 L 18.508929 17.919643 L 17.714286 18.133929 C 18.607143 17.098214 19.3125 15.910714 19.803571 14.633929 C 20.508929 13 21.178571 11.169643 21.732143 9.696429 L 21.758929 9.625 L 21.678571 9.625 L 21.0625 9.669643 C 21.857143 8.651786 22.339286 7.428571 22.446429 6.142857 C 22.633929 4.785714 22.660714 3.419643 22.526786 2.053571 Z M 21.946429 2.875 C 21.982143 5.348214 21.910714 7.785714 19.776786 10.107143 L 19.696429 10.196429 L 19.8125 10.196429 L 20.6875 10.205357 C 19.267857 13.160714 18.348214 16.098214 16.303571 19.035714 L 16.232143 19.142857 L 16.357143 19.125 L 17.4375 18.919643 C 16.883929 20.598214 15.607143 21.946429 13.955357 22.571429 C 13.5625 17.116071 16.285714 12.303571 18.598214 7.5 L 18.607143 7.491071 L 18.517857 7.428571 C 14.732143 11.660714 13.026786 17.625 12.383929 22.553571 C 11.285714 21.901786 10.508929 20.821429 10.241071 19.5625 L 11.142857 19.946429 L 11.232143 19.982143 L 11.214286 19.883929 C 10.526786 16.857143 11.589286 14.678571 12.616071 11.830357 L 13.348214 12.321429 L 13.4375 12.383929 L 13.4375 12.276786 C 13.375 9.964286 14.9375 7.633929 17.008929 5.553571 L 17.303571 6.321429 L 17.339286 6.419643 L 17.392857 6.321429 L 18.026786 5.267857 C 18.973214 3.991071 20.375 3.133929 21.946429 2.875 Z M 21.946429 2.875 " transform="matrix(0.4375,0,0,0.4375,0,0)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -1,6 +1,9 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.5066 8.01531L19.2375 12.1073V20.2894L12.5066 16.1992V8.01531Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.0294 12.1073V20.2894L27.1563 16.1992V8.01531L20.0294 12.1073Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.58781 3.66V11.5787L11.7147 15.5381V7.61937L4.58781 3.66Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.5066 25.04L19.2375 29V21.1348V21.0818L12.5066 17.1219V25.04Z" fill="black"/>
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px" viewBox="0 0 14 14" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:evenodd;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 5.472656 3.507812 L 8.417969 5.296875 L 8.417969 8.875 L 5.472656 7.085938 Z M 5.472656 3.507812 "/>
<path style=" stroke:none;fill-rule:evenodd;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 8.761719 5.296875 L 8.761719 8.875 L 11.882812 7.085938 L 11.882812 3.507812 Z M 8.761719 5.296875 "/>
<path style=" stroke:none;fill-rule:evenodd;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 2.007812 1.601562 L 2.007812 5.066406 L 5.125 6.796875 L 5.125 3.332031 Z M 2.007812 1.601562 "/>
<path style=" stroke:none;fill-rule:evenodd;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 5.472656 10.953125 L 8.417969 12.6875 L 8.417969 9.222656 L 5.472656 7.492188 Z M 5.472656 10.953125 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 961 B

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20 17V15.8C20 14.1198 20 13.2798 19.673 12.638C19.3854 12.0735 18.9265 11.6146 18.362 11.327C17.7202 11 16.8802 11 15.2 11H4M4 11L8 7M4 11L8 15" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 468 B

View File

@@ -16,6 +16,7 @@
"ctrl-enter": "menu::SecondaryConfirm",
"escape": "menu::Cancel",
"ctrl-c": "menu::Cancel",
"shift-enter": "menu::UseSelectedQuery",
"ctrl-shift-w": "workspace::CloseWindow",
"shift-escape": "workspace::ToggleZoom",
"ctrl-o": "workspace::Open",
@@ -72,7 +73,7 @@
"ctrl-n": "editor::MoveDown",
"ctrl-b": "editor::MoveLeft",
"ctrl-f": "editor::MoveRight",
"ctrl-shift-l": "editor::NextScreen", // todo!(linux): What is this
"ctrl-shift-l": "editor::NextScreen", // todo(linux): What is this
"alt-left": "editor::MoveToPreviousWordStart",
"alt-b": "editor::MoveToPreviousWordStart",
"alt-right": "editor::MoveToNextWordEnd",
@@ -116,7 +117,9 @@
{
"stop_at_soft_wraps": true
}
]
],
"ctrl-;": "editor::ToggleLineNumbers",
"ctrl-alt-z": "editor::RevertSelectedHunks"
}
},
{
@@ -133,10 +136,21 @@
"focus": true
}
],
"alt-\\": "copilot::Suggest",
"ctrl->": "assistant::QuoteSelection"
}
},
{
"context": "Editor && mode == full && copilot_suggestion",
"bindings": {
"alt-]": "copilot::NextSuggestion",
"alt-[": "copilot::PreviousSuggestion",
"ctrl->": "assistant::QuoteSelection"
"alt-right": "editor::AcceptPartialCopilotSuggestion"
}
},
{
"context": "Editor && !copilot_suggestion",
"bindings": {
"alt-\\": "copilot::Suggest"
}
},
{
@@ -341,10 +355,18 @@
{
"context": "Workspace",
"bindings": {
// Change the default action on `menu::Confirm` by setting the parameter
// "alt-cmd-o": [
// "projects::OpenRecent",
// {
// "create_new_window": true
// }
// ]
"ctrl-alt-o": "projects::OpenRecent",
"ctrl-alt-b": "branches::OpenRecent",
"ctrl-~": "workspace::NewTerminal",
"ctrl-s": "workspace::Save",
"ctrl-k s": "workspace::SaveWithoutFormat",
"ctrl-shift-s": "workspace::SaveAs",
"ctrl-n": "workspace::NewFile",
"ctrl-shift-n": "workspace::NewWindow",
@@ -387,7 +409,7 @@
}
},
// Bindings from Sublime Text
// todo!(linux) make sure these match linux bindings or remove above comment?
// todo(linux) make sure these match linux bindings or remove above comment?
{
"context": "Editor",
"bindings": {
@@ -411,7 +433,7 @@
}
},
// Bindings from Atom
// todo!(linux) make sure these match linux bindings or remove above comment?
// todo(linux) make sure these match linux bindings or remove above comment?
{
"context": "Pane",
"bindings": {
@@ -466,6 +488,7 @@
"context": "Editor && mode == full",
"bindings": {
"alt-enter": "editor::OpenExcerpts",
"ctrl-k enter": "editor::OpenExcerptsSplit",
"ctrl-f8": "editor::GoToHunk",
"ctrl-shift-f8": "editor::GoToPrevHunk",
"ctrl-enter": "assistant::InlineAssist"

View File

@@ -17,6 +17,7 @@
"cmd-enter": "menu::SecondaryConfirm",
"escape": "menu::Cancel",
"ctrl-c": "menu::Cancel",
"shift-enter": "menu::UseSelectedQuery",
"cmd-shift-w": "workspace::CloseWindow",
"shift-escape": "workspace::ToggleZoom",
"cmd-o": "workspace::Open",
@@ -48,6 +49,7 @@
"cmd-backspace": "editor::DeleteToBeginningOfLine",
"cmd-delete": "editor::DeleteToEndOfLine",
"alt-backspace": "editor::DeleteToPreviousWordStart",
"ctrl-w": "editor::DeleteToPreviousWordStart",
"alt-delete": "editor::DeleteToNextWordEnd",
"alt-h": "editor::DeleteToPreviousWordStart",
"alt-d": "editor::DeleteToNextWordEnd",
@@ -150,7 +152,9 @@
"center_cursor": true
}
],
"ctrl-cmd-space": "editor::ShowCharacterPalette"
"ctrl-cmd-space": "editor::ShowCharacterPalette",
"cmd-;": "editor::ToggleLineNumbers",
"cmd-alt-z": "editor::RevertSelectedHunks"
}
},
{
@@ -173,10 +177,21 @@
"focus": false
}
],
"alt-\\": "copilot::Suggest",
"cmd->": "assistant::QuoteSelection"
}
},
{
"context": "Editor && mode == full && copilot_suggestion",
"bindings": {
"alt-]": "copilot::NextSuggestion",
"alt-[": "copilot::PreviousSuggestion",
"cmd->": "assistant::QuoteSelection"
"alt-right": "editor::AcceptPartialCopilotSuggestion"
}
},
{
"context": "Editor && !copilot_suggestion",
"bindings": {
"alt-\\": "copilot::Suggest"
}
},
{
@@ -301,6 +316,18 @@
"cmd-ctrl-p": "editor::AddSelectionAbove",
"cmd-alt-down": "editor::AddSelectionBelow",
"cmd-ctrl-n": "editor::AddSelectionBelow",
"cmd-shift-k": "editor::DeleteLine",
"alt-up": "editor::MoveLineUp",
"alt-down": "editor::MoveLineDown",
"alt-shift-up": [
"editor::DuplicateLine",
{
"move_upwards": true
}
],
"alt-shift-down": "editor::DuplicateLine",
"ctrl-shift-right": "editor::SelectLargerSyntaxNode",
"ctrl-shift-left": "editor::SelectSmallerSyntaxNode",
"cmd-d": [
"editor::SelectNext",
{
@@ -333,8 +360,6 @@
"advance_downwards": false
}
],
"alt-up": "editor::SelectLargerSyntaxNode",
"alt-down": "editor::SelectSmallerSyntaxNode",
"cmd-u": "editor::UndoSelection",
"cmd-shift-u": "editor::RedoSelection",
"f8": "editor::GoToDiagnostic",
@@ -383,10 +408,18 @@
{
"context": "Workspace",
"bindings": {
// Change the default action on `menu::Confirm` by setting the parameter
// "alt-cmd-o": [
// "projects::OpenRecent",
// {
// "create_new_window": true
// }
// ]
"alt-cmd-o": "projects::OpenRecent",
"alt-cmd-b": "branches::OpenRecent",
"ctrl-~": "workspace::NewTerminal",
"cmd-s": "workspace::Save",
"cmd-k s": "workspace::SaveWithoutFormat",
"cmd-shift-s": "workspace::SaveAs",
"cmd-n": "workspace::NewFile",
"cmd-shift-n": "workspace::NewWindow",
@@ -405,8 +438,8 @@
"cmd-j": "workspace::ToggleBottomDock",
"alt-cmd-y": "workspace::CloseAllDocks",
"cmd-shift-f": "pane::DeploySearch",
"cmd-k cmd-t": "theme_selector::Toggle",
"cmd-k cmd-s": "zed::OpenKeymap",
"cmd-k cmd-t": "theme_selector::Toggle",
"cmd-t": "project_symbols::Toggle",
"cmd-p": "file_finder::Toggle",
"cmd-shift-p": "command_palette::Toggle",
@@ -432,11 +465,7 @@
{
"context": "Editor",
"bindings": {
"ctrl-shift-k": "editor::DeleteLine",
"cmd-shift-d": "editor::DuplicateLine",
"ctrl-j": "editor::JoinLines",
"ctrl-cmd-up": "editor::MoveLineUp",
"ctrl-cmd-down": "editor::MoveLineDown",
"ctrl-alt-backspace": "editor::DeleteToPreviousSubwordStart",
"ctrl-alt-h": "editor::DeleteToPreviousSubwordStart",
"ctrl-alt-delete": "editor::DeleteToNextSubwordEnd",
@@ -506,6 +535,7 @@
"context": "Editor && mode == full",
"bindings": {
"alt-enter": "editor::OpenExcerpts",
"cmd-k enter": "editor::OpenExcerptsSplit",
"cmd-f8": "editor::GoToHunk",
"cmd-shift-f8": "editor::GoToPrevHunk",
"ctrl-enter": "assistant::InlineAssist"

View File

@@ -39,6 +39,8 @@
"advance_downwards": true
}
],
"alt-up": "editor::SelectLargerSyntaxNode",
"alt-down": "editor::SelectSmallerSyntaxNode",
"shift-alt-up": "editor::MoveLineUp",
"shift-alt-down": "editor::MoveLineDown",
"cmd-alt-l": "editor::Format",

View File

@@ -37,30 +37,42 @@
"_": "vim::StartOfLineDownward",
"g _": "vim::EndOfLineDownward",
"shift-g": "vim::EndOfDocument",
"w": "vim::NextWordStart",
"{": "vim::StartOfParagraph",
"}": "vim::EndOfParagraph",
"|": "vim::GoToColumn",
// Word motions
"w": "vim::NextWordStart",
"e": "vim::NextWordEnd",
"b": "vim::PreviousWordStart",
"g e": "vim::PreviousWordEnd",
// Subword motions
// "w": "vim::NextSubwordStart",
// "b": "vim::PreviousSubwordStart",
// "e": "vim::NextSubwordEnd",
// "g e": "vim::PreviousSubwordEnd",
"shift-w": [
"vim::NextWordStart",
{
"ignorePunctuation": true
}
],
"e": "vim::NextWordEnd",
"shift-e": [
"vim::NextWordEnd",
{
"ignorePunctuation": true
}
],
"b": "vim::PreviousWordStart",
"shift-b": [
"vim::PreviousWordStart",
{
"ignorePunctuation": true
}
],
"g shift-e": ["vim::PreviousWordEnd", { "ignorePunctuation": true }],
"n": "search::SelectNextMatch",
"shift-n": "search::SelectPrevMatch",
"%": "vim::Matching",
@@ -117,8 +129,6 @@
"ctrl-e": "vim::LineDown",
"ctrl-y": "vim::LineUp",
// "g" commands
"g e": "vim::PreviousWordEnd",
"g shift-e": ["vim::PreviousWordEnd", { "ignorePunctuation": true }],
"g g": "vim::StartOfDocument",
"g h": "editor::Hover",
"g t": "pane::ActivateNextItem",
@@ -218,6 +228,7 @@
// z commands
"z t": "editor::ScrollCursorTop",
"z z": "editor::ScrollCursorCenter",
"z .": ["workspace::SendKeystrokes", "z z ^"],
"z b": "editor::ScrollCursorBottom",
"z c": "editor::Fold",
"z o": "editor::UnfoldLines",
@@ -288,6 +299,13 @@
"ctrl-w ctrl-o": "workspace::CloseInactiveTabsAndPanes",
"ctrl-w n": ["workspace::NewFileInDirection", "Up"],
"ctrl-w ctrl-n": ["workspace::NewFileInDirection", "Up"],
"ctrl-w d": "editor::GoToDefinitionSplit",
"ctrl-w g d": "editor::GoToDefinitionSplit",
"ctrl-w shift-d": "editor::GoToTypeDefinitionSplit",
"ctrl-w g shift-d": "editor::GoToTypeDefinitionSplit",
"ctrl-w space": "editor::OpenExcerptsSplit",
"ctrl-w g space": "editor::OpenExcerptsSplit",
"-": "pane::RevealInProjectPanel"
}
},
@@ -345,7 +363,9 @@
"> >": "vim::Indent",
"< <": "vim::Outdent",
"ctrl-pagedown": "pane::ActivateNextItem",
"ctrl-pageup": "pane::ActivatePrevItem"
"ctrl-pageup": "pane::ActivatePrevItem",
"[ x": "editor::SelectLargerSyntaxNode",
"] x": "editor::SelectSmallerSyntaxNode"
}
},
{
@@ -385,6 +405,7 @@
],
"t": "vim::Tag",
"s": "vim::Sentence",
"p": "vim::Paragraph",
"'": "vim::Quotes",
"`": "vim::BackQuotes",
"\"": "vim::DoubleQuotes",

View File

@@ -140,6 +140,15 @@
// Whether to show diagnostic indicators in the scrollbar.
"diagnostics": true
},
// What to do when multibuffer is double clicked in some of its excerpts
// (parts of singleton buffers).
// May take 2 values:
// 1. Behave as a regular buffer and select the whole word (default).
// "double_click_in_multibuffer": "select"
// 2. Open the excerpt clicked as a new buffer in the new tab.
// "double_click_in_multibuffer": "open",
// For the case of "open", regular selection behavior can be achieved by holding `alt` when double clicking.
"double_click_in_multibuffer": "select",
"gutter": {
// Whether to show line numbers in the gutter.
"line_numbers": true,
@@ -148,7 +157,7 @@
// Whether to show fold buttons in the gutter.
"folds": true
},
// The number of lines to keep above/below the cursor when scrolling.
// The number of lines to keep above/below the cursor when moving the cursor.
"vertical_scroll_margin": 3,
"relative_line_numbers": false,
// When to populate a new search's query based on the text under the cursor.
@@ -180,7 +189,7 @@
"project_panel": {
// Default width of the project panel.
"default_width": 240,
// Where to dock project panel. Can be 'left' or 'right'.
// Where to dock the project panel. Can be 'left' or 'right'.
"dock": "left",
// Whether to show file icons in the project panel.
"file_icons": true,
@@ -198,45 +207,64 @@
"collaboration_panel": {
// Whether to show the collaboration panel button in the status bar.
"button": true,
// Where to dock channels panel. Can be 'left' or 'right'.
// Where to dock the collaboration panel. Can be 'left' or 'right'.
"dock": "left",
// Default width of the channels panel.
// Default width of the collaboration panel.
"default_width": 240
},
"chat_panel": {
// Whether to show the collaboration panel button in the status bar.
// Whether to show the chat panel button in the status bar.
"button": true,
// Where to dock channels panel. Can be 'left' or 'right'.
// Where to the chat panel. Can be 'left' or 'right'.
"dock": "right",
// Default width of the channels panel.
// Default width of the chat panel.
"default_width": 240
},
"message_editor": {
// Whether to automatically replace emoji shortcodes with emoji characters.
// For example: typing `:wave:` gets replaced with `👋`.
"auto_replace_emoji_shortcode": true
},
"notification_panel": {
// Whether to show the collaboration panel button in the status bar.
// Whether to show the notification panel button in the status bar.
"button": true,
// Where to dock channels panel. Can be 'left' or 'right'.
// Where to dock the notification panel. Can be 'left' or 'right'.
"dock": "right",
// Default width of the channels panel.
// Default width of the notification panel.
"default_width": 380
},
"assistant": {
// Whether to show the assistant panel button in the status bar.
"button": true,
// Where to dock the assistant. Can be 'left', 'right' or 'bottom'.
// Where to dock the assistant panel. Can be 'left', 'right' or 'bottom'.
"dock": "right",
// Default width when the assistant is docked to the left or right.
"default_width": 640,
// Default height when the assistant is docked to the bottom.
"default_height": 320,
// Deprecated: Please use `provider.api_url` instead.
// The default OpenAI API endpoint to use when starting new conversations.
"openai_api_url": "https://api.openai.com/v1",
// Deprecated: Please use `provider.default_model` instead.
// The default OpenAI model to use when starting new conversations. This
// setting can take three values:
//
// 1. "gpt-3.5-turbo-0613""
// 2. "gpt-4-0613""
// 3. "gpt-4-1106-preview"
"default_open_ai_model": "gpt-4-1106-preview"
"default_open_ai_model": "gpt-4-1106-preview",
"provider": {
"type": "openai",
// The default OpenAI API endpoint to use when starting new conversations.
"api_url": "https://api.openai.com/v1",
// The default OpenAI model to use when starting new conversations. This
// setting can take three values:
//
// 1. "gpt-3.5-turbo-0613""
// 2. "gpt-4-0613""
// 3. "gpt-4-1106-preview"
"default_model": "gpt-4-1106-preview"
}
},
// Whether the screen sharing icon is shown in the os status bar.
"show_call_status_icon": true,
@@ -458,6 +486,10 @@
// Can also be 'csh', 'fish', and `nushell`
"activate_script": "default"
}
},
"toolbar": {
// Whether to display the terminal title in its toolbar.
"title": true
}
// Set the terminal's font size. If this option is not included,
// the terminal will default to matching the buffer's font size.
@@ -572,7 +604,8 @@
// Vim settings
"vim": {
"use_system_clipboard": "always",
"use_multiline_find": false
"use_multiline_find": false,
"use_smartcase_find": false
},
// The server to connect to. If the environment variable
// ZED_SERVER_URL is set, it will override this setting.

View File

@@ -4,9 +4,7 @@
[
{
"label": "Example task",
"command": "bash",
// rest of the parameters are optional
"args": ["-c", "for i in {1..5}; do echo \"Hello $i/5\"; sleep 1; done"],
"command": "for i in {1..5}; do echo \"Hello $i/5\"; sleep 1; done",
// Env overrides for the command, will be appended to the terminal's environment from the settings.
"env": { "foo": "bar" },
// Current working directory to spawn the command into, defaults to current project root.

View File

@@ -77,7 +77,7 @@
"terminal.ansi.green": "#5cc1a3ff",
"terminal.ansi.bright_green": "#31614fff",
"terminal.ansi.dim_green": "#b3e1d1ff",
"terminal.ansi.yellow": "#f5c177ff",
"terminal.ansi.yellow": "#f6c177ff",
"terminal.ansi.bright_yellow": "#8a643aff",
"terminal.ansi.dim_yellow": "#fedfbbff",
"terminal.ansi.blue": "#9bced6ff",
@@ -93,7 +93,7 @@
"terminal.ansi.bright_white": "#e0def4ff",
"terminal.ansi.dim_white": "#514e68ff",
"link_text.hover": "#9bced6ff",
"conflict": "#f5c177ff",
"conflict": "#f6c177ff",
"conflict.background": "#50331aff",
"conflict.border": "#6d4d2bff",
"created": "#5cc1a3ff",
@@ -117,7 +117,7 @@
"info": "#9bced6ff",
"info.background": "#2f3639ff",
"info.border": "#435255ff",
"modified": "#f5c177ff",
"modified": "#f6c177ff",
"modified.background": "#50331aff",
"modified.border": "#6d4d2bff",
"predictive": "#556b81ff",
@@ -132,7 +132,7 @@
"unreachable": "#74708dff",
"unreachable.background": "#292738ff",
"unreachable.border": "#423f55ff",
"warning": "#f5c177ff",
"warning": "#f6c177ff",
"warning.background": "#50331aff",
"warning.border": "#6d4d2bff",
"players": [
@@ -167,9 +167,9 @@
"selection": "#ea6e923d"
},
{
"cursor": "#f5c177ff",
"background": "#f5c177ff",
"selection": "#f5c1773d"
"cursor": "#f6c177ff",
"background": "#f6c177ff",
"selection": "#f6c1773d"
},
{
"cursor": "#5cc1a3ff",
@@ -319,7 +319,7 @@
"font_weight": null
},
"string": {
"color": "#f5c177ff",
"color": "#f6c177ff",
"font_style": null,
"font_weight": null
},
@@ -354,7 +354,7 @@
"font_weight": null
},
"title": {
"color": "#f5c177ff",
"color": "#f6c177ff",
"font_style": null,
"font_weight": 700
},
@@ -835,7 +835,7 @@
"terminal.ansi.green": "#5cc1a3ff",
"terminal.ansi.bright_green": "#31614fff",
"terminal.ansi.dim_green": "#b3e1d1ff",
"terminal.ansi.yellow": "#f5c177ff",
"terminal.ansi.yellow": "#f6c177ff",
"terminal.ansi.bright_yellow": "#8a643aff",
"terminal.ansi.dim_yellow": "#fedfbbff",
"terminal.ansi.blue": "#9bced6ff",
@@ -851,7 +851,7 @@
"terminal.ansi.bright_white": "#e0def4ff",
"terminal.ansi.dim_white": "#74708dff",
"link_text.hover": "#9bced6ff",
"conflict": "#f5c177ff",
"conflict": "#f6c177ff",
"conflict.background": "#50331aff",
"conflict.border": "#6d4d2bff",
"created": "#5cc1a3ff",
@@ -875,7 +875,7 @@
"info": "#9bced6ff",
"info.background": "#2f3639ff",
"info.border": "#435255ff",
"modified": "#f5c177ff",
"modified": "#f6c177ff",
"modified.background": "#50331aff",
"modified.border": "#6d4d2bff",
"predictive": "#516b83ff",
@@ -890,7 +890,7 @@
"unreachable": "#85819eff",
"unreachable.background": "#38354eff",
"unreachable.border": "#504c68ff",
"warning": "#f5c177ff",
"warning": "#f6c177ff",
"warning.background": "#50331aff",
"warning.border": "#6d4d2bff",
"players": [
@@ -925,9 +925,9 @@
"selection": "#ea6e923d"
},
{
"cursor": "#f5c177ff",
"background": "#f5c177ff",
"selection": "#f5c1773d"
"cursor": "#f6c177ff",
"background": "#f6c177ff",
"selection": "#f6c1773d"
},
{
"cursor": "#5cc1a3ff",
@@ -1077,7 +1077,7 @@
"font_weight": null
},
"string": {
"color": "#f5c177ff",
"color": "#f6c177ff",
"font_style": null,
"font_weight": null
},
@@ -1112,7 +1112,7 @@
"font_weight": null
},
"title": {
"color": "#f5c177ff",
"color": "#f6c177ff",
"font_style": null,
"font_weight": 700
},

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/activity_indicator.rs"
doctest = false

View File

@@ -6,7 +6,7 @@ use gpui::{
ParentElement as _, Render, SharedString, StatefulInteractiveElement, Styled, View,
ViewContext, VisualContext as _,
};
use language::{LanguageRegistry, LanguageServerBinaryStatus};
use language::{LanguageRegistry, LanguageServerBinaryStatus, LanguageServerName};
use project::{LanguageServerProgress, Project};
use smallvec::SmallVec;
use std::{cmp::Reverse, fmt::Write, sync::Arc};
@@ -30,7 +30,7 @@ pub struct ActivityIndicator {
}
struct LspStatus {
name: Arc<str>,
name: LanguageServerName,
status: LanguageServerBinaryStatus,
}
@@ -58,13 +58,10 @@ impl ActivityIndicator {
let this = cx.new_view(|cx: &mut ViewContext<Self>| {
let mut status_events = languages.language_server_binary_statuses();
cx.spawn(|this, mut cx| async move {
while let Some((language, event)) = status_events.next().await {
while let Some((name, status)) = status_events.next().await {
this.update(&mut cx, |this, cx| {
this.statuses.retain(|s| s.name != language.name());
this.statuses.push(LspStatus {
name: language.name(),
status: event,
});
this.statuses.retain(|s| s.name != name);
this.statuses.push(LspStatus { name, status });
cx.notify();
})?;
}
@@ -97,7 +94,7 @@ impl ActivityIndicator {
cx,
);
});
workspace.add_item(
workspace.add_item_to_active_pane(
Box::new(
cx.new_view(|cx| Editor::for_buffer(buffer, Some(project.clone()), cx)),
),
@@ -114,7 +111,7 @@ impl ActivityIndicator {
self.statuses.retain(|status| {
if let LanguageServerBinaryStatus::Failed { error } = &status.status {
cx.emit(Event::ShowError {
lsp_name: status.name.clone(),
lsp_name: status.name.0.clone(),
error: error.clone(),
});
false
@@ -202,11 +199,12 @@ impl ActivityIndicator {
let mut checking_for_update = SmallVec::<[_; 3]>::new();
let mut failed = SmallVec::<[_; 3]>::new();
for status in &self.statuses {
let name = status.name.clone();
match status.status {
LanguageServerBinaryStatus::CheckingForUpdate => checking_for_update.push(name),
LanguageServerBinaryStatus::Downloading => downloading.push(name),
LanguageServerBinaryStatus::Failed { .. } => failed.push(name),
LanguageServerBinaryStatus::CheckingForUpdate => {
checking_for_update.push(status.name.0.as_ref())
}
LanguageServerBinaryStatus::Downloading => downloading.push(status.name.0.as_ref()),
LanguageServerBinaryStatus::Failed { .. } => failed.push(status.name.0.as_ref()),
LanguageServerBinaryStatus::Downloaded | LanguageServerBinaryStatus::Cached => {}
}
}
@@ -214,34 +212,28 @@ impl ActivityIndicator {
if !downloading.is_empty() {
return Content {
icon: Some(DOWNLOAD_ICON),
message: format!(
"Downloading {} language server{}...",
downloading.join(", "),
if downloading.len() > 1 { "s" } else { "" }
),
message: format!("Downloading {}...", downloading.join(", "),),
on_click: None,
};
} else if !checking_for_update.is_empty() {
}
if !checking_for_update.is_empty() {
return Content {
icon: Some(DOWNLOAD_ICON),
message: format!(
"Checking for updates to {} language server{}...",
"Checking for updates to {}...",
checking_for_update.join(", "),
if checking_for_update.len() > 1 {
"s"
} else {
""
}
),
on_click: None,
};
} else if !failed.is_empty() {
}
if !failed.is_empty() {
return Content {
icon: Some(WARNING_ICON),
message: format!(
"Failed to download {} language server{}. Click to show error.",
"Failed to download {}. Click to show error.",
failed.join(", "),
if failed.len() > 1 { "s" } else { "" }
),
on_click: Some(Arc::new(|this, cx| {
this.show_error_message(&Default::default(), cx)
@@ -249,6 +241,17 @@ impl ActivityIndicator {
};
}
// Show any formatting failure
if let Some(failure) = self.project.read(cx).last_formatting_failure() {
return Content {
icon: Some(WARNING_ICON),
message: format!("Formatting failed: {}. Click to see logs.", failure),
on_click: Some(Arc::new(|_, cx| {
cx.dispatch_action(Box::new(workspace::OpenLog));
})),
};
}
// Show any application auto-update info.
if let Some(updater) = &self.auto_updater {
return match &updater.read(cx).status() {

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/ai.rs"
doctest = false
@@ -20,7 +23,6 @@ futures.workspace = true
gpui.workspace = true
isahc.workspace = true
language.workspace = true
lazy_static.workspace = true
log.workspace = true
matrixmultiply = "0.3.7"
ordered-float.workspace = true
@@ -29,6 +31,7 @@ parse_duration = "2.1.1"
postage.workspace = true
rand.workspace = true
rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] }
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
tiktoken-rs.workspace = true

View File

@@ -19,11 +19,9 @@ pub struct Embedding(pub Vec<f32>);
impl FromSql for Embedding {
fn column_result(value: ValueRef) -> FromSqlResult<Self> {
let bytes = value.as_blob()?;
let embedding: Result<Vec<f32>, Box<bincode::ErrorKind>> = bincode::deserialize(bytes);
if embedding.is_err() {
return Err(rusqlite::types::FromSqlError::Other(embedding.unwrap_err()));
}
Ok(Embedding(embedding.unwrap()))
let embedding =
bincode::deserialize(bytes).map_err(|err| rusqlite::types::FromSqlError::Other(err))?;
Ok(Embedding(embedding))
}
}
@@ -112,7 +110,7 @@ mod tests {
}
fn round_to_decimals(n: OrderedFloat<f32>, decimal_places: i32) -> f32 {
let factor = (10.0 as f32).powi(decimal_places);
let factor = 10.0_f32.powi(decimal_places);
(n * factor).round() / factor
}

View File

@@ -30,7 +30,7 @@ impl PromptArguments {
if self
.language_name
.as_ref()
.and_then(|name| Some(!["Markdown", "Plain Text"].contains(&name.as_str())))
.map(|name| !["Markdown", "Plain Text"].contains(&name.as_str()))
.unwrap_or(true)
{
PromptFileType::Code
@@ -51,8 +51,10 @@ pub trait PromptTemplate {
#[repr(i8)]
#[derive(PartialEq, Eq, Ord)]
pub enum PromptPriority {
Mandatory, // Ignores truncation
Ordered { order: usize }, // Truncates based on priority
/// Ignores truncation.
Mandatory,
/// Truncates based on priority.
Ordered { order: usize },
}
impl PartialOrd for PromptPriority {
@@ -86,7 +88,6 @@ impl PromptChain {
let mut sorted_indices = (0..self.templates.len()).collect::<Vec<_>>();
sorted_indices.sort_by_key(|&i| Reverse(&self.templates[i].0));
// If Truncate
let mut tokens_outstanding = if truncate {
Some(self.args.model.capacity()? - self.args.reserved_tokens)
} else {

View File

@@ -24,11 +24,9 @@ impl PromptCodeSnippet {
let language_name = buffer
.language()
.and_then(|language| Some(language.name().to_string().to_lowercase()));
.map(|language| language.name().to_string().to_lowercase());
let file_path = buffer
.file()
.and_then(|file| Some(file.path().to_path_buf()));
let file_path = buffer.file().map(|file| file.path().to_path_buf());
(content, language_name, file_path)
})?;
@@ -46,7 +44,7 @@ impl ToString for PromptCodeSnippet {
let path = self
.path
.as_ref()
.and_then(|path| Some(path.to_string_lossy().to_string()))
.map(|path| path.to_string_lossy().to_string())
.unwrap_or("".to_string());
let language_name = self.language_name.clone().unwrap_or("".to_string());
let content = self.content.clone();
@@ -67,7 +65,7 @@ impl PromptTemplate for RepositoryContext {
let template = "You are working inside a large repository, here are a few code snippets that may be useful.";
let mut prompt = String::new();
let mut remaining_tokens = max_token_length.clone();
let mut remaining_tokens = max_token_length;
let separator_token_length = args.model.count_tokens("\n")?;
for snippet in &args.snippets {
let mut snippet_prompt = template.to_string();

View File

@@ -6,4 +6,4 @@ pub use completion::*;
pub use embedding::*;
pub use model::OpenAiLanguageModel;
pub const OPEN_AI_API_URL: &'static str = "https://api.openai.com/v1";
pub const OPEN_AI_API_URL: &str = "https://api.openai.com/v1";

View File

@@ -1,3 +1,10 @@
use std::{
env,
fmt::{self, Display},
io,
sync::Arc,
};
use anyhow::{anyhow, Result};
use futures::{
future::BoxFuture, io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, FutureExt,
@@ -6,23 +13,17 @@ use futures::{
use gpui::{AppContext, BackgroundExecutor};
use isahc::{http::StatusCode, Request, RequestExt};
use parking_lot::RwLock;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::{
env,
fmt::{self, Display},
io,
sync::Arc,
};
use util::ResultExt;
use crate::providers::open_ai::{OpenAiLanguageModel, OPEN_AI_API_URL};
use crate::{
auth::{CredentialProvider, ProviderCredential},
completion::{CompletionProvider, CompletionRequest},
models::LanguageModel,
};
use crate::providers::open_ai::{OpenAiLanguageModel, OPEN_AI_API_URL};
#[derive(Clone, Copy, Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum Role {
@@ -102,8 +103,9 @@ pub struct OpenAiResponseStreamEvent {
pub usage: Option<OpenAiUsage>,
}
pub async fn stream_completion(
async fn stream_completion(
api_url: String,
kind: OpenAiCompletionProviderKind,
credential: ProviderCredential,
executor: BackgroundExecutor,
request: Box<dyn CompletionRequest>,
@@ -117,10 +119,11 @@ pub async fn stream_completion(
let (tx, rx) = futures::channel::mpsc::unbounded::<Result<OpenAiResponseStreamEvent>>();
let (auth_header_name, auth_header_value) = kind.auth_header(api_key);
let json_data = request.data()?;
let mut response = Request::post(format!("{api_url}/chat/completions"))
let mut response = Request::post(kind.completions_endpoint_url(&api_url))
.header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {}", api_key))
.header(auth_header_name, auth_header_value)
.body(json_data)?
.send_async()
.await?;
@@ -194,22 +197,109 @@ pub async fn stream_completion(
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
pub enum AzureOpenAiApiVersion {
/// Retiring April 2, 2024.
#[serde(rename = "2023-03-15-preview")]
V2023_03_15Preview,
#[serde(rename = "2023-05-15")]
V2023_05_15,
/// Retiring April 2, 2024.
#[serde(rename = "2023-06-01-preview")]
V2023_06_01Preview,
/// Retiring April 2, 2024.
#[serde(rename = "2023-07-01-preview")]
V2023_07_01Preview,
/// Retiring April 2, 2024.
#[serde(rename = "2023-08-01-preview")]
V2023_08_01Preview,
/// Retiring April 2, 2024.
#[serde(rename = "2023-09-01-preview")]
V2023_09_01Preview,
#[serde(rename = "2023-12-01-preview")]
V2023_12_01Preview,
#[serde(rename = "2024-02-15-preview")]
V2024_02_15Preview,
}
impl fmt::Display for AzureOpenAiApiVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
Self::V2023_03_15Preview => "2023-03-15-preview",
Self::V2023_05_15 => "2023-05-15",
Self::V2023_06_01Preview => "2023-06-01-preview",
Self::V2023_07_01Preview => "2023-07-01-preview",
Self::V2023_08_01Preview => "2023-08-01-preview",
Self::V2023_09_01Preview => "2023-09-01-preview",
Self::V2023_12_01Preview => "2023-12-01-preview",
Self::V2024_02_15Preview => "2024-02-15-preview",
}
)
}
}
#[derive(Clone)]
pub enum OpenAiCompletionProviderKind {
OpenAi,
AzureOpenAi {
deployment_id: String,
api_version: AzureOpenAiApiVersion,
},
}
impl OpenAiCompletionProviderKind {
/// Returns the chat completion endpoint URL for this [`OpenAiCompletionProviderKind`].
fn completions_endpoint_url(&self, api_url: &str) -> String {
match self {
Self::OpenAi => {
// https://platform.openai.com/docs/api-reference/chat/create
format!("{api_url}/chat/completions")
}
Self::AzureOpenAi {
deployment_id,
api_version,
} => {
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions
format!("{api_url}/openai/deployments/{deployment_id}/chat/completions?api-version={api_version}")
}
}
}
/// Returns the authentication header for this [`OpenAiCompletionProviderKind`].
fn auth_header(&self, api_key: String) -> (&'static str, String) {
match self {
Self::OpenAi => ("Authorization", format!("Bearer {api_key}")),
Self::AzureOpenAi { .. } => ("Api-Key", api_key),
}
}
}
#[derive(Clone)]
pub struct OpenAiCompletionProvider {
api_url: String,
kind: OpenAiCompletionProviderKind,
model: OpenAiLanguageModel,
credential: Arc<RwLock<ProviderCredential>>,
executor: BackgroundExecutor,
}
impl OpenAiCompletionProvider {
pub async fn new(api_url: String, model_name: String, executor: BackgroundExecutor) -> Self {
pub async fn new(
api_url: String,
kind: OpenAiCompletionProviderKind,
model_name: String,
executor: BackgroundExecutor,
) -> Self {
let model = executor
.spawn(async move { OpenAiLanguageModel::load(&model_name) })
.await;
let credential = Arc::new(RwLock::new(ProviderCredential::NoCredentials));
Self {
api_url,
kind,
model,
credential,
executor,
@@ -297,6 +387,7 @@ impl CompletionProvider for OpenAiCompletionProvider {
let model: Box<dyn LanguageModel> = Box::new(self.model.clone());
model
}
fn complete(
&self,
prompt: Box<dyn CompletionRequest>,
@@ -307,7 +398,8 @@ impl CompletionProvider for OpenAiCompletionProvider {
// At some point in the future we should rectify this.
let credential = self.credential.read().clone();
let api_url = self.api_url.clone();
let request = stream_completion(api_url, credential, self.executor.clone(), prompt);
let kind = self.kind.clone();
let request = stream_completion(api_url, kind, credential, self.executor.clone(), prompt);
async move {
let response = request.await?;
let stream = response
@@ -322,6 +414,7 @@ impl CompletionProvider for OpenAiCompletionProvider {
}
.boxed()
}
fn box_clone(&self) -> Box<dyn CompletionProvider> {
Box::new((*self).clone())
}

View File

@@ -8,7 +8,6 @@ use gpui::BackgroundExecutor;
use isahc::http::StatusCode;
use isahc::prelude::Configurable;
use isahc::{AsyncBody, Response};
use lazy_static::lazy_static;
use parking_lot::{Mutex, RwLock};
use parse_duration::parse;
use postage::watch;
@@ -16,7 +15,7 @@ use serde::{Deserialize, Serialize};
use serde_json;
use std::env;
use std::ops::Add;
use std::sync::Arc;
use std::sync::{Arc, OnceLock};
use std::time::{Duration, Instant};
use tiktoken_rs::{cl100k_base, CoreBPE};
use util::http::{HttpClient, Request};
@@ -29,8 +28,9 @@ use crate::providers::open_ai::OpenAiLanguageModel;
use crate::providers::open_ai::OPEN_AI_API_URL;
lazy_static! {
pub(crate) static ref OPEN_AI_BPE_TOKENIZER: CoreBPE = cl100k_base().unwrap();
pub(crate) fn open_ai_bpe_tokenizer() -> &'static CoreBPE {
static OPEN_AI_BPE_TOKENIZER: OnceLock<CoreBPE> = OnceLock::new();
OPEN_AI_BPE_TOKENIZER.get_or_init(|| cl100k_base().unwrap())
}
#[derive(Clone)]

View File

@@ -3,7 +3,7 @@ use tiktoken_rs::CoreBPE;
use crate::models::{LanguageModel, TruncationDirection};
use super::OPEN_AI_BPE_TOKENIZER;
use super::open_ai_bpe_tokenizer;
#[derive(Clone)]
pub struct OpenAiLanguageModel {
@@ -13,8 +13,8 @@ pub struct OpenAiLanguageModel {
impl OpenAiLanguageModel {
pub fn load(model_name: &str) -> Self {
let bpe =
tiktoken_rs::get_bpe_from_model(model_name).unwrap_or(OPEN_AI_BPE_TOKENIZER.to_owned());
let bpe = tiktoken_rs::get_bpe_from_model(model_name)
.unwrap_or(open_ai_bpe_tokenizer().to_owned());
OpenAiLanguageModel {
name: model_name.to_string(),
bpe: Some(bpe),

View File

@@ -54,6 +54,7 @@ impl LanguageModel for FakeLanguageModel {
}
}
#[derive(Default)]
pub struct FakeEmbeddingProvider {
pub embedding_count: AtomicUsize,
}
@@ -66,14 +67,6 @@ impl Clone for FakeEmbeddingProvider {
}
}
impl Default for FakeEmbeddingProvider {
fn default() -> Self {
FakeEmbeddingProvider {
embedding_count: AtomicUsize::default(),
}
}
}
impl FakeEmbeddingProvider {
pub fn embedding_count(&self) -> usize {
self.embedding_count.load(atomic::Ordering::SeqCst)

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
gpui.workspace = true

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/assistant.rs"
doctest = false

View File

@@ -7,11 +7,13 @@ use crate::{
SavedMessage, Split, ToggleFocus, ToggleIncludeConversation, ToggleRetrieveContext,
};
use ai::prompts::repository_context::PromptCodeSnippet;
use ai::providers::open_ai::OPEN_AI_API_URL;
use ai::{
auth::ProviderCredential,
completion::{CompletionProvider, CompletionRequest},
providers::open_ai::{OpenAiCompletionProvider, OpenAiRequest, RequestMessage},
providers::open_ai::{
OpenAiCompletionProvider, OpenAiCompletionProviderKind, OpenAiRequest, RequestMessage,
OPEN_AI_API_URL,
},
};
use anyhow::{anyhow, Result};
use chrono::{DateTime, Local};
@@ -29,9 +31,9 @@ use fs::Fs;
use futures::StreamExt;
use gpui::{
canvas, div, point, relative, rems, uniform_list, Action, AnyElement, AppContext,
AsyncAppContext, AsyncWindowContext, AvailableSpace, ClipboardItem, Context, EventEmitter,
FocusHandle, FocusableView, FontStyle, FontWeight, HighlightStyle, InteractiveElement,
IntoElement, Model, ModelContext, ParentElement, Pixels, PromptLevel, Render, SharedString,
AsyncAppContext, AsyncWindowContext, ClipboardItem, Context, EventEmitter, FocusHandle,
FocusableView, FontStyle, FontWeight, HighlightStyle, InteractiveElement, IntoElement, Model,
ModelContext, ParentElement, Pixels, PromptLevel, Render, SharedString,
StatefulInteractiveElement, Styled, Subscription, Task, TextStyle, UniformListScrollHandle,
View, ViewContext, VisualContext, WeakModel, WeakView, WhiteSpace, WindowContext,
};
@@ -122,15 +124,18 @@ impl AssistantPanel {
.await
.log_err()
.unwrap_or_default();
let (api_url, model_name) = cx.update(|cx| {
let (provider_kind, api_url, model_name) = cx.update(|cx| {
let settings = AssistantSettings::get_global(cx);
(
settings.openai_api_url.clone(),
settings.default_open_ai_model.full_name().to_string(),
)
})?;
anyhow::Ok((
settings.provider_kind()?,
settings.provider_api_url()?,
settings.provider_model_name()?,
))
})??;
let completion_provider = OpenAiCompletionProvider::new(
api_url,
provider_kind,
model_name,
cx.background_executor().clone(),
)
@@ -647,7 +652,7 @@ impl AssistantPanel {
// If Markdown or No Language is Known, increase the randomness for more creative output
// If Code, decrease temperature to get more deterministic outputs
let temperature = if let Some(language) = language_name.clone() {
if language.to_string() != "Markdown".to_string() {
if *language != *"Markdown" {
0.5
} else {
1.0
@@ -690,24 +695,29 @@ impl AssistantPanel {
Task::ready(Ok(Vec::new()))
};
let mut model = AssistantSettings::get_global(cx)
.default_open_ai_model
.clone();
let model_name = model.full_name();
let Some(mut model_name) = AssistantSettings::get_global(cx)
.provider_model_name()
.log_err()
else {
return;
};
let prompt = cx.background_executor().spawn(async move {
let snippets = snippets.await?;
let prompt = cx.background_executor().spawn({
let model_name = model_name.clone();
async move {
let snippets = snippets.await?;
let language_name = language_name.as_deref();
generate_content_prompt(
user_prompt,
language_name,
buffer,
range,
snippets,
model_name,
project_name,
)
let language_name = language_name.as_deref();
generate_content_prompt(
user_prompt,
language_name,
buffer,
range,
snippets,
&model_name,
project_name,
)
}
});
let mut messages = Vec::new();
@@ -719,7 +729,7 @@ impl AssistantPanel {
.messages(cx)
.map(|message| message.to_open_ai_message(buffer)),
);
model = conversation.model.clone();
model_name = conversation.model.full_name().to_string();
}
cx.spawn(|_, mut cx| async move {
@@ -732,7 +742,7 @@ impl AssistantPanel {
});
let request = Box::new(OpenAiRequest {
model: model.full_name().into(),
model: model_name,
messages,
stream: true,
stop: vec!["|END|>".to_string()],
@@ -771,7 +781,7 @@ impl AssistantPanel {
} else {
editor.highlight_background::<PendingInlineAssist>(
background_ranges,
|theme| theme.editor_active_line_background, // todo!("use the appropriate color")
|theme| theme.editor_active_line_background, // todo("use the appropriate color")
cx,
);
}
@@ -969,7 +979,7 @@ impl AssistantPanel {
font_size: rems(0.875).into(),
font_weight: FontWeight::NORMAL,
font_style: FontStyle::Normal,
line_height: relative(1.3).into(),
line_height: relative(1.3),
background_color: None,
underline: None,
strikethrough: None,
@@ -1274,25 +1284,25 @@ impl Render for AssistantPanel {
let view = cx.view().clone();
let scroll_handle = self.saved_conversations_scroll_handle.clone();
let conversation_count = self.saved_conversations.len();
canvas(move |bounds, cx| {
uniform_list(
view,
"saved_conversations",
conversation_count,
|this, range, cx| {
range
.map(|ix| this.render_saved_conversation(ix, cx))
.collect()
},
)
.track_scroll(scroll_handle)
.into_any_element()
.draw(
bounds.origin,
bounds.size.map(AvailableSpace::Definite),
cx,
);
})
canvas(
move |bounds, cx| {
let mut list = uniform_list(
view,
"saved_conversations",
conversation_count,
|this, range, cx| {
range
.map(|ix| this.render_saved_conversation(ix, cx))
.collect()
},
)
.track_scroll(scroll_handle)
.into_any_element();
list.layout(bounds.origin, bounds.size.into(), cx);
list
},
|_bounds, mut list, cx| list.paint(cx),
)
.size_full()
.into_any_element()
}),
@@ -1451,8 +1461,14 @@ impl Conversation {
});
let settings = AssistantSettings::get_global(cx);
let model = settings.default_open_ai_model.clone();
let api_url = settings.openai_api_url.clone();
let model = settings
.provider_model()
.log_err()
.unwrap_or(OpenAiModel::FourTurbo);
let api_url = settings
.provider_api_url()
.log_err()
.unwrap_or_else(|| OPEN_AI_API_URL.to_string());
let mut this = Self {
id: Some(Uuid::new_v4().to_string()),
@@ -1467,7 +1483,7 @@ impl Conversation {
max_token_count: tiktoken_rs::model::get_context_size(&model.full_name()),
pending_token_count: Task::ready(None),
api_url: Some(api_url),
model: model.clone(),
model,
_subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)],
pending_save: Task::ready(Ok(())),
path: None,
@@ -1511,7 +1527,7 @@ impl Conversation {
.as_ref()
.map(|summary| summary.text.clone())
.unwrap_or_default(),
model: self.model.clone(),
model: self.model,
api_url: self.api_url.clone(),
}
}
@@ -1533,6 +1549,7 @@ impl Conversation {
api_url
.clone()
.unwrap_or_else(|| OPEN_AI_API_URL.to_string()),
OpenAiCompletionProviderKind::OpenAi,
model.full_name().into(),
cx.background_executor().clone(),
)
@@ -1616,26 +1633,23 @@ impl Conversation {
fn count_remaining_tokens(&mut self, cx: &mut ModelContext<Self>) {
let messages = self
.messages(cx)
.into_iter()
.filter_map(|message| {
Some(tiktoken_rs::ChatCompletionRequestMessage {
role: match message.role {
Role::User => "user".into(),
Role::Assistant => "assistant".into(),
Role::System => "system".into(),
},
content: Some(
self.buffer
.read(cx)
.text_for_range(message.offset_range)
.collect(),
),
name: None,
function_call: None,
})
.map(|message| tiktoken_rs::ChatCompletionRequestMessage {
role: match message.role {
Role::User => "user".into(),
Role::Assistant => "assistant".into(),
Role::System => "system".into(),
},
content: Some(
self.buffer
.read(cx)
.text_for_range(message.offset_range)
.collect(),
),
name: None,
function_call: None,
})
.collect::<Vec<_>>();
let model = self.model.clone();
let model = self.model;
self.pending_token_count = cx.spawn(|this, mut cx| {
async move {
cx.background_executor()
@@ -2399,7 +2413,9 @@ impl ConversationEditor {
.read(cx)
.messages(cx)
.map(|message| BlockProperties {
position: buffer.anchor_in_excerpt(excerpt_id, message.anchor),
position: buffer
.anchor_in_excerpt(excerpt_id, message.anchor)
.unwrap(),
height: 2,
style: BlockStyle::Sticky,
render: Arc::new({
@@ -2818,6 +2834,7 @@ impl FocusableView for InlineAssistant {
}
impl InlineAssistant {
#[allow(clippy::too_many_arguments)]
fn new(
id: usize,
measurements: Rc<Cell<BlockMeasurements>>,
@@ -3183,7 +3200,7 @@ impl InlineAssistant {
font_size: rems(0.875).into(),
font_weight: FontWeight::NORMAL,
font_style: FontStyle::Normal,
line_height: relative(1.3).into(),
line_height: relative(1.3),
background_color: None,
underline: None,
strikethrough: None,
@@ -3651,9 +3668,9 @@ fn report_assistant_event(
let client = workspace.read(cx).project().read(cx).client();
let telemetry = client.telemetry();
let model = AssistantSettings::get_global(cx)
.default_open_ai_model
.clone();
let Ok(model_name) = AssistantSettings::get_global(cx).provider_model_name() else {
return;
};
telemetry.report_assistant_event(conversation_id, assistant_kind, model.full_name())
telemetry.report_assistant_event(conversation_id, assistant_kind, &model_name)
}

View File

@@ -1,10 +1,14 @@
use anyhow;
use ai::providers::open_ai::{
AzureOpenAiApiVersion, OpenAiCompletionProviderKind, OPEN_AI_API_URL,
};
use anyhow::anyhow;
use gpui::Pixels;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::Settings;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OpenAiModel {
#[serde(rename = "gpt-3.5-turbo-0613")]
ThreePointFiveTurbo,
@@ -17,25 +21,25 @@ pub enum OpenAiModel {
impl OpenAiModel {
pub fn full_name(&self) -> &'static str {
match self {
OpenAiModel::ThreePointFiveTurbo => "gpt-3.5-turbo-0613",
OpenAiModel::Four => "gpt-4-0613",
OpenAiModel::FourTurbo => "gpt-4-1106-preview",
Self::ThreePointFiveTurbo => "gpt-3.5-turbo-0613",
Self::Four => "gpt-4-0613",
Self::FourTurbo => "gpt-4-1106-preview",
}
}
pub fn short_name(&self) -> &'static str {
match self {
OpenAiModel::ThreePointFiveTurbo => "gpt-3.5-turbo",
OpenAiModel::Four => "gpt-4",
OpenAiModel::FourTurbo => "gpt-4-turbo",
Self::ThreePointFiveTurbo => "gpt-3.5-turbo",
Self::Four => "gpt-4",
Self::FourTurbo => "gpt-4-turbo",
}
}
pub fn cycle(&self) -> Self {
match self {
OpenAiModel::ThreePointFiveTurbo => OpenAiModel::Four,
OpenAiModel::Four => OpenAiModel::FourTurbo,
OpenAiModel::FourTurbo => OpenAiModel::ThreePointFiveTurbo,
Self::ThreePointFiveTurbo => Self::Four,
Self::Four => Self::FourTurbo,
Self::FourTurbo => Self::ThreePointFiveTurbo,
}
}
}
@@ -48,14 +52,113 @@ pub enum AssistantDockPosition {
Bottom,
}
#[derive(Deserialize, Debug)]
#[derive(Debug, Deserialize)]
pub struct AssistantSettings {
/// Whether to show the assistant panel button in the status bar.
pub button: bool,
/// Where to dock the assistant.
pub dock: AssistantDockPosition,
/// Default width in pixels when the assistant is docked to the left or right.
pub default_width: Pixels,
/// Default height in pixels when the assistant is docked to the bottom.
pub default_height: Pixels,
/// The default OpenAI model to use when starting new conversations.
#[deprecated = "Please use `provider.default_model` instead."]
pub default_open_ai_model: OpenAiModel,
/// OpenAI API base URL to use when starting new conversations.
#[deprecated = "Please use `provider.api_url` instead."]
pub openai_api_url: String,
/// The settings for the AI provider.
pub provider: AiProviderSettings,
}
impl AssistantSettings {
pub fn provider_kind(&self) -> anyhow::Result<OpenAiCompletionProviderKind> {
match &self.provider {
AiProviderSettings::OpenAi(_) => Ok(OpenAiCompletionProviderKind::OpenAi),
AiProviderSettings::AzureOpenAi(settings) => {
let deployment_id = settings
.deployment_id
.clone()
.ok_or_else(|| anyhow!("no Azure OpenAI deployment ID"))?;
let api_version = settings
.api_version
.ok_or_else(|| anyhow!("no Azure OpenAI API version"))?;
Ok(OpenAiCompletionProviderKind::AzureOpenAi {
deployment_id,
api_version,
})
}
}
}
pub fn provider_api_url(&self) -> anyhow::Result<String> {
match &self.provider {
AiProviderSettings::OpenAi(settings) => Ok(settings
.api_url
.clone()
.unwrap_or_else(|| OPEN_AI_API_URL.to_string())),
AiProviderSettings::AzureOpenAi(settings) => settings
.api_url
.clone()
.ok_or_else(|| anyhow!("no Azure OpenAI API URL")),
}
}
pub fn provider_model(&self) -> anyhow::Result<OpenAiModel> {
match &self.provider {
AiProviderSettings::OpenAi(settings) => {
Ok(settings.default_model.unwrap_or(OpenAiModel::FourTurbo))
}
AiProviderSettings::AzureOpenAi(settings) => {
let deployment_id = settings
.deployment_id
.as_deref()
.ok_or_else(|| anyhow!("no Azure OpenAI deployment ID"))?;
match deployment_id {
// https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4-and-gpt-4-turbo-preview
"gpt-4" | "gpt-4-32k" => Ok(OpenAiModel::Four),
// https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-35
"gpt-35-turbo" | "gpt-35-turbo-16k" | "gpt-35-turbo-instruct" => {
Ok(OpenAiModel::ThreePointFiveTurbo)
}
_ => Err(anyhow!(
"no matching OpenAI model found for deployment ID: '{deployment_id}'"
)),
}
}
}
}
pub fn provider_model_name(&self) -> anyhow::Result<String> {
match &self.provider {
AiProviderSettings::OpenAi(settings) => Ok(settings
.default_model
.unwrap_or(OpenAiModel::FourTurbo)
.full_name()
.to_string()),
AiProviderSettings::AzureOpenAi(settings) => settings
.deployment_id
.clone()
.ok_or_else(|| anyhow!("no Azure OpenAI deployment ID")),
}
}
}
impl Settings for AssistantSettings {
const KEY: Option<&'static str> = Some("assistant");
type FileContent = AssistantSettingsContent;
fn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
_: &mut gpui::AppContext,
) -> anyhow::Result<Self> {
Self::load_via_json_merge(default_value, user_values)
}
}
/// Assistant panel settings
@@ -77,26 +180,88 @@ pub struct AssistantSettingsContent {
///
/// Default: 320
pub default_height: Option<f32>,
/// Deprecated: Please use `provider.default_model` instead.
/// The default OpenAI model to use when starting new conversations.
///
/// Default: gpt-4-1106-preview
#[deprecated = "Please use `provider.default_model` instead."]
pub default_open_ai_model: Option<OpenAiModel>,
/// Deprecated: Please use `provider.api_url` instead.
/// OpenAI API base URL to use when starting new conversations.
///
/// Default: https://api.openai.com/v1
#[deprecated = "Please use `provider.api_url` instead."]
pub openai_api_url: Option<String>,
/// The settings for the AI provider.
#[serde(default)]
pub provider: AiProviderSettingsContent,
}
impl Settings for AssistantSettings {
const KEY: Option<&'static str> = Some("assistant");
#[derive(Debug, Clone, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum AiProviderSettings {
/// The settings for the OpenAI provider.
#[serde(rename = "openai")]
OpenAi(OpenAiProviderSettings),
/// The settings for the Azure OpenAI provider.
#[serde(rename = "azure_openai")]
AzureOpenAi(AzureOpenAiProviderSettings),
}
type FileContent = AssistantSettingsContent;
/// The settings for the AI provider used by the Zed Assistant.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum AiProviderSettingsContent {
/// The settings for the OpenAI provider.
#[serde(rename = "openai")]
OpenAi(OpenAiProviderSettingsContent),
/// The settings for the Azure OpenAI provider.
#[serde(rename = "azure_openai")]
AzureOpenAi(AzureOpenAiProviderSettingsContent),
}
fn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
_: &mut gpui::AppContext,
) -> anyhow::Result<Self> {
Self::load_via_json_merge(default_value, user_values)
impl Default for AiProviderSettingsContent {
fn default() -> Self {
Self::OpenAi(OpenAiProviderSettingsContent::default())
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct OpenAiProviderSettings {
/// The OpenAI API base URL to use when starting new conversations.
pub api_url: Option<String>,
/// The default OpenAI model to use when starting new conversations.
pub default_model: Option<OpenAiModel>,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct OpenAiProviderSettingsContent {
/// The OpenAI API base URL to use when starting new conversations.
///
/// Default: https://api.openai.com/v1
pub api_url: Option<String>,
/// The default OpenAI model to use when starting new conversations.
///
/// Default: gpt-4-1106-preview
pub default_model: Option<OpenAiModel>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct AzureOpenAiProviderSettings {
/// The Azure OpenAI API base URL to use when starting new conversations.
pub api_url: Option<String>,
/// The Azure OpenAI API version.
pub api_version: Option<AzureOpenAiApiVersion>,
/// The Azure OpenAI API deployment ID.
pub deployment_id: Option<String>,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct AzureOpenAiProviderSettingsContent {
/// The Azure OpenAI API base URL to use when starting new conversations.
pub api_url: Option<String>,
/// The Azure OpenAI API version.
pub api_version: Option<AzureOpenAiApiVersion>,
/// The Azure OpenAI deployment ID.
pub deployment_id: Option<String>,
}

View File

@@ -297,7 +297,7 @@ fn strip_invalid_spans_from_codeblock(
} else if buffer.starts_with("<|")
|| buffer.starts_with("<|S")
|| buffer.starts_with("<|S|")
|| buffer.ends_with("|")
|| buffer.ends_with('|')
|| buffer.ends_with("|E")
|| buffer.ends_with("|E|")
{
@@ -335,7 +335,7 @@ fn strip_invalid_spans_from_codeblock(
.strip_suffix("|E|>")
.or_else(|| text.strip_suffix("E|>"))
.or_else(|| text.strip_prefix("|>"))
.or_else(|| text.strip_prefix(">"))
.or_else(|| text.strip_prefix('>'))
.unwrap_or(&text)
.to_string();
};

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/audio.rs"
doctest = false

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/auto_update.rs"
doctest = false

View File

@@ -20,7 +20,7 @@ use smol::io::AsyncReadExt;
use settings::{Settings, SettingsStore};
use smol::{fs::File, process::Command};
use release_channel::{AppCommitSha, ReleaseChannel};
use release_channel::{AppCommitSha, AppVersion, ReleaseChannel};
use std::{
env::consts::{ARCH, OS},
ffi::OsString,
@@ -190,7 +190,7 @@ pub fn view_release_notes(_: &ViewReleaseNotes, cx: &mut AppContext) -> Option<(
fn view_release_notes_locally(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
let release_channel = ReleaseChannel::global(cx);
let version = env!("CARGO_PKG_VERSION");
let version = AppVersion::global(cx).to_string();
let client = client::Client::global(cx).http_client();
let url = client.build_url(&format!(
@@ -229,6 +229,7 @@ fn view_release_notes_locally(workspace: &mut Workspace, cx: &mut ViewContext<Wo
buffer.update(cx, |buffer, cx| {
buffer.edit([(0..0, body.release_notes)], None, cx)
});
let language_registry = project.read(cx).languages().clone();
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
@@ -240,9 +241,10 @@ fn view_release_notes_locally(workspace: &mut Workspace, cx: &mut ViewContext<Wo
editor,
workspace_handle,
Some(tab_description),
language_registry,
cx,
);
workspace.add_item(Box::new(view.clone()), cx);
workspace.add_item_to_active_pane(Box::new(view.clone()), cx);
cx.notify();
})
.log_err();
@@ -343,8 +345,7 @@ impl AutoUpdater {
));
cx.update(|cx| {
if let Some(param) = ReleaseChannel::try_global(cx)
.map(|release_channel| release_channel.release_query_param())
.flatten()
.and_then(|release_channel| release_channel.release_query_param())
{
url_string += "&";
url_string += param;

View File

@@ -44,7 +44,7 @@ impl Render for UpdateNotification {
crate::view_release_notes(&Default::default(), cx);
this.dismiss(&menu::Cancel, cx)
})),
);
)
}
}

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/breadcrumbs.rs"
doctest = false

View File

@@ -4,10 +4,11 @@ use gpui::{
ViewContext,
};
use itertools::Itertools;
use std::cmp;
use theme::ActiveTheme;
use ui::{prelude::*, ButtonLike, ButtonStyle, Label, Tooltip};
use workspace::{
item::{ItemEvent, ItemHandle},
item::{BreadcrumbText, ItemEvent, ItemHandle},
ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView,
};
@@ -31,14 +32,30 @@ impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {}
impl Render for Breadcrumbs {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
const MAX_SEGMENTS: usize = 12;
let element = h_flex().text_ui();
let Some(active_item) = self.active_item.as_ref() else {
return element;
};
let Some(segments) = active_item.breadcrumbs(cx.theme(), cx) else {
let Some(mut segments) = active_item.breadcrumbs(cx.theme(), cx) else {
return element;
};
let prefix_end_ix = cmp::min(segments.len(), MAX_SEGMENTS / 2);
let suffix_start_ix = cmp::max(
prefix_end_ix,
segments.len().saturating_sub(MAX_SEGMENTS / 2),
);
if suffix_start_ix > prefix_end_ix {
segments.splice(
prefix_end_ix..suffix_start_ix,
Some(BreadcrumbText {
text: "".into(),
highlights: None,
}),
);
}
let highlighted_segments = segments.into_iter().map(|segment| {
let mut text_style = cx.text_style();
text_style.color = Color::Muted.color(cx);

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/call.rs"
doctest = false

View File

@@ -302,7 +302,7 @@ impl ActiveCall {
return Task::ready(Ok(()));
}
let room_id = call.room_id.clone();
let room_id = call.room_id;
let client = self.client.clone();
let user_store = self.user_store.clone();
let join = self

View File

@@ -1182,19 +1182,10 @@ impl Room {
) -> Task<Result<Model<Project>>> {
let client = self.client.clone();
let user_store = self.user_store.clone();
let role = self.local_participant.role;
cx.emit(Event::RemoteProjectJoined { project_id: id });
cx.spawn(move |this, mut cx| async move {
let project = Project::remote(
id,
client,
user_store,
language_registry,
fs,
role,
cx.clone(),
)
.await?;
let project =
Project::remote(id, client, user_store, language_registry, fs, cx.clone()).await?;
this.update(&mut cx, |this, cx| {
this.joined_projects.retain(|project| {

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/channel.rs"
doctest = false

View File

@@ -11,7 +11,7 @@ pub use channel_chat::{
mentions_to_proto, ChannelChat, ChannelChatEvent, ChannelMessage, ChannelMessageId,
MessageParams,
};
pub use channel_store::{Channel, ChannelEvent, ChannelMembership, ChannelStore, HostedProjectId};
pub use channel_store::{Channel, ChannelEvent, ChannelMembership, ChannelStore};
#[cfg(test)]
mod channel_store_tests;

View File

@@ -126,7 +126,7 @@ impl ChannelBuffer {
for (_, old_collaborator) in &self.collaborators {
if !new_collaborators.contains_key(&old_collaborator.peer_id) {
self.buffer.update(cx, |buffer, cx| {
buffer.remove_peer(old_collaborator.replica_id as u16, cx)
buffer.remove_peer(old_collaborator.replica_id, cx)
});
}
}

View File

@@ -681,7 +681,7 @@ pub fn mentions_to_proto(mentions: &[(Range<usize>, UserId)]) -> Vec<proto::Chat
start: range.start as u64,
end: range.end as u64,
}),
user_id: *user_id as u64,
user_id: *user_id,
})
.collect()
}

View File

@@ -3,7 +3,7 @@ mod channel_index;
use crate::{channel_buffer::ChannelBuffer, channel_chat::ChannelChat, ChannelMessage};
use anyhow::{anyhow, Result};
use channel_index::ChannelIndex;
use client::{ChannelId, Client, Subscription, User, UserId, UserStore};
use client::{ChannelId, Client, ClientSettings, ProjectId, Subscription, User, UserId, UserStore};
use collections::{hash_map, HashMap, HashSet};
use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt};
use gpui::{
@@ -11,11 +11,11 @@ use gpui::{
Task, WeakModel,
};
use language::Capability;
use release_channel::RELEASE_CHANNEL;
use rpc::{
proto::{self, ChannelRole, ChannelVisibility},
TypedEnvelope,
};
use settings::Settings;
use std::{mem, sync::Arc, time::Duration};
use util::{async_maybe, maybe, ResultExt};
@@ -27,10 +27,7 @@ pub fn init(client: &Arc<Client>, user_store: Model<UserStore>, cx: &mut AppCont
cx.set_global(GlobalChannelStore(channel_store));
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub struct HostedProjectId(pub u64);
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone, Default, PartialEq)]
struct NotesVersion {
epoch: u64,
version: clock::Global,
@@ -38,7 +35,7 @@ struct NotesVersion {
#[derive(Debug, Clone)]
pub struct HostedProject {
id: HostedProjectId,
project_id: ProjectId,
channel_id: ChannelId,
name: SharedString,
_visibility: proto::ChannelVisibility,
@@ -47,7 +44,7 @@ pub struct HostedProject {
impl From<proto::HostedProject> for HostedProject {
fn from(project: proto::HostedProject) -> Self {
Self {
id: HostedProjectId(project.id),
project_id: ProjectId(project.project_id),
channel_id: ChannelId(project.channel_id),
_visibility: project.visibility(),
name: project.name.into(),
@@ -60,7 +57,7 @@ pub struct ChannelStore {
channel_invitations: Vec<Arc<Channel>>,
channel_participants: HashMap<ChannelId, Vec<Arc<User>>>,
channel_states: HashMap<ChannelId, ChannelState>,
hosted_projects: HashMap<HostedProjectId, HostedProject>,
hosted_projects: HashMap<ProjectId, HostedProject>,
outgoing_invites: HashSet<(ChannelId, UserId)>,
update_channels_tx: mpsc::UnboundedSender<proto::UpdateChannels>,
@@ -82,27 +79,28 @@ pub struct Channel {
pub parent_path: Vec<ChannelId>,
}
#[derive(Default)]
#[derive(Default, Debug)]
pub struct ChannelState {
latest_chat_message: Option<u64>,
latest_notes_versions: Option<NotesVersion>,
latest_notes_version: NotesVersion,
observed_notes_version: NotesVersion,
observed_chat_message: Option<u64>,
observed_notes_versions: Option<NotesVersion>,
role: Option<ChannelRole>,
projects: HashSet<HostedProjectId>,
projects: HashSet<ProjectId>,
}
impl Channel {
pub fn link(&self) -> String {
RELEASE_CHANNEL.link_prefix().to_owned()
+ "channel/"
+ &Self::slug(&self.name)
+ "-"
+ &self.id.to_string()
pub fn link(&self, cx: &AppContext) -> String {
format!(
"{}/channel/{}-{}",
ClientSettings::get_global(cx).server_url,
Self::slug(&self.name),
self.id
)
}
pub fn notes_link(&self, heading: Option<String>) -> String {
self.link()
pub fn notes_link(&self, heading: Option<String>, cx: &AppContext) -> String {
self.link(cx)
+ "/notes"
+ &heading
.map(|h| format!("#{}", Self::slug(&h)))
@@ -305,8 +303,8 @@ impl ChannelStore {
self.channel_index.by_id().get(&channel_id)
}
pub fn projects_for_id(&self, channel_id: ChannelId) -> Vec<(SharedString, HostedProjectId)> {
let mut projects: Vec<(SharedString, HostedProjectId)> = self
pub fn projects_for_id(&self, channel_id: ChannelId) -> Vec<(SharedString, ProjectId)> {
let mut projects: Vec<(SharedString, ProjectId)> = self
.channel_states
.get(&channel_id)
.map(|state| state.projects.clone())
@@ -592,7 +590,7 @@ impl ChannelStore {
cx: &mut ModelContext<Self>,
) -> Task<Result<ChannelId>> {
let client = self.client.clone();
let name = name.trim_start_matches("#").to_owned();
let name = name.trim_start_matches('#').to_owned();
cx.spawn(move |this, mut cx| async move {
let response = client
.request(proto::CreateChannel {
@@ -839,12 +837,10 @@ impl ChannelStore {
Ok(users
.into_iter()
.zip(response.members)
.filter_map(|(user, member)| {
Some(ChannelMembership {
user,
role: member.role(),
kind: member.kind(),
})
.map(|(user, member)| ChannelMembership {
user,
role: member.role(),
kind: member.kind(),
})
.collect())
})
@@ -1161,27 +1157,27 @@ impl ChannelStore {
let hosted_project: HostedProject = hosted_project.into();
if let Some(old_project) = self
.hosted_projects
.insert(hosted_project.id, hosted_project.clone())
.insert(hosted_project.project_id, hosted_project.clone())
{
self.channel_states
.entry(old_project.channel_id)
.or_default()
.remove_hosted_project(old_project.id);
.remove_hosted_project(old_project.project_id);
}
self.channel_states
.entry(hosted_project.channel_id)
.or_default()
.add_hosted_project(hosted_project.id);
.add_hosted_project(hosted_project.project_id);
}
for hosted_project_id in payload.deleted_hosted_projects {
let hosted_project_id = HostedProjectId(hosted_project_id);
let hosted_project_id = ProjectId(hosted_project_id);
if let Some(old_project) = self.hosted_projects.remove(&hosted_project_id) {
self.channel_states
.entry(old_project.channel_id)
.or_default()
.remove_hosted_project(old_project.id);
.remove_hosted_project(old_project.project_id);
}
}
}
@@ -1238,19 +1234,12 @@ impl ChannelState {
}
fn has_channel_buffer_changed(&self) -> bool {
if let Some(latest_version) = &self.latest_notes_versions {
if let Some(observed_version) = &self.observed_notes_versions {
latest_version.epoch > observed_version.epoch
|| (latest_version.epoch == observed_version.epoch
&& latest_version
.version
.changed_since(&observed_version.version))
} else {
true
}
} else {
false
}
self.latest_notes_version.epoch > self.observed_notes_version.epoch
|| (self.latest_notes_version.epoch == self.observed_notes_version.epoch
&& self
.latest_notes_version
.version
.changed_since(&self.observed_notes_version.version))
}
fn has_new_messages(&self) -> bool {
@@ -1277,36 +1266,32 @@ impl ChannelState {
}
fn acknowledge_notes_version(&mut self, epoch: u64, version: &clock::Global) {
if let Some(existing) = &mut self.observed_notes_versions {
if existing.epoch == epoch {
existing.version.join(version);
return;
}
if self.observed_notes_version.epoch == epoch {
self.observed_notes_version.version.join(version);
} else {
self.observed_notes_version = NotesVersion {
epoch,
version: version.clone(),
};
}
self.observed_notes_versions = Some(NotesVersion {
epoch,
version: version.clone(),
});
}
fn update_latest_notes_version(&mut self, epoch: u64, version: &clock::Global) {
if let Some(existing) = &mut self.latest_notes_versions {
if existing.epoch == epoch {
existing.version.join(version);
return;
}
if self.latest_notes_version.epoch == epoch {
self.latest_notes_version.version.join(version);
} else {
self.latest_notes_version = NotesVersion {
epoch,
version: version.clone(),
};
}
self.latest_notes_versions = Some(NotesVersion {
epoch,
version: version.clone(),
});
}
fn add_hosted_project(&mut self, project_id: HostedProjectId) {
fn add_hosted_project(&mut self, project_id: ProjectId) {
self.projects.insert(project_id);
}
fn remove_hosted_project(&mut self, project_id: HostedProjectId) {
fn remove_hosted_project(&mut self, project_id: ProjectId) {
self.projects.remove(&project_id);
}
}

View File

@@ -97,9 +97,9 @@ impl<'a> Drop for ChannelPathsInsertGuard<'a> {
}
}
fn channel_path_sorting_key<'a>(
fn channel_path_sorting_key(
id: ChannelId,
channels_by_id: &'a BTreeMap<ChannelId, Arc<Channel>>,
channels_by_id: &BTreeMap<ChannelId, Arc<Channel>>,
) -> impl Iterator<Item = (&str, ChannelId)> {
let (parent_path, name) = channels_by_id
.get(&id)

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/cli.rs"
doctest = false
@@ -15,6 +18,7 @@ path = "src/main.rs"
[dependencies]
anyhow.workspace = true
# TODO: Use workspace version of `clap`.
clap = { version = "3.1", features = ["derive"] }
ipc-channel = "0.16"
serde.workspace = true

View File

@@ -9,12 +9,11 @@ pub struct IpcHandshake {
#[derive(Debug, Serialize, Deserialize)]
pub enum CliRequest {
// The filed is named `path` for compatibility, but now CLI can request
// opening a path at a certain row and/or column: `some/path:123` and `some/path:123:456`.
//
// Since Zed CLI has to be installed separately, there can be situations when old CLI is
// querying new Zed editors, support both formats by using `String` here and parsing it on Zed side later.
Open { paths: Vec<String>, wait: bool },
Open {
paths: Vec<String>,
wait: bool,
open_new_workspace: Option<bool>,
},
}
#[derive(Debug, Serialize, Deserialize)]

View File

@@ -5,19 +5,25 @@ use clap::Parser;
use cli::{CliRequest, CliResponse};
use serde::Deserialize;
use std::{
env,
ffi::OsStr,
fs::{self, OpenOptions},
io,
fs::{self},
path::{Path, PathBuf},
};
use util::paths::PathLikeWithPosition;
#[derive(Parser)]
#[derive(Parser, Debug)]
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
struct Args {
/// Wait for all of the given paths to be opened/closed before exiting.
#[clap(short, long)]
wait: bool,
/// Add files to the currently open workspace
#[clap(short, long, overrides_with = "new")]
add: bool,
/// Create a new workspace
#[clap(short, long, overrides_with = "add")]
new: bool,
/// A sequence of space-separated paths that you want to open.
///
/// Use `path:line:row` syntax to open a file at a specific location.
@@ -56,31 +62,41 @@ fn main() -> Result<()> {
return Ok(());
}
for path in args
.paths_with_position
.iter()
.map(|path_with_position| &path_with_position.path_like)
{
if !path.exists() {
touch(path.as_path())?;
}
let curdir = env::current_dir()?;
let mut paths = vec![];
for path in args.paths_with_position {
let canonicalized = path.map_path_like(|path| match fs::canonicalize(&path) {
Ok(path) => Ok(path),
Err(e) => {
if let Some(mut parent) = path.parent() {
if parent == Path::new("") {
parent = &curdir;
}
match fs::canonicalize(parent) {
Ok(parent) => Ok(parent.join(path.file_name().unwrap())),
Err(_) => Err(e),
}
} else {
Err(e)
}
}
})?;
paths.push(canonicalized.to_string(|path| path.display().to_string()))
}
let (tx, rx) = bundle.launch()?;
let open_new_workspace = if args.new {
Some(true)
} else if args.add {
Some(false)
} else {
None
};
tx.send(CliRequest::Open {
paths: args
.paths_with_position
.into_iter()
.map(|path_with_position| {
let path_with_position = path_with_position.map_path_like(|path| {
fs::canonicalize(&path)
.with_context(|| format!("path {path:?} canonicalization"))
})?;
Ok(path_with_position.to_string(|path| path.display().to_string()))
})
.collect::<Result<_>>()?,
paths,
wait: args.wait,
open_new_workspace,
})?;
while let Ok(response) = rx.recv() {
@@ -106,13 +122,6 @@ enum Bundle {
},
}
fn touch(path: &Path) -> io::Result<()> {
match OpenOptions::new().create(true).write(true).open(path) {
Ok(_) => Ok(()),
Err(e) => Err(e),
}
}
fn locate_bundle() -> Result<PathBuf> {
let cli_path = std::env::current_exe()?.canonicalize()?;
let mut app_path = cli_path.clone();
@@ -156,7 +165,7 @@ mod linux {
}
}
// todo!("windows")
// todo("windows")
#[cfg(target_os = "windows")]
mod windows {
use std::path::Path;

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/client.rs"
doctest = false

View File

@@ -27,7 +27,7 @@ use release_channel::{AppVersion, ReleaseChannel};
use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json;
use settings::{Settings, SettingsStore};
use std::{
any::TypeId,
@@ -61,7 +61,7 @@ lazy_static! {
pub static ref ZED_APP_PATH: Option<PathBuf> =
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
pub static ref ZED_ALWAYS_ACTIVE: bool =
std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| e.len() > 0);
std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| !e.is_empty());
}
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100);
@@ -427,7 +427,7 @@ impl Client {
http: Arc<HttpClientWithUrl>,
cx: &mut AppContext,
) -> Arc<Self> {
let client = Arc::new(Self {
Arc::new(Self {
id: AtomicU64::new(0),
peer: Peer::new(0),
telemetry: Telemetry::new(clock, http.clone(), cx),
@@ -438,9 +438,7 @@ impl Client {
authenticate: Default::default(),
#[cfg(any(test, feature = "test-support"))]
establish_connection: Default::default(),
});
client
})
}
pub fn id(&self) -> u64 {
@@ -573,17 +571,18 @@ impl Client {
let mut state = self.state.write();
if state.entities_by_type_and_remote_id.contains_key(&id) {
return Err(anyhow!("already subscribed to entity"));
} else {
state
.entities_by_type_and_remote_id
.insert(id, WeakSubscriber::Pending(Default::default()));
Ok(PendingEntitySubscription {
client: self.clone(),
remote_id,
consumed: false,
_entity_type: PhantomData,
})
}
state
.entities_by_type_and_remote_id
.insert(id, WeakSubscriber::Pending(Default::default()));
Ok(PendingEntitySubscription {
client: self.clone(),
remote_id,
consumed: false,
_entity_type: PhantomData,
})
}
#[track_caller]
@@ -926,7 +925,7 @@ impl Client {
move |cx| async move {
match handle_io.await {
Ok(()) => {
if this.status().borrow().clone()
if *this.status().borrow()
== (Status::Connected {
connection_id,
peer_id,
@@ -1335,7 +1334,7 @@ impl Client {
pending.push(message);
return;
}
Some(weak_subscriber @ _) => match weak_subscriber {
Some(weak_subscriber) => match weak_subscriber {
WeakSubscriber::Entity { handle } => {
subscriber = handle.upgrade();
}
@@ -1438,21 +1437,29 @@ async fn delete_credentials_from_keychain(cx: &AsyncAppContext) -> Result<()> {
.await
}
const WORKTREE_URL_PREFIX: &str = "zed://worktrees/";
/// prefix for the zed:// url scheme
pub static ZED_URL_SCHEME: &str = "zed";
pub fn encode_worktree_url(id: u64, access_token: &str) -> String {
format!("{}{}/{}", WORKTREE_URL_PREFIX, id, access_token)
}
pub fn decode_worktree_url(url: &str) -> Option<(u64, String)> {
let path = url.trim().strip_prefix(WORKTREE_URL_PREFIX)?;
let mut parts = path.split('/');
let id = parts.next()?.parse::<u64>().ok()?;
let access_token = parts.next()?;
if access_token.is_empty() {
return None;
/// Parses the given link into a Zed link.
///
/// Returns a [`Some`] containing the unprefixed link if the link is a Zed link.
/// Returns [`None`] otherwise.
pub fn parse_zed_link<'a>(link: &'a str, cx: &AppContext) -> Option<&'a str> {
let server_url = &ClientSettings::get_global(cx).server_url;
if let Some(stripped) = link
.strip_prefix(server_url)
.and_then(|result| result.strip_prefix('/'))
{
return Some(stripped);
}
Some((id, access_token.to_string()))
if let Some(stripped) = link
.strip_prefix(ZED_URL_SCHEME)
.and_then(|result| result.strip_prefix("://"))
{
return Some(stripped);
}
None
}
#[cfg(test)]
@@ -1630,17 +1637,6 @@ mod tests {
assert_eq!(*dropped_auth_count.lock(), 1);
}
#[test]
fn test_encode_and_decode_worktree_url() {
let url = encode_worktree_url(5, "deadbeef");
assert_eq!(decode_worktree_url(&url), Some((5, "deadbeef".to_string())));
assert_eq!(
decode_worktree_url(&format!("\n {}\t", url)),
Some((5, "deadbeef".to_string()))
);
assert_eq!(decode_worktree_url("not://the-right-format"), None);
}
#[gpui::test]
async fn test_subscribing_to_entity(cx: &mut TestAppContext) {
init_test(cx);

View File

@@ -12,9 +12,7 @@ use settings::{Settings, SettingsStore};
use sha2::{Digest, Sha256};
use std::io::Write;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use sysinfo::{
CpuRefreshKind, Pid, PidExt, ProcessExt, ProcessRefreshKind, RefreshKind, System, SystemExt,
};
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, Pid, ProcessRefreshKind, RefreshKind, System};
use telemetry_events::{
ActionEvent, AppEvent, AssistantEvent, AssistantKind, CallEvent, CopilotEvent, CpuEvent,
EditEvent, EditorEvent, Event, EventRequestBody, EventWrapper, MemoryEvent, SettingEvent,
@@ -84,7 +82,7 @@ impl Telemetry {
TelemetrySettings::register(cx);
let state = Arc::new(Mutex::new(TelemetryState {
settings: TelemetrySettings::get_global(cx).clone(),
settings: *TelemetrySettings::get_global(cx),
app_metadata: cx.app_metadata(),
architecture: env::consts::ARCH,
release_channel,
@@ -119,7 +117,7 @@ impl Telemetry {
move |cx| {
let mut state = state.lock();
state.settings = TelemetrySettings::get_global(cx).clone();
state.settings = *TelemetrySettings::get_global(cx);
}
})
.detach();
@@ -168,14 +166,14 @@ impl Telemetry {
) {
let mut state = self.state.lock();
state.installation_id = installation_id.map(|id| id.into());
state.session_id = Some(session_id.into());
state.session_id = Some(session_id);
drop(state);
let this = self.clone();
cx.spawn(|_| async move {
// Avoiding calling `System::new_all()`, as there have been crashes related to it
let refresh_kind = RefreshKind::new()
.with_memory() // For memory usage
.with_memory(MemoryRefreshKind::everything()) // For memory usage
.with_processes(ProcessRefreshKind::everything()) // For process usage
.with_cpu(CpuRefreshKind::everything()); // For core count
@@ -263,7 +261,7 @@ impl Telemetry {
self: &Arc<Self>,
conversation_id: Option<String>,
kind: AssistantKind,
model: &'static str,
model: &str,
) {
let event = Event::Assistant(AssistantEvent {
conversation_id,
@@ -387,11 +385,9 @@ impl Telemetry {
event,
});
if state.installation_id.is_some() {
if state.events_queue.len() >= state.max_queue_size {
drop(state);
self.flush_events();
}
if state.installation_id.is_some() && state.events_queue.len() >= state.max_queue_size {
drop(state);
self.flush_events();
}
}
@@ -433,7 +429,7 @@ impl Telemetry {
json_bytes.clear();
serde_json::to_writer(&mut json_bytes, event)?;
file.write_all(&json_bytes)?;
file.write(b"\n")?;
file.write_all(b"\n")?;
}
}
@@ -442,7 +438,7 @@ impl Telemetry {
let request_body = EventRequestBody {
installation_id: state.installation_id.as_deref().map(Into::into),
session_id: state.session_id.clone(),
is_staff: state.is_staff.clone(),
is_staff: state.is_staff,
app_version: state
.app_metadata
.app_version

View File

@@ -24,6 +24,9 @@ impl std::fmt::Display for ChannelId {
}
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub struct ProjectId(pub u64);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ParticipantIndex(pub u32);
@@ -653,7 +656,7 @@ impl UserStore {
let users = response
.users
.into_iter()
.map(|user| User::new(user))
.map(User::new)
.collect::<Vec<_>>();
this.update(&mut cx, |this, _| {

View File

@@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/clock.rs"
doctest = false

View File

@@ -19,5 +19,7 @@ ZED_CLIENT_CHECKSUM_SEED = "development-checksum-seed"
# CLICKHOUSE_PASSWORD = ""
# CLICKHOUSE_DATABASE = "default"
# SLACK_PANICS_WEBHOOK = ""
# RUST_LOG=info
# LOG_JSON=true

View File

@@ -7,23 +7,23 @@ version = "0.44.0"
publish = false
license = "AGPL-3.0-or-later"
[features]
seed-support = ["reqwest"]
[lints]
workspace = true
[[bin]]
name = "collab"
[[bin]]
name = "seed"
required-features = ["seed-support"]
[dependencies]
anyhow.workspace = true
async-tungstenite = "0.16"
aws-config = { version = "1.1.5" }
aws-sdk-s3 = { version = "1.15.0" }
axum = { version = "0.5", features = ["json", "headers", "ws"] }
axum-extra = { version = "0.3", features = ["erased-json"] }
axum = { version = "0.6", features = ["json", "headers", "ws"] }
axum-extra = { version = "0.4", features = ["erased-json"] }
base64.workspace = true
chrono.workspace = true
clock.workspace = true
clickhouse.workspace = true
@@ -32,8 +32,6 @@ dashmap = "5.4"
envy = "0.4.2"
futures.workspace = true
hex.workspace = true
hyper = "0.14"
lazy_static.workspace = true
live_kit_server.workspace = true
log.workspace = true
nanoid = "0.4"
@@ -41,7 +39,7 @@ parking_lot.workspace = true
prometheus = "0.13"
prost.workspace = true
rand.workspace = true
reqwest = { version = "0.11", features = ["json"], optional = true }
reqwest = { version = "0.11", features = ["json"] }
rpc.workspace = true
scrypt = "0.7"
sea-orm = { version = "0.12.x", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
@@ -51,6 +49,8 @@ serde_derive.workspace = true
serde_json.workspace = true
sha2.workspace = true
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "postgres", "json", "time", "uuid", "any"] }
subtle.workspace = true
rustc-demangle.workspace = true
telemetry_events.workspace = true
text.workspace = true
time.workspace = true
@@ -59,8 +59,7 @@ toml.workspace = true
tower = "0.4"
tower-http = { workspace = true, features = ["trace"] }
tracing = "0.1.34"
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json", "registry", "tracing-log"] }
util.workspace = true
uuid.workspace = true

View File

@@ -11,6 +11,8 @@ metadata:
namespace: ${ZED_KUBE_NAMESPACE}
name: ${ZED_SERVICE_NAME}
annotations:
service.beta.kubernetes.io/do-loadbalancer-name: "${ZED_SERVICE_NAME}-${ZED_KUBE_NAMESPACE}"
service.beta.kubernetes.io/do-loadbalancer-size-unit: "${ZED_LOAD_BALANCER_SIZE_UNIT}"
service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443"
service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID}
service.beta.kubernetes.io/do-loadbalancer-disable-lets-encrypt-dns-records: "true"
@@ -33,6 +35,11 @@ metadata:
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: ${ZED_SERVICE_NAME}
@@ -76,6 +83,13 @@ spec:
port: 8080
initialDelaySeconds: 1
periodSeconds: 1
startupProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 1
periodSeconds: 1
failureThreshold: 15
env:
- name: HTTP_PORT
value: "8080"
@@ -156,6 +170,11 @@ spec:
secretKeyRef:
name: clickhouse
key: database
- name: SLACK_PANICS_WEBHOOK
valueFrom:
secretKeyRef:
name: slack
key: panics_webhook
- name: INVITE_LINK_PREFIX
value: ${INVITE_LINK_PREFIX}
- name: RUST_BACKTRACE
@@ -171,3 +190,4 @@ spec:
# FIXME - Switch to the more restrictive `PERFMON` capability.
# This capability isn't yet available in a stable version of Debian.
add: ["SYS_ADMIN"]
terminationGracePeriodSeconds: 10

View File

@@ -5,6 +5,7 @@ metadata:
namespace: ${ZED_KUBE_NAMESPACE}
name: postgrest
annotations:
service.beta.kubernetes.io/do-loadbalancer-name: "postgrest-${ZED_KUBE_NAMESPACE}"
service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443"
service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID}
service.beta.kubernetes.io/do-loadbalancer-disable-lets-encrypt-dns-records: "true"

View File

@@ -46,10 +46,11 @@ CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");
CREATE TABLE "projects" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"room_id" INTEGER REFERENCES rooms (id) ON DELETE CASCADE NOT NULL,
"host_user_id" INTEGER REFERENCES users (id) NOT NULL,
"host_user_id" INTEGER REFERENCES users (id),
"host_connection_id" INTEGER,
"host_connection_server_id" INTEGER REFERENCES servers (id) ON DELETE CASCADE,
"unregistered" BOOLEAN NOT NULL DEFAULT FALSE
"unregistered" BOOLEAN NOT NULL DEFAULT FALSE,
"hosted_project_id" INTEGER REFERENCES hosted_projects (id)
);
CREATE INDEX "index_projects_on_host_connection_server_id" ON "projects" ("host_connection_server_id");
CREATE INDEX "index_projects_on_host_connection_id_and_host_connection_server_id" ON "projects" ("host_connection_id", "host_connection_server_id");
@@ -247,7 +248,10 @@ CREATE UNIQUE INDEX "index_channel_members_on_channel_id_and_user_id" ON "channe
CREATE TABLE "buffers" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
"epoch" INTEGER NOT NULL DEFAULT 0
"epoch" INTEGER NOT NULL DEFAULT 0,
"latest_operation_epoch" INTEGER,
"latest_operation_replica_id" INTEGER,
"latest_operation_lamport_timestamp" INTEGER
);
CREATE INDEX "index_buffers_on_channel_id" ON "buffers" ("channel_id");

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE projects ALTER COLUMN host_user_id DROP NOT NULL;
ALTER TABLE projects ADD COLUMN hosted_project_id INTEGER REFERENCES hosted_projects(id) UNIQUE NULL;

View File

@@ -0,0 +1,17 @@
-- Add migration script here
ALTER TABLE buffers ADD COLUMN latest_operation_epoch INTEGER;
ALTER TABLE buffers ADD COLUMN latest_operation_lamport_timestamp INTEGER;
ALTER TABLE buffers ADD COLUMN latest_operation_replica_id INTEGER;
WITH ops AS (
SELECT DISTINCT ON (buffer_id) buffer_id, epoch, lamport_timestamp, replica_id
FROM buffer_operations
ORDER BY buffer_id, epoch DESC, lamport_timestamp DESC, replica_id DESC
)
UPDATE buffers
SET latest_operation_epoch = ops.epoch,
latest_operation_lamport_timestamp = ops.lamport_timestamp,
latest_operation_replica_id = ops.replica_id
FROM ops
WHERE buffers.id = ops.buffer_id;

View File

@@ -1,5 +1,7 @@
pub mod events;
pub mod extensions;
pub mod ips_file;
pub mod slack;
use crate::{
auth,
@@ -9,7 +11,7 @@ use crate::{
use anyhow::anyhow;
use axum::{
body::Body,
extract::{Path, Query},
extract::{self, Path, Query},
http::{self, Request, StatusCode},
middleware::{self, Next},
response::IntoResponse,
@@ -21,15 +23,13 @@ use chrono::SecondsFormat;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tower::ServiceBuilder;
use tracing::instrument;
pub use extensions::fetch_extensions_from_blob_store_periodically;
pub fn routes(rpc_server: Option<Arc<rpc::Server>>, state: Arc<AppState>) -> Router<Body> {
pub fn routes(rpc_server: Option<Arc<rpc::Server>>, state: Arc<AppState>) -> Router<(), Body> {
Router::new()
.route("/user", get(get_authenticated_user))
.route("/users/:id/access_tokens", post(create_access_token))
.route("/panic", post(trace_panic))
.route("/rpc_server_snapshot", get(get_rpc_server_snapshot))
.route("/contributors", get(get_contributors).post(add_contributor))
.route("/contributor", get(check_is_contributor))
@@ -120,20 +120,6 @@ struct CreateUserResponse {
metrics_id: String,
}
#[derive(Debug, Deserialize)]
struct Panic {
version: String,
release_channel: String,
backtrace_hash: String,
text: String,
}
#[instrument(skip(panic))]
async fn trace_panic(panic: Json<Panic>) -> Result<()> {
tracing::error!(version = %panic.version, release_channel = %panic.release_channel, backtrace_hash = %panic.backtrace_hash, text = %panic.text, "panic report");
Ok(())
}
async fn get_rpc_server_snapshot(
Extension(rpc_server): Extension<Option<Arc<rpc::Server>>>,
) -> Result<ErasedJson> {
@@ -190,17 +176,16 @@ async fn check_is_contributor(
}
async fn add_contributor(
Json(params): Json<AuthenticatedUserParams>,
Extension(app): Extension<Arc<AppState>>,
extract::Json(params): extract::Json<AuthenticatedUserParams>,
) -> Result<()> {
Ok(app
.db
app.db
.add_contributor(
&params.github_login,
params.github_user_id,
params.github_email.as_deref(),
)
.await?)
.await
}
#[derive(Deserialize)]

View File

@@ -1,34 +1,38 @@
use std::sync::Arc;
use std::sync::{Arc, OnceLock};
use anyhow::{anyhow, Context};
use aws_sdk_s3::primitives::ByteStream;
use axum::{
body::Bytes, headers::Header, http::HeaderName, routing::post, Extension, Router, TypedHeader,
body::Bytes,
headers::Header,
http::{HeaderMap, HeaderName, StatusCode},
routing::post,
Extension, Router, TypedHeader,
};
use hyper::StatusCode;
use lazy_static::lazy_static;
use serde::{Serialize, Serializer};
use sha2::{Digest, Sha256};
use telemetry_events::{
ActionEvent, AppEvent, AssistantEvent, CallEvent, CopilotEvent, CpuEvent, EditEvent,
EditorEvent, Event, EventRequestBody, EventWrapper, MemoryEvent, SettingEvent,
};
use util::SemanticVersion;
use crate::{AppState, Error, Result};
use crate::{api::slack, AppState, Error, Result};
use super::ips_file::IpsFile;
pub fn router() -> Router {
Router::new().route("/telemetry/events", post(post_events))
}
lazy_static! {
static ref ZED_CHECKSUM_HEADER: HeaderName = HeaderName::from_static("x-zed-checksum");
static ref CLOUDFLARE_IP_COUNTRY_HEADER: HeaderName = HeaderName::from_static("cf-ipcountry");
Router::new()
.route("/telemetry/events", post(post_events))
.route("/telemetry/crashes", post(post_crash))
}
pub struct ZedChecksumHeader(Vec<u8>);
impl Header for ZedChecksumHeader {
fn name() -> &'static HeaderName {
&ZED_CHECKSUM_HEADER
static ZED_CHECKSUM_HEADER: OnceLock<HeaderName> = OnceLock::new();
ZED_CHECKSUM_HEADER.get_or_init(|| HeaderName::from_static("x-zed-checksum"))
}
fn decode<'i, I>(values: &mut I) -> Result<Self, axum::headers::Error>
@@ -55,7 +59,8 @@ pub struct CloudflareIpCountryHeader(String);
impl Header for CloudflareIpCountryHeader {
fn name() -> &'static HeaderName {
&CLOUDFLARE_IP_COUNTRY_HEADER
static CLOUDFLARE_IP_COUNTRY_HEADER: OnceLock<HeaderName> = OnceLock::new();
CLOUDFLARE_IP_COUNTRY_HEADER.get_or_init(|| HeaderName::from_static("cf-ipcountry"))
}
fn decode<'i, I>(values: &mut I) -> Result<Self, axum::headers::Error>
@@ -77,6 +82,140 @@ impl Header for CloudflareIpCountryHeader {
}
}
pub async fn post_crash(
Extension(app): Extension<Arc<AppState>>,
headers: HeaderMap,
body: Bytes,
) -> Result<()> {
static CRASH_REPORTS_BUCKET: &str = "zed-crash-reports";
let report = IpsFile::parse(&body)?;
let version_threshold = SemanticVersion::new(0, 123, 0);
let bundle_id = &report.header.bundle_id;
let app_version = &report.app_version();
if bundle_id == "dev.zed.Zed-Dev" {
log::error!("Crash uploads from {} are ignored.", bundle_id);
return Ok(());
}
if app_version.is_none() || app_version.unwrap() < version_threshold {
log::error!(
"Crash uploads from {} are ignored.",
report.header.app_version
);
return Ok(());
}
let app_version = app_version.unwrap();
if let Some(blob_store_client) = app.blob_store_client.as_ref() {
let response = blob_store_client
.head_object()
.bucket(CRASH_REPORTS_BUCKET)
.key(report.header.incident_id.clone() + ".ips")
.send()
.await;
if response.is_ok() {
log::info!("We've already uploaded this crash");
return Ok(());
}
blob_store_client
.put_object()
.bucket(CRASH_REPORTS_BUCKET)
.key(report.header.incident_id.clone() + ".ips")
.acl(aws_sdk_s3::types::ObjectCannedAcl::PublicRead)
.body(ByteStream::from(body.to_vec()))
.send()
.await
.map_err(|e| log::error!("Failed to upload crash: {}", e))
.ok();
}
let recent_panic_on: Option<i64> = headers
.get("x-zed-panicked-on")
.and_then(|h| h.to_str().ok())
.and_then(|s| s.parse().ok());
let mut recent_panic = None;
if let Some(recent_panic_on) = recent_panic_on {
let crashed_at = match report.timestamp() {
Ok(t) => Some(t),
Err(e) => {
log::error!("Can't parse {}: {}", report.header.timestamp, e);
None
}
};
if crashed_at.is_some_and(|t| (t.timestamp_millis() - recent_panic_on).abs() <= 30000) {
recent_panic = headers.get("x-zed-panic").and_then(|h| h.to_str().ok());
}
}
let description = report.description(recent_panic);
let summary = report.backtrace_summary();
tracing::error!(
service = "client",
version = %report.header.app_version,
os_version = %report.header.os_version,
bundle_id = %report.header.bundle_id,
incident_id = %report.header.incident_id,
description = %description,
backtrace = %summary,
"crash report");
if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() {
let payload = slack::WebhookBody::new(|w| {
w.add_section(|s| s.text(slack::Text::markdown(description)))
.add_section(|s| {
s.add_field(slack::Text::markdown(format!(
"*Version:*\n{} ({})",
bundle_id, app_version
)))
.add_field({
let hostname = app.config.blob_store_url.clone().unwrap_or_default();
let hostname = hostname.strip_prefix("https://").unwrap_or_else(|| {
hostname.strip_prefix("http://").unwrap_or_default()
});
slack::Text::markdown(format!(
"*Incident:*\n<https://{}.{}/{}.ips|{}…>",
CRASH_REPORTS_BUCKET,
hostname,
report.header.incident_id,
report
.header
.incident_id
.chars()
.take(8)
.collect::<String>(),
))
})
})
.add_rich_text(|r| r.add_preformatted(|p| p.add_text(summary)))
});
let payload_json = serde_json::to_string(&payload).map_err(|err| {
log::error!("Failed to serialize payload to JSON: {err}");
Error::Internal(anyhow!(err))
})?;
reqwest::Client::new()
.post(slack_panics_webhook)
.header("Content-Type", "application/json")
.body(payload_json)
.send()
.await
.map_err(|err| {
log::error!("Failed to send payload to Slack: {err}");
Error::Internal(anyhow!(err))
})?;
}
Ok(())
}
pub async fn post_events(
Extension(app): Extension<Arc<AppState>>,
TypedHeader(ZedChecksumHeader(checksum)): TypedHeader<ZedChecksumHeader>,
@@ -102,7 +241,7 @@ pub async fn post_events(
summer.update(&body);
summer.update(checksum_seed);
if &checksum[..] != &summer.finalize()[..] {
if &checksum != &summer.finalize()[..] {
return Err(Error::Http(
StatusCode::BAD_REQUEST,
"invalid checksum".into(),
@@ -219,40 +358,68 @@ struct ToUpload {
impl ToUpload {
pub async fn upload(&self, clickhouse_client: &clickhouse::Client) -> anyhow::Result<()> {
Self::upload_to_table("editor_events", &self.editor_events, clickhouse_client)
const EDITOR_EVENTS_TABLE: &str = "editor_events";
Self::upload_to_table(EDITOR_EVENTS_TABLE, &self.editor_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'editor_events'"))?;
Self::upload_to_table("copilot_events", &self.copilot_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'copilot_events'"))?;
.with_context(|| format!("failed to upload to table '{EDITOR_EVENTS_TABLE}'"))?;
const COPILOT_EVENTS_TABLE: &str = "copilot_events";
Self::upload_to_table(
"assistant_events",
COPILOT_EVENTS_TABLE,
&self.copilot_events,
clickhouse_client,
)
.await
.with_context(|| format!("failed to upload to table '{COPILOT_EVENTS_TABLE}'"))?;
const ASSISTANT_EVENTS_TABLE: &str = "assistant_events";
Self::upload_to_table(
ASSISTANT_EVENTS_TABLE,
&self.assistant_events,
clickhouse_client,
)
.await
.with_context(|| format!("failed to upload to table 'assistant_events'"))?;
Self::upload_to_table("call_events", &self.call_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{ASSISTANT_EVENTS_TABLE}'"))?;
const CALL_EVENTS_TABLE: &str = "call_events";
Self::upload_to_table(CALL_EVENTS_TABLE, &self.call_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'call_events'"))?;
Self::upload_to_table("cpu_events", &self.cpu_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{CALL_EVENTS_TABLE}'"))?;
const CPU_EVENTS_TABLE: &str = "cpu_events";
Self::upload_to_table(CPU_EVENTS_TABLE, &self.cpu_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'cpu_events'"))?;
Self::upload_to_table("memory_events", &self.memory_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{CPU_EVENTS_TABLE}'"))?;
const MEMORY_EVENTS_TABLE: &str = "memory_events";
Self::upload_to_table(MEMORY_EVENTS_TABLE, &self.memory_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'memory_events'"))?;
Self::upload_to_table("app_events", &self.app_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{MEMORY_EVENTS_TABLE}'"))?;
const APP_EVENTS_TABLE: &str = "app_events";
Self::upload_to_table(APP_EVENTS_TABLE, &self.app_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'app_events'"))?;
Self::upload_to_table("setting_events", &self.setting_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{APP_EVENTS_TABLE}'"))?;
const SETTING_EVENTS_TABLE: &str = "setting_events";
Self::upload_to_table(
SETTING_EVENTS_TABLE,
&self.setting_events,
clickhouse_client,
)
.await
.with_context(|| format!("failed to upload to table '{SETTING_EVENTS_TABLE}'"))?;
const EDIT_EVENTS_TABLE: &str = "edit_events";
Self::upload_to_table(EDIT_EVENTS_TABLE, &self.edit_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'setting_events'"))?;
Self::upload_to_table("edit_events", &self.edit_events, clickhouse_client)
.with_context(|| format!("failed to upload to table '{EDIT_EVENTS_TABLE}'"))?;
const ACTION_EVENTS_TABLE: &str = "action_events";
Self::upload_to_table(ACTION_EVENTS_TABLE, &self.action_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'edit_events'"))?;
Self::upload_to_table("action_events", &self.action_events, clickhouse_client)
.await
.with_context(|| format!("failed to upload to table 'action_events'"))?;
.with_context(|| format!("failed to upload to table '{ACTION_EVENTS_TABLE}'"))?;
Ok(())
}

View File

@@ -7,12 +7,12 @@ use anyhow::{anyhow, Context as _};
use aws_sdk_s3::presigning::PresigningConfig;
use axum::{
extract::{Path, Query},
http::StatusCode,
response::Redirect,
routing::get,
Extension, Json, Router,
};
use collections::HashMap;
use hyper::StatusCode;
use serde::{Deserialize, Serialize};
use std::{sync::Arc, time::Duration};
use time::PrimitiveDateTime;
@@ -140,6 +140,8 @@ async fn fetch_extensions_from_blob_store(
blob_store_bucket: &String,
app_state: &Arc<AppState>,
) -> anyhow::Result<()> {
log::info!("fetching extensions from blob store");
let list = blob_store_client
.list_objects()
.bucket(blob_store_bucket)
@@ -147,9 +149,7 @@ async fn fetch_extensions_from_blob_store(
.send()
.await?;
let objects = list
.contents
.ok_or_else(|| anyhow!("missing bucket contents"))?;
let objects = list.contents.unwrap_or_default();
let mut published_versions = HashMap::<&str, Vec<&str>>::default();
for object in &objects {
@@ -166,10 +166,12 @@ async fn fetch_extensions_from_blob_store(
let Some(version) = parts.next() else {
continue;
};
published_versions
.entry(extension_id)
.or_default()
.push(version);
if parts.next() == Some("manifest.json") {
published_versions
.entry(extension_id)
.or_default()
.push(version);
}
}
let known_versions = app_state.db.get_known_extension_versions().await?;
@@ -184,46 +186,20 @@ async fn fetch_extensions_from_blob_store(
.binary_search_by_key(&published_version, String::as_str)
.is_err()
{
let object = blob_store_client
.get_object()
.bucket(blob_store_bucket)
.key(format!(
"extensions/{extension_id}/{published_version}/manifest.json"
))
.send()
.await?;
let manifest_bytes = object
.body
.collect()
.await
.map(|data| data.into_bytes())
.with_context(|| format!("failed to download manifest for extension {extension_id} version {published_version}"))?
.to_vec();
let manifest = serde_json::from_slice::<ExtensionManifest>(&manifest_bytes)
.with_context(|| format!("invalid manifest for extension {extension_id} version {published_version}: {}", String::from_utf8_lossy(&manifest_bytes)))?;
let published_at = object.last_modified.ok_or_else(|| anyhow!("missing last modified timestamp for extension {extension_id} version {published_version}"))?;
let published_at =
time::OffsetDateTime::from_unix_timestamp_nanos(published_at.as_nanos())?;
let published_at = PrimitiveDateTime::new(published_at.date(), published_at.time());
let version = semver::Version::parse(&manifest.version).with_context(|| {
format!(
"invalid version for extension {extension_id} version {published_version}"
)
})?;
new_versions
.entry(extension_id)
.or_default()
.push(NewExtensionVersion {
name: manifest.name,
version,
description: manifest.description.unwrap_or_default(),
authors: manifest.authors,
repository: manifest.repository,
published_at,
});
if let Some(extension) = fetch_extension_manifest(
blob_store_client,
blob_store_bucket,
extension_id,
published_version,
)
.await
.log_err()
{
new_versions
.entry(extension_id)
.or_default()
.push(extension);
}
}
}
}
@@ -233,5 +209,56 @@ async fn fetch_extensions_from_blob_store(
.insert_extension_versions(&new_versions)
.await?;
log::info!(
"fetched {} new extensions from blob store",
new_versions.values().map(|v| v.len()).sum::<usize>()
);
Ok(())
}
async fn fetch_extension_manifest(
blob_store_client: &aws_sdk_s3::Client,
blob_store_bucket: &String,
extension_id: &str,
version: &str,
) -> Result<NewExtensionVersion, anyhow::Error> {
let object = blob_store_client
.get_object()
.bucket(blob_store_bucket)
.key(format!("extensions/{extension_id}/{version}/manifest.json"))
.send()
.await?;
let manifest_bytes = object
.body
.collect()
.await
.map(|data| data.into_bytes())
.with_context(|| {
format!("failed to download manifest for extension {extension_id} version {version}")
})?
.to_vec();
let manifest =
serde_json::from_slice::<ExtensionManifest>(&manifest_bytes).with_context(|| {
format!(
"invalid manifest for extension {extension_id} version {version}: {}",
String::from_utf8_lossy(&manifest_bytes)
)
})?;
let published_at = object.last_modified.ok_or_else(|| {
anyhow!("missing last modified timestamp for extension {extension_id} version {version}")
})?;
let published_at = time::OffsetDateTime::from_unix_timestamp_nanos(published_at.as_nanos())?;
let published_at = PrimitiveDateTime::new(published_at.date(), published_at.time());
let version = semver::Version::parse(&manifest.version).with_context(|| {
format!("invalid version for extension {extension_id} version {version}")
})?;
Ok(NewExtensionVersion {
name: manifest.name,
version,
description: manifest.description.unwrap_or_default(),
authors: manifest.authors,
repository: manifest.repository,
published_at,
})
}

View File

@@ -0,0 +1,352 @@
use collections::HashMap;
use serde_derive::Deserialize;
use serde_derive::Serialize;
use serde_json::Value;
use util::SemanticVersion;
#[derive(Debug)]
pub struct IpsFile {
pub header: Header,
pub body: Body,
}
impl IpsFile {
pub fn parse(bytes: &[u8]) -> anyhow::Result<IpsFile> {
let mut split = bytes.splitn(2, |&b| b == b'\n');
let header_bytes = split
.next()
.ok_or_else(|| anyhow::anyhow!("No header found"))?;
let header: Header = serde_json::from_slice(header_bytes)
.map_err(|e| anyhow::anyhow!("Failed to parse header: {}", e))?;
let body_bytes = split
.next()
.ok_or_else(|| anyhow::anyhow!("No body found"))?;
let body: Body = serde_json::from_slice(body_bytes)
.map_err(|e| anyhow::anyhow!("Failed to parse body: {}", e))?;
Ok(IpsFile { header, body })
}
pub fn faulting_thread(&self) -> Option<&Thread> {
self.body.threads.get(self.body.faulting_thread? as usize)
}
pub fn app_version(&self) -> Option<SemanticVersion> {
self.header.app_version.parse().ok()
}
pub fn timestamp(&self) -> anyhow::Result<chrono::DateTime<chrono::FixedOffset>> {
chrono::DateTime::parse_from_str(&self.header.timestamp, "%Y-%m-%d %H:%M:%S%.f %#z")
.map_err(|e| anyhow::anyhow!(e))
}
pub fn description(&self, panic: Option<&str>) -> String {
let mut desc = if self.body.termination.indicator == "Abort trap: 6" {
match panic {
Some(panic_message) => format!("Panic `{}`", panic_message),
None => "Crash `Abort trap: 6` (possible panic)".into(),
}
} else if let Some(msg) = &self.body.exception.message {
format!("Exception `{}`", msg)
} else {
format!("Crash `{}`", self.body.termination.indicator)
};
if let Some(thread) = self.faulting_thread() {
if let Some(queue) = thread.queue.as_ref() {
desc += &format!(
" on thread {} ({})",
self.body.faulting_thread.unwrap_or_default(),
queue
);
} else {
desc += &format!(
" on thread {} ({})",
self.body.faulting_thread.unwrap_or_default(),
thread.name.clone().unwrap_or_default()
);
}
}
desc
}
pub fn backtrace_summary(&self) -> String {
if let Some(thread) = self.faulting_thread() {
let mut frames = thread
.frames
.iter()
.filter_map(|frame| {
if let Some(name) = &frame.symbol {
if self.is_ignorable_frame(name) {
return None;
}
Some(format!("{:#}", rustc_demangle::demangle(name)))
} else if let Some(image) = self.body.used_images.get(frame.image_index) {
Some(image.name.clone().unwrap_or("<unknown-image>".into()))
} else {
Some("<unknown>".into())
}
})
.collect::<Vec<_>>();
let total = frames.len();
if total > 21 {
frames = frames.into_iter().take(20).collect();
frames.push(format!(" and {} more...", total - 20))
}
frames.join("\n")
} else {
"<no backtrace available>".into()
}
}
fn is_ignorable_frame(&self, symbol: &String) -> bool {
[
"pthread_kill",
"panic",
"backtrace",
"rust_begin_unwind",
"abort",
]
.iter()
.any(|s| symbol.contains(s))
}
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Header {
pub app_name: String,
pub timestamp: String,
pub app_version: String,
pub slice_uuid: String,
pub build_version: String,
pub platform: i64,
#[serde(rename = "bundleID", default)]
pub bundle_id: String,
pub share_with_app_devs: i64,
pub is_first_party: i64,
pub bug_type: String,
pub os_version: String,
pub roots_installed: i64,
pub name: String,
pub incident_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Body {
pub uptime: i64,
pub proc_role: String,
pub version: i64,
#[serde(rename = "userID")]
pub user_id: i64,
pub deploy_version: i64,
pub model_code: String,
#[serde(rename = "coalitionID")]
pub coalition_id: i64,
pub os_version: OsVersion,
pub capture_time: String,
pub code_signing_monitor: i64,
pub incident: String,
pub pid: i64,
pub translated: bool,
pub cpu_type: String,
#[serde(rename = "roots_installed")]
pub roots_installed: i64,
#[serde(rename = "bug_type")]
pub bug_type: String,
pub proc_launch: String,
pub proc_start_abs_time: i64,
pub proc_exit_abs_time: i64,
pub proc_name: String,
pub proc_path: String,
pub bundle_info: BundleInfo,
pub store_info: StoreInfo,
pub parent_proc: String,
pub parent_pid: i64,
pub coalition_name: String,
pub crash_reporter_key: String,
#[serde(rename = "codeSigningID")]
pub code_signing_id: String,
#[serde(rename = "codeSigningTeamID")]
pub code_signing_team_id: String,
pub code_signing_flags: i64,
pub code_signing_validation_category: i64,
pub code_signing_trust_level: i64,
pub instruction_byte_stream: InstructionByteStream,
pub sip: String,
pub exception: Exception,
pub termination: Termination,
pub asi: Asi,
pub ext_mods: ExtMods,
pub faulting_thread: Option<i64>,
pub threads: Vec<Thread>,
pub used_images: Vec<UsedImage>,
pub shared_cache: SharedCache,
pub vm_summary: String,
pub legacy_info: LegacyInfo,
pub log_writing_signature: String,
pub trial_info: TrialInfo,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct OsVersion {
pub train: String,
pub build: String,
pub release_type: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct BundleInfo {
#[serde(rename = "CFBundleShortVersionString")]
pub cfbundle_short_version_string: String,
#[serde(rename = "CFBundleVersion")]
pub cfbundle_version: String,
#[serde(rename = "CFBundleIdentifier")]
pub cfbundle_identifier: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct StoreInfo {
pub device_identifier_for_vendor: String,
pub third_party: bool,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct InstructionByteStream {
#[serde(rename = "beforePC")]
pub before_pc: String,
#[serde(rename = "atPC")]
pub at_pc: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Exception {
pub codes: String,
pub raw_codes: Vec<i64>,
#[serde(rename = "type")]
pub type_field: String,
pub subtype: Option<String>,
pub signal: String,
pub port: Option<i64>,
pub guard_id: Option<i64>,
pub message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Termination {
pub flags: i64,
pub code: i64,
pub namespace: String,
pub indicator: String,
pub by_proc: String,
pub by_pid: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Asi {
#[serde(rename = "libsystem_c.dylib")]
pub libsystem_c_dylib: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct ExtMods {
pub caller: ExtMod,
pub system: ExtMod,
pub targeted: ExtMod,
pub warnings: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct ExtMod {
#[serde(rename = "thread_create")]
pub thread_create: i64,
#[serde(rename = "thread_set_state")]
pub thread_set_state: i64,
#[serde(rename = "task_for_pid")]
pub task_for_pid: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Thread {
pub thread_state: HashMap<String, Value>,
pub id: i64,
pub triggered: Option<bool>,
pub name: Option<String>,
pub queue: Option<String>,
pub frames: Vec<Frame>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Frame {
pub image_offset: i64,
pub symbol: Option<String>,
pub symbol_location: Option<i64>,
pub image_index: usize,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct UsedImage {
pub source: String,
pub arch: Option<String>,
pub base: i64,
#[serde(rename = "CFBundleShortVersionString")]
pub cfbundle_short_version_string: Option<String>,
#[serde(rename = "CFBundleIdentifier")]
pub cfbundle_identifier: Option<String>,
pub size: i64,
pub uuid: String,
pub path: Option<String>,
pub name: Option<String>,
#[serde(rename = "CFBundleVersion")]
pub cfbundle_version: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct SharedCache {
pub base: i64,
pub size: i64,
pub uuid: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct LegacyInfo {
pub thread_triggered: ThreadTriggered,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct ThreadTriggered {
pub name: String,
pub queue: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct TrialInfo {
pub rollouts: Vec<Rollout>,
pub experiments: Vec<Value>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct Rollout {
pub rollout_id: String,
pub factor_pack_ids: HashMap<String, Value>,
pub deployment_id: i64,
}

View File

@@ -0,0 +1,144 @@
use serde::{Deserialize, Serialize};
/// https://api.slack.com/reference/messaging/payload
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct WebhookBody {
text: String,
#[serde(skip_serializing_if = "Vec::is_empty")]
blocks: Vec<Block>,
#[serde(skip_serializing_if = "Option::is_none")]
thread_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
mrkdwn: Option<bool>,
}
impl WebhookBody {
pub fn new(f: impl FnOnce(Self) -> Self) -> Self {
f(Self::default())
}
pub fn add_section(mut self, build: impl FnOnce(Section) -> Section) -> Self {
self.blocks.push(Block::Section(build(Section::default())));
self
}
pub fn add_rich_text(mut self, build: impl FnOnce(RichText) -> RichText) -> Self {
self.blocks
.push(Block::RichText(build(RichText::default())));
self
}
}
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
/// https://api.slack.com/reference/block-kit/blocks
pub enum Block {
#[serde(rename = "section")]
Section(Section),
#[serde(rename = "rich_text")]
RichText(RichText),
// .... etc.
}
/// https://api.slack.com/reference/block-kit/blocks#section
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct Section {
#[serde(skip_serializing_if = "Option::is_none")]
text: Option<Text>,
#[serde(skip_serializing_if = "Vec::is_empty")]
fields: Vec<Text>,
// fields, accessories...
}
impl Section {
pub fn text(mut self, text: Text) -> Self {
self.text = Some(text);
self
}
pub fn add_field(mut self, field: Text) -> Self {
self.fields.push(field);
self
}
}
/// https://api.slack.com/reference/block-kit/composition-objects#text
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Text {
#[serde(rename = "plain_text")]
PlainText { text: String, emoji: bool },
#[serde(rename = "mrkdwn")]
Markdown { text: String, verbatim: bool },
}
impl Text {
pub fn plain(s: String) -> Self {
Self::PlainText {
text: s,
emoji: true,
}
}
pub fn markdown(s: String) -> Self {
Self::Markdown {
text: s,
verbatim: false,
}
}
}
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct RichText {
elements: Vec<RichTextObject>,
}
impl RichText {
pub fn new(f: impl FnOnce(Self) -> Self) -> Self {
f(Self::default())
}
pub fn add_preformatted(
mut self,
build: impl FnOnce(RichTextPreformatted) -> RichTextPreformatted,
) -> Self {
self.elements.push(RichTextObject::Preformatted(build(
RichTextPreformatted::default(),
)));
self
}
}
/// https://api.slack.com/reference/block-kit/blocks#rich_text
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum RichTextObject {
#[serde(rename = "rich_text_preformatted")]
Preformatted(RichTextPreformatted),
// etc.
}
/// https://api.slack.com/reference/block-kit/blocks#rich_text_preformatted
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct RichTextPreformatted {
#[serde(skip_serializing_if = "Vec::is_empty")]
elements: Vec<RichTextElement>,
#[serde(skip_serializing_if = "Option::is_none")]
border: Option<u8>,
}
impl RichTextPreformatted {
pub fn add_text(mut self, text: String) -> Self {
self.elements.push(RichTextElement::Text { text });
self
}
}
/// https://api.slack.com/reference/block-kit/blocks#element-types
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum RichTextElement {
#[serde(rename = "text")]
Text { text: String },
// etc.
}

View File

@@ -8,24 +8,16 @@ use axum::{
middleware::Next,
response::IntoResponse,
};
use lazy_static::lazy_static;
use prometheus::{exponential_buckets, register_histogram, Histogram};
use rand::thread_rng;
use scrypt::{
password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
password_hash::{PasswordHash, PasswordVerifier},
Scrypt,
};
use serde::{Deserialize, Serialize};
use sha2::Digest;
use std::sync::OnceLock;
use std::{sync::Arc, time::Instant};
lazy_static! {
static ref METRIC_ACCESS_TOKEN_HASHING_TIME: Histogram = register_histogram!(
"access_token_hashing_time",
"time spent hashing access tokens",
exponential_buckets(10.0, 2.0, 10).unwrap(),
)
.unwrap();
}
use subtle::ConstantTimeEq;
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Impersonator(pub Option<db::User>);
@@ -124,8 +116,7 @@ pub async fn create_access_token(
) -> Result<String> {
const VERSION: usize = 1;
let access_token = rpc::auth::random_token();
let access_token_hash =
hash_access_token(&access_token).context("failed to hash access token")?;
let access_token_hash = hash_access_token(&access_token);
let id = db
.create_access_token(
user_id,
@@ -141,23 +132,15 @@ pub async fn create_access_token(
})?)
}
fn hash_access_token(token: &str) -> Result<String> {
// Avoid slow hashing in debug mode.
let params = if cfg!(debug_assertions) {
scrypt::Params::new(1, 1, 1).unwrap()
} else {
scrypt::Params::new(14, 8, 1).unwrap()
};
Ok(Scrypt
.hash_password(
token.as_bytes(),
None,
params,
&SaltString::generate(thread_rng()),
)
.map_err(anyhow::Error::new)?
.to_string())
/// Hashing prevents anyone with access to the database being able to login.
/// As the token is randomly generated, we don't need to worry about scrypt-style
/// protection.
fn hash_access_token(token: &str) -> String {
let digest = sha2::Sha256::digest(token);
format!(
"$sha256${}",
base64::encode_config(digest, base64::URL_SAFE)
)
}
/// Encrypts the given access token with the given public key to avoid leaking it on the way
@@ -182,6 +165,16 @@ pub async fn verify_access_token(
user_id: UserId,
db: &Arc<Database>,
) -> Result<VerifyAccessTokenResult> {
static METRIC_ACCESS_TOKEN_HASHING_TIME: OnceLock<Histogram> = OnceLock::new();
let metric_access_token_hashing_time = METRIC_ACCESS_TOKEN_HASHING_TIME.get_or_init(|| {
register_histogram!(
"access_token_hashing_time",
"time spent hashing access tokens",
exponential_buckets(10.0, 2.0, 10).unwrap(),
)
.unwrap()
});
let token: AccessTokenJson = serde_json::from_str(&token)?;
let db_token = db.get_access_token(token.id).await?;
@@ -189,15 +182,27 @@ pub async fn verify_access_token(
if token_user_id != user_id {
return Err(anyhow!("no such access token"))?;
}
let db_hash = PasswordHash::new(&db_token.hash).map_err(anyhow::Error::new)?;
let t0 = Instant::now();
let is_valid = Scrypt
.verify_password(token.token.as_bytes(), &db_hash)
.is_ok();
let is_valid = if db_token.hash.starts_with("$scrypt$") {
let db_hash = PasswordHash::new(&db_token.hash).map_err(anyhow::Error::new)?;
Scrypt
.verify_password(token.token.as_bytes(), &db_hash)
.is_ok()
} else {
let token_hash = hash_access_token(&token.token);
db_token.hash.as_bytes().ct_eq(token_hash.as_ref()).into()
};
let duration = t0.elapsed();
log::info!("hashed access token in {:?}", duration);
METRIC_ACCESS_TOKEN_HASHING_TIME.observe(duration.as_millis() as f64);
metric_access_token_hashing_time.observe(duration.as_millis() as f64);
if is_valid && db_token.hash.starts_with("$scrypt$") {
let new_hash = hash_access_token(&token.token);
db.update_access_token_hash(db_token.id, &new_hash).await?;
}
Ok(VerifyAccessTokenResult {
is_valid,
impersonator_id: if db_token.impersonated_user_id.is_some() {
@@ -207,3 +212,145 @@ pub async fn verify_access_token(
},
})
}
#[cfg(test)]
mod test {
use rand::thread_rng;
use scrypt::password_hash::{PasswordHasher, SaltString};
use sea_orm::EntityTrait;
use super::*;
use crate::db::{access_token, NewUserParams};
#[gpui::test]
async fn test_verify_access_token(cx: &mut gpui::TestAppContext) {
let test_db = crate::db::TestDb::postgres(cx.executor().clone());
let db = test_db.db();
let user = db
.create_user(
"example@example.com",
false,
NewUserParams {
github_login: "example".into(),
github_user_id: 1,
},
)
.await
.unwrap();
let token = create_access_token(&db, user.user_id, None).await.unwrap();
assert!(matches!(
verify_access_token(&token, user.user_id, &db)
.await
.unwrap(),
VerifyAccessTokenResult {
is_valid: true,
impersonator_id: None,
}
));
let old_token = create_previous_access_token(user.user_id, None, &db)
.await
.unwrap();
let old_token_id = serde_json::from_str::<AccessTokenJson>(&old_token)
.unwrap()
.id;
let hash = db
.transaction(|tx| async move {
Ok(access_token::Entity::find_by_id(old_token_id)
.one(&*tx)
.await?)
})
.await
.unwrap()
.unwrap()
.hash;
assert!(hash.starts_with("$scrypt$"));
assert!(matches!(
verify_access_token(&old_token, user.user_id, &db)
.await
.unwrap(),
VerifyAccessTokenResult {
is_valid: true,
impersonator_id: None,
}
));
let hash = db
.transaction(|tx| async move {
Ok(access_token::Entity::find_by_id(old_token_id)
.one(&*tx)
.await?)
})
.await
.unwrap()
.unwrap()
.hash;
assert!(hash.starts_with("$sha256$"));
assert!(matches!(
verify_access_token(&old_token, user.user_id, &db)
.await
.unwrap(),
VerifyAccessTokenResult {
is_valid: true,
impersonator_id: None,
}
));
assert!(matches!(
verify_access_token(&token, user.user_id, &db)
.await
.unwrap(),
VerifyAccessTokenResult {
is_valid: true,
impersonator_id: None,
}
));
}
async fn create_previous_access_token(
user_id: UserId,
impersonated_user_id: Option<UserId>,
db: &Database,
) -> Result<String> {
let access_token = rpc::auth::random_token();
let access_token_hash = previous_hash_access_token(&access_token)?;
let id = db
.create_access_token(
user_id,
impersonated_user_id,
&access_token_hash,
MAX_ACCESS_TOKENS_TO_STORE,
)
.await?;
Ok(serde_json::to_string(&AccessTokenJson {
version: 1,
id,
token: access_token,
})?)
}
fn previous_hash_access_token(token: &str) -> Result<String> {
// Avoid slow hashing in debug mode.
let params = if cfg!(debug_assertions) {
scrypt::Params::new(1, 1, 1).unwrap()
} else {
scrypt::Params::new(14, 8, 1).unwrap()
};
Ok(Scrypt
.hash_password(
token.as_bytes(),
None,
params,
&SaltString::generate(thread_rng()),
)
.map_err(anyhow::Error::new)?
.to_string())
}
}

View File

@@ -88,9 +88,9 @@ async fn fetch_github<T: DeserializeOwned>(client: &reqwest::Client, url: &str)
.header("user-agent", "zed")
.send()
.await
.expect(&format!("failed to fetch '{}'", url));
.unwrap_or_else(|_| panic!("failed to fetch '{}'", url));
response
.json()
.await
.expect(&format!("failed to deserialize github user from '{}'", url))
.unwrap_or_else(|_| panic!("failed to deserialize github user from '{}'", url))
}

View File

@@ -359,7 +359,7 @@ impl Database {
const SLEEPS: [f32; 10] = [10., 20., 40., 80., 160., 320., 640., 1280., 2560., 5120.];
if is_serialization_error(error) && prev_attempt_count < SLEEPS.len() {
let base_delay = SLEEPS[prev_attempt_count];
let randomized_delay = base_delay as f32 * self.rng.lock().await.gen_range(0.5..=2.0);
let randomized_delay = base_delay * self.rng.lock().await.gen_range(0.5..=2.0);
log::info!(
"retrying transaction after serialization error. delay: {} ms.",
randomized_delay
@@ -375,7 +375,7 @@ impl Database {
}
fn is_serialization_error(error: &Error) -> bool {
const SERIALIZATION_FAILURE_CODE: &'static str = "40001";
const SERIALIZATION_FAILURE_CODE: &str = "40001";
match error {
Error::Database(
DbErr::Exec(sea_orm::RuntimeErr::SqlxError(error))
@@ -670,6 +670,8 @@ pub struct RefreshedChannelBuffer {
}
pub struct Project {
pub id: ProjectId,
pub role: ChannelRole,
pub collaborators: Vec<ProjectCollaborator>,
pub worktrees: BTreeMap<u64, Worktree>,
pub language_servers: Vec<proto::LanguageServer>,
@@ -695,7 +697,7 @@ impl ProjectCollaborator {
#[derive(Debug)]
pub struct LeftProject {
pub id: ProjectId,
pub host_user_id: UserId,
pub host_user_id: Option<UserId>,
pub host_connection_id: Option<ConnectionId>,
pub connection_ids: Vec<ConnectionId>,
}

View File

@@ -55,4 +55,22 @@ impl Database {
})
.await
}
/// Retrieves the access token with the given ID.
pub async fn update_access_token_hash(
&self,
id: AccessTokenId,
new_hash: &str,
) -> Result<access_token::Model> {
self.transaction(|tx| async move {
Ok(access_token::Entity::update(access_token::ActiveModel {
id: ActiveValue::unchanged(id),
hash: ActiveValue::set(new_hash.into()),
..Default::default()
})
.exec(&*tx)
.await?)
})
.await
}
}

View File

@@ -18,7 +18,7 @@ impl Database {
connection: ConnectionId,
) -> Result<proto::JoinChannelBufferResponse> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
@@ -134,10 +134,10 @@ impl Database {
let mut results = Vec::new();
for client_buffer in buffers {
let channel = self
.get_channel_internal(ChannelId::from_proto(client_buffer.channel_id), &*tx)
.get_channel_internal(ChannelId::from_proto(client_buffer.channel_id), &tx)
.await?;
if self
.check_user_is_channel_participant(&channel, user_id, &*tx)
.check_user_is_channel_participant(&channel, user_id, &tx)
.await
.is_err()
{
@@ -145,7 +145,7 @@ impl Database {
continue;
}
let buffer = self.get_channel_buffer(channel.id, &*tx).await?;
let buffer = self.get_channel_buffer(channel.id, &tx).await?;
let mut collaborators = channel_buffer_collaborator::Entity::find()
.filter(channel_buffer_collaborator::Column::ChannelId.eq(channel.id))
.all(&*tx)
@@ -161,11 +161,9 @@ impl Database {
// Find the collaborator record for this user's previous lost
// connection. Update it with the new connection id.
let server_id = ServerId(connection_id.owner_id as i32);
let Some(self_collaborator) = collaborators.iter_mut().find(|c| {
c.user_id == user_id
&& (c.connection_lost || c.connection_server_id != server_id)
}) else {
let Some(self_collaborator) =
collaborators.iter_mut().find(|c| c.user_id == user_id)
else {
log::info!("can't rejoin buffer, no previous collaborator found");
continue;
};
@@ -182,7 +180,7 @@ impl Database {
let client_version = version_from_wire(&client_buffer.version);
let serialization_version = self
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &*tx)
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &tx)
.await?;
let mut rows = buffer_operation::Entity::find()
@@ -285,7 +283,7 @@ impl Database {
connection: ConnectionId,
) -> Result<LeftChannelBuffer> {
self.transaction(|tx| async move {
self.leave_channel_buffer_internal(channel_id, connection, &*tx)
self.leave_channel_buffer_internal(channel_id, connection, &tx)
.await
})
.await
@@ -310,7 +308,7 @@ impl Database {
connection_lost: ActiveValue::set(true),
..Default::default()
})
.exec(&*tx)
.exec(tx)
.await?;
Ok(())
}
@@ -339,7 +337,7 @@ impl Database {
let mut result = Vec::new();
for channel_id in channel_ids {
let left_channel_buffer = self
.leave_channel_buffer_internal(channel_id, connection, &*tx)
.leave_channel_buffer_internal(channel_id, connection, &tx)
.await?;
result.push(left_channel_buffer);
}
@@ -365,7 +363,7 @@ impl Database {
.eq(connection.owner_id as i32),
),
)
.exec(&*tx)
.exec(tx)
.await?;
if result.rows_affected == 0 {
Err(anyhow!("not a collaborator on this project"))?;
@@ -377,7 +375,7 @@ impl Database {
.filter(
Condition::all().add(channel_buffer_collaborator::Column::ChannelId.eq(channel_id)),
)
.stream(&*tx)
.stream(tx)
.await?;
while let Some(row) = rows.next().await {
let row = row?;
@@ -408,7 +406,7 @@ impl Database {
channel_id: ChannelId,
) -> Result<Vec<UserId>> {
self.transaction(|tx| async move {
self.get_channel_buffer_collaborators_internal(channel_id, &*tx)
self.get_channel_buffer_collaborators_internal(channel_id, &tx)
.await
})
.await
@@ -431,7 +429,7 @@ impl Database {
Condition::all().add(channel_buffer_collaborator::Column::ChannelId.eq(channel_id)),
)
.into_values::<_, QueryUserIds>()
.all(&*tx)
.all(tx)
.await?;
Ok(users)
@@ -449,7 +447,7 @@ impl Database {
Vec<proto::VectorClockEntry>,
)> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut requires_write_permission = false;
for op in operations.iter() {
@@ -459,10 +457,10 @@ impl Database {
}
}
if requires_write_permission {
self.check_user_is_channel_member(&channel, user, &*tx)
self.check_user_is_channel_member(&channel, user, &tx)
.await?;
} else {
self.check_user_is_channel_participant(&channel, user, &*tx)
self.check_user_is_channel_participant(&channel, user, &tx)
.await?;
}
@@ -473,7 +471,7 @@ impl Database {
.ok_or_else(|| anyhow!("no such buffer"))?;
let serialization_version = self
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &*tx)
.get_buffer_operation_serialization_version(buffer.id, buffer.epoch, &tx)
.await?;
let operations = operations
@@ -502,13 +500,13 @@ impl Database {
buffer.epoch,
*max_operation.replica_id.as_ref(),
*max_operation.lamport_timestamp.as_ref(),
&*tx,
&tx,
)
.await?;
channel_members = self.get_channel_participants(&channel, &*tx).await?;
channel_members = self.get_channel_participants(&channel, &tx).await?;
let collaborators = self
.get_channel_buffer_collaborators_internal(channel_id, &*tx)
.get_channel_buffer_collaborators_internal(channel_id, &tx)
.await?;
channel_members.retain(|member| !collaborators.contains(member));
@@ -560,6 +558,17 @@ impl Database {
lamport_timestamp: i32,
tx: &DatabaseTransaction,
) -> Result<()> {
buffer::Entity::update(buffer::ActiveModel {
id: ActiveValue::Unchanged(buffer_id),
epoch: ActiveValue::Unchanged(epoch),
latest_operation_epoch: ActiveValue::Set(Some(epoch)),
latest_operation_replica_id: ActiveValue::Set(Some(replica_id)),
latest_operation_lamport_timestamp: ActiveValue::Set(Some(lamport_timestamp)),
channel_id: ActiveValue::NotSet,
})
.exec(tx)
.await?;
use observed_buffer_edits::Column;
observed_buffer_edits::Entity::insert(observed_buffer_edits::ActiveModel {
user_id: ActiveValue::Set(user_id),
@@ -604,7 +613,7 @@ impl Database {
.select_only()
.column(buffer_snapshot::Column::OperationSerializationVersion)
.into_values::<_, QueryOperationSerializationVersion>()
.one(&*tx)
.one(tx)
.await?
.ok_or_else(|| anyhow!("missing buffer snapshot"))?)
}
@@ -619,7 +628,7 @@ impl Database {
..Default::default()
}
.find_related(buffer::Entity)
.one(&*tx)
.one(tx)
.await?
.ok_or_else(|| anyhow!("no such buffer"))?)
}
@@ -641,7 +650,7 @@ impl Database {
.eq(id)
.and(buffer_snapshot::Column::Epoch.eq(buffer.epoch)),
)
.one(&*tx)
.one(tx)
.await?
.ok_or_else(|| anyhow!("no such snapshot"))?;
@@ -659,7 +668,7 @@ impl Database {
)
.order_by_asc(buffer_operation::Column::LamportTimestamp)
.order_by_asc(buffer_operation::Column::ReplicaId)
.stream(&*tx)
.stream(tx)
.await?;
let mut operations = Vec::new();
@@ -713,7 +722,10 @@ impl Database {
buffer::ActiveModel {
id: ActiveValue::Unchanged(buffer.id),
epoch: ActiveValue::Set(epoch),
..Default::default()
latest_operation_epoch: ActiveValue::NotSet,
latest_operation_replica_id: ActiveValue::NotSet,
latest_operation_lamport_timestamp: ActiveValue::NotSet,
channel_id: ActiveValue::NotSet,
}
.save(tx)
.await?;
@@ -739,7 +751,7 @@ impl Database {
epoch,
component.replica_id as i32,
component.timestamp as i32,
&*tx,
&tx,
)
.await?;
Ok(())
@@ -747,30 +759,6 @@ impl Database {
.await
}
pub async fn latest_channel_buffer_changes(
&self,
channel_ids_by_buffer_id: &HashMap<BufferId, ChannelId>,
tx: &DatabaseTransaction,
) -> Result<Vec<proto::ChannelBufferVersion>> {
let latest_operations = self
.get_latest_operations_for_buffers(channel_ids_by_buffer_id.keys().copied(), &*tx)
.await?;
Ok(latest_operations
.iter()
.flat_map(|op| {
Some(proto::ChannelBufferVersion {
channel_id: channel_ids_by_buffer_id.get(&op.buffer_id)?.to_proto(),
epoch: op.epoch as u64,
version: vec![proto::VectorClockEntry {
replica_id: op.replica_id as u32,
timestamp: op.lamport_timestamp as u32,
}],
})
})
.collect())
}
pub async fn observed_channel_buffer_changes(
&self,
channel_ids_by_buffer_id: &HashMap<BufferId, ChannelId>,
@@ -783,7 +771,7 @@ impl Database {
observed_buffer_edits::Column::BufferId
.is_in(channel_ids_by_buffer_id.keys().copied()),
)
.all(&*tx)
.all(tx)
.await?;
Ok(observed_operations
@@ -800,55 +788,6 @@ impl Database {
})
.collect())
}
/// Returns the latest operations for the buffers with the specified IDs.
pub async fn get_latest_operations_for_buffers(
&self,
buffer_ids: impl IntoIterator<Item = BufferId>,
tx: &DatabaseTransaction,
) -> Result<Vec<buffer_operation::Model>> {
let mut values = String::new();
for id in buffer_ids {
if !values.is_empty() {
values.push_str(", ");
}
write!(&mut values, "({})", id).unwrap();
}
if values.is_empty() {
return Ok(Vec::default());
}
let sql = format!(
r#"
SELECT
*
FROM
(
SELECT
*,
row_number() OVER (
PARTITION BY buffer_id
ORDER BY
epoch DESC,
lamport_timestamp DESC,
replica_id DESC
) as row_number
FROM buffer_operations
WHERE
buffer_id in ({values})
) AS last_operations
WHERE
row_number = 1
"#,
);
let stmt = Statement::from_string(self.pool.get_database_backend(), sql);
Ok(buffer_operation::Entity::find()
.from_raw_sql(stmt)
.all(&*tx)
.await?)
}
}
fn operation_to_storage(

View File

@@ -1,5 +1,8 @@
use super::*;
use rpc::{proto::channel_member::Kind, ErrorCode, ErrorCodeExt};
use rpc::{
proto::{channel_member::Kind, ChannelBufferVersion, VectorClockEntry},
ErrorCode, ErrorCodeExt,
};
use sea_orm::TryGetableMany;
impl Database {
@@ -53,8 +56,8 @@ impl Database {
let mut membership = None;
if let Some(parent_channel_id) = parent_channel_id {
let parent_channel = self.get_channel_internal(parent_channel_id, &*tx).await?;
self.check_user_is_channel_admin(&parent_channel, admin_id, &*tx)
let parent_channel = self.get_channel_internal(parent_channel_id, &tx).await?;
self.check_user_is_channel_admin(&parent_channel, admin_id, &tx)
.await?;
parent = Some(parent_channel);
}
@@ -105,14 +108,14 @@ impl Database {
connection: ConnectionId,
) -> Result<(JoinRoom, Option<MembershipUpdated>, ChannelRole)> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let mut role = self.channel_role_for_user(&channel, user_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut role = self.channel_role_for_user(&channel, user_id, &tx).await?;
let mut accept_invite_result = None;
if role.is_none() {
if let Some(invitation) = self
.pending_invite_for_channel(&channel, user_id, &*tx)
.pending_invite_for_channel(&channel, user_id, &tx)
.await?
{
// note, this may be a parent channel
@@ -125,12 +128,12 @@ impl Database {
.await?;
accept_invite_result = Some(
self.calculate_membership_updated(&channel, user_id, &*tx)
self.calculate_membership_updated(&channel, user_id, &tx)
.await?,
);
debug_assert!(
self.channel_role_for_user(&channel, user_id, &*tx).await? == role
self.channel_role_for_user(&channel, user_id, &tx).await? == role
);
} else if channel.visibility == ChannelVisibility::Public {
role = Some(ChannelRole::Guest);
@@ -145,12 +148,12 @@ impl Database {
.await?;
accept_invite_result = Some(
self.calculate_membership_updated(&channel, user_id, &*tx)
self.calculate_membership_updated(&channel, user_id, &tx)
.await?,
);
debug_assert!(
self.channel_role_for_user(&channel, user_id, &*tx).await? == role
self.channel_role_for_user(&channel, user_id, &tx).await? == role
);
}
}
@@ -162,10 +165,10 @@ impl Database {
let live_kit_room = format!("channel-{}", nanoid::nanoid!(30));
let room_id = self
.get_or_create_channel_room(channel_id, &live_kit_room, &*tx)
.get_or_create_channel_room(channel_id, &live_kit_room, &tx)
.await?;
self.join_channel_room_internal(room_id, user_id, connection, role, &*tx)
self.join_channel_room_internal(room_id, user_id, connection, role, &tx)
.await
.map(|jr| (jr, accept_invite_result, role))
})
@@ -180,13 +183,13 @@ impl Database {
admin_id: UserId,
) -> Result<(Channel, Vec<channel_member::Model>)> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?;
if visibility == ChannelVisibility::Public {
if let Some(parent_id) = channel.parent_id() {
let parent = self.get_channel_internal(parent_id, &*tx).await?;
let parent = self.get_channel_internal(parent_id, &tx).await?;
if parent.visibility != ChannelVisibility::Public {
Err(ErrorCode::BadPublicNesting
@@ -196,7 +199,7 @@ impl Database {
}
} else if visibility == ChannelVisibility::Members {
if self
.get_channel_descendants_excluding_self([&channel], &*tx)
.get_channel_descendants_excluding_self([&channel], &tx)
.await?
.into_iter()
.any(|channel| channel.visibility == ChannelVisibility::Public)
@@ -228,7 +231,7 @@ impl Database {
requires_zed_cla: bool,
) -> Result<()> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
let mut model = channel.into_active_model();
model.requires_zed_cla = ActiveValue::Set(requires_zed_cla);
model.update(&*tx).await?;
@@ -244,8 +247,8 @@ impl Database {
user_id: UserId,
) -> Result<(Vec<ChannelId>, Vec<UserId>)> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, user_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, user_id, &tx)
.await?;
let members_to_notify: Vec<UserId> = channel_member::Entity::find()
@@ -258,7 +261,7 @@ impl Database {
.await?;
let channels_to_remove = self
.get_channel_descendants_excluding_self([&channel], &*tx)
.get_channel_descendants_excluding_self([&channel], &tx)
.await?
.into_iter()
.map(|channel| channel.id)
@@ -284,8 +287,8 @@ impl Database {
role: ChannelRole,
) -> Result<InviteMemberResult> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, inviter_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, inviter_id, &tx)
.await?;
if !channel.is_root() {
Err(ErrorCode::NotARootChannel.anyhow())?
@@ -312,7 +315,7 @@ impl Database {
inviter_id: inviter_id.to_proto(),
},
true,
&*tx,
&tx,
)
.await?
.into_iter()
@@ -344,8 +347,8 @@ impl Database {
self.transaction(move |tx| async move {
let new_name = Self::sanitize_channel_name(new_name)?.to_string();
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?;
let mut model = channel.into_active_model();
@@ -370,7 +373,7 @@ impl Database {
accept: bool,
) -> Result<RespondToChannelInvite> {
self.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
let membership_update = if accept {
let rows_affected = channel_member::Entity::update_many()
@@ -393,7 +396,7 @@ impl Database {
}
Some(
self.calculate_membership_updated(&channel, user_id, &*tx)
self.calculate_membership_updated(&channel, user_id, &tx)
.await?,
)
} else {
@@ -425,7 +428,7 @@ impl Database {
inviter_id: Default::default(),
},
accept,
&*tx,
&tx,
)
.await?
.into_iter()
@@ -441,9 +444,9 @@ impl Database {
user_id: UserId,
tx: &DatabaseTransaction,
) -> Result<MembershipUpdated> {
let new_channels = self.get_user_channels(user_id, Some(channel), &*tx).await?;
let new_channels = self.get_user_channels(user_id, Some(channel), tx).await?;
let removed_channels = self
.get_channel_descendants_excluding_self([channel], &*tx)
.get_channel_descendants_excluding_self([channel], tx)
.await?
.into_iter()
.map(|channel| channel.id)
@@ -466,10 +469,10 @@ impl Database {
admin_id: UserId,
) -> Result<RemoveChannelMemberResult> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
if member_id != admin_id {
self.check_user_is_channel_admin(&channel, admin_id, &*tx)
self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?;
}
@@ -488,7 +491,7 @@ impl Database {
Ok(RemoveChannelMemberResult {
membership_update: self
.calculate_membership_updated(&channel, member_id, &*tx)
.calculate_membership_updated(&channel, member_id, &tx)
.await?,
notification_id: self
.remove_notification(
@@ -498,7 +501,7 @@ impl Database {
channel_name: Default::default(),
inviter_id: Default::default(),
},
&*tx,
&tx,
)
.await?,
})
@@ -529,10 +532,7 @@ impl Database {
.all(&*tx)
.await?;
let channels = channels
.into_iter()
.filter_map(|channel| Some(Channel::from_model(channel)))
.collect();
let channels = channels.into_iter().map(Channel::from_model).collect();
Ok(channels)
})
@@ -567,16 +567,16 @@ impl Database {
let channel_memberships = channel_member::Entity::find()
.filter(filter)
.all(&*tx)
.all(tx)
.await?;
let channels = channel::Entity::find()
.filter(channel::Column::Id.is_in(channel_memberships.iter().map(|m| m.channel_id)))
.all(&*tx)
.all(tx)
.await?;
let mut descendants = self
.get_channel_descendants_excluding_self(channels.iter(), &*tx)
.get_channel_descendants_excluding_self(channels.iter(), tx)
.await?;
for channel in channels {
@@ -617,7 +617,7 @@ impl Database {
.column(room::Column::ChannelId)
.column(room_participant::Column::UserId)
.into_values::<_, QueryUserIdsAndChannelIds>()
.stream(&*tx)
.stream(tx)
.await?;
while let Some(row) = rows.next().await {
let row: (ChannelId, UserId) = row?;
@@ -628,32 +628,44 @@ impl Database {
let channel_ids = channels.iter().map(|c| c.id).collect::<Vec<_>>();
let mut channel_ids_by_buffer_id = HashMap::default();
let mut latest_buffer_versions: Vec<ChannelBufferVersion> = vec![];
let mut rows = buffer::Entity::find()
.filter(buffer::Column::ChannelId.is_in(channel_ids.iter().copied()))
.stream(&*tx)
.stream(tx)
.await?;
while let Some(row) = rows.next().await {
let row = row?;
channel_ids_by_buffer_id.insert(row.id, row.channel_id);
latest_buffer_versions.push(ChannelBufferVersion {
channel_id: row.channel_id.0 as u64,
epoch: row.latest_operation_epoch.unwrap_or_default() as u64,
version: if let Some((latest_lamport_timestamp, latest_replica_id)) = row
.latest_operation_lamport_timestamp
.zip(row.latest_operation_replica_id)
{
vec![VectorClockEntry {
timestamp: latest_lamport_timestamp as u32,
replica_id: latest_replica_id as u32,
}]
} else {
vec![]
},
});
}
drop(rows);
let latest_buffer_versions = self
.latest_channel_buffer_changes(&channel_ids_by_buffer_id, &*tx)
.await?;
let latest_channel_messages = self.latest_channel_messages(&channel_ids, &*tx).await?;
let latest_channel_messages = self.latest_channel_messages(&channel_ids, tx).await?;
let observed_buffer_versions = self
.observed_channel_buffer_changes(&channel_ids_by_buffer_id, user_id, &*tx)
.observed_channel_buffer_changes(&channel_ids_by_buffer_id, user_id, tx)
.await?;
let observed_channel_messages = self
.observed_channel_messages(&channel_ids, user_id, &*tx)
.observed_channel_messages(&channel_ids, user_id, tx)
.await?;
let hosted_projects = self
.get_hosted_projects(&channel_ids, &roles_by_channel_id, &*tx)
.get_hosted_projects(&channel_ids, &roles_by_channel_id, tx)
.await?;
Ok(ChannelsForUser {
@@ -677,8 +689,8 @@ impl Database {
role: ChannelRole,
) -> Result<SetMemberRoleResult> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?;
let membership = channel_member::Entity::find()
@@ -700,7 +712,7 @@ impl Database {
if updated.accepted {
Ok(SetMemberRoleResult::MembershipUpdated(
self.calculate_membership_updated(&channel, for_user, &*tx)
self.calculate_membership_updated(&channel, for_user, &tx)
.await?,
))
} else {
@@ -720,13 +732,13 @@ impl Database {
) -> Result<Vec<proto::ChannelMember>> {
let (role, members) = self
.transaction(move |tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
let role = self
.check_user_is_channel_participant(&channel, user_id, &*tx)
.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
Ok((
role,
self.get_channel_participant_details_internal(&channel, &*tx)
self.get_channel_participant_details_internal(&channel, &tx)
.await?,
))
})
@@ -781,7 +793,7 @@ impl Database {
tx: &DatabaseTransaction,
) -> Result<Vec<UserId>> {
let participants = self
.get_channel_participant_details_internal(channel, &*tx)
.get_channel_participant_details_internal(channel, tx)
.await?;
Ok(participants
.into_iter()
@@ -858,7 +870,7 @@ impl Database {
.filter(channel_member::Column::ChannelId.eq(channel.root_id()))
.filter(channel_member::Column::UserId.eq(user_id))
.filter(channel_member::Column::Accepted.eq(false))
.one(&*tx)
.one(tx)
.await?;
Ok(row)
@@ -878,7 +890,7 @@ impl Database {
.and(channel_member::Column::UserId.eq(user_id))
.and(channel_member::Column::Accepted.eq(true)),
)
.one(&*tx)
.one(tx)
.await?;
let Some(membership) = membership else {
@@ -918,8 +930,8 @@ impl Database {
/// Returns the channel with the given ID.
pub async fn get_channel(&self, channel_id: ChannelId, user_id: UserId) -> Result<Channel> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
Ok(Channel::from_model(channel))
@@ -933,7 +945,7 @@ impl Database {
tx: &DatabaseTransaction,
) -> Result<channel::Model> {
Ok(channel::Entity::find_by_id(channel_id)
.one(&*tx)
.one(tx)
.await?
.ok_or_else(|| proto::ErrorCode::NoSuchChannel.anyhow())?)
}
@@ -946,7 +958,7 @@ impl Database {
) -> Result<RoomId> {
let room = room::Entity::find()
.filter(room::Column::ChannelId.eq(channel_id))
.one(&*tx)
.one(tx)
.await?;
let room_id = if let Some(room) = room {
@@ -957,7 +969,7 @@ impl Database {
live_kit_room: ActiveValue::Set(live_kit_room.to_string()),
..Default::default()
})
.exec(&*tx)
.exec(tx)
.await?;
result.last_insert_id
@@ -974,10 +986,10 @@ impl Database {
admin_id: UserId,
) -> Result<(Vec<Channel>, Vec<channel_member::Model>)> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_admin(&channel, admin_id, &tx)
.await?;
let new_parent = self.get_channel_internal(new_parent_id, &*tx).await?;
let new_parent = self.get_channel_internal(new_parent_id, &tx).await?;
if new_parent.root_id() != channel.root_id() {
Err(anyhow!(ErrorCode::WrongMoveTarget))?;

View File

@@ -177,7 +177,7 @@ impl Database {
sender_id: sender_id.to_proto(),
},
true,
&*tx,
&tx,
)
.await?
.into_iter()
@@ -227,7 +227,7 @@ impl Database {
rpc::Notification::ContactRequest {
sender_id: requester_id.to_proto(),
},
&*tx,
&tx,
)
.await?;
}
@@ -335,7 +335,7 @@ impl Database {
sender_id: requester_id.to_proto(),
},
accept,
&*tx,
&tx,
)
.await?,
);
@@ -348,7 +348,7 @@ impl Database {
responder_id: responder_id.to_proto(),
},
true,
&*tx,
&tx,
)
.await?,
);

View File

@@ -72,7 +72,7 @@ impl Database {
github_login,
github_user_id,
github_email,
&*tx,
&tx,
)
.await?;

View File

@@ -1,4 +1,4 @@
use rpc::proto;
use rpc::{proto, ErrorCode};
use super::*;
@@ -9,20 +9,21 @@ impl Database {
roles: &HashMap<ChannelId, ChannelRole>,
tx: &DatabaseTransaction,
) -> Result<Vec<proto::HostedProject>> {
Ok(hosted_project::Entity::find()
let projects = hosted_project::Entity::find()
.find_also_related(project::Entity)
.filter(hosted_project::Column::ChannelId.is_in(channel_ids.iter().map(|id| id.0)))
.all(&*tx)
.all(tx)
.await?
.into_iter()
.flat_map(|project| {
if project.deleted_at.is_some() {
.flat_map(|(hosted_project, project)| {
if hosted_project.deleted_at.is_some() {
return None;
}
match project.visibility {
match hosted_project.visibility {
ChannelVisibility::Public => {}
ChannelVisibility::Members => {
let is_visible = roles
.get(&project.channel_id)
.get(&hosted_project.channel_id)
.map(|role| role.can_see_all_descendants())
.unwrap_or(false);
if !is_visible {
@@ -31,12 +32,54 @@ impl Database {
}
};
Some(proto::HostedProject {
id: project.id.to_proto(),
channel_id: project.channel_id.to_proto(),
name: project.name.clone(),
visibility: project.visibility.into(),
project_id: project?.id.to_proto(),
channel_id: hosted_project.channel_id.to_proto(),
name: hosted_project.name.clone(),
visibility: hosted_project.visibility.into(),
})
})
.collect())
.collect();
Ok(projects)
}
pub async fn get_hosted_project(
&self,
hosted_project_id: HostedProjectId,
user_id: UserId,
tx: &DatabaseTransaction,
) -> Result<(hosted_project::Model, ChannelRole)> {
let project = hosted_project::Entity::find_by_id(hosted_project_id)
.one(tx)
.await?
.ok_or_else(|| anyhow!(ErrorCode::NoSuchProject))?;
let channel = channel::Entity::find_by_id(project.channel_id)
.one(tx)
.await?
.ok_or_else(|| anyhow!(ErrorCode::NoSuchChannel))?;
let role = match project.visibility {
ChannelVisibility::Public => {
self.check_user_is_channel_participant(&channel, user_id, tx)
.await?
}
ChannelVisibility::Members => {
self.check_user_is_channel_member(&channel, user_id, tx)
.await?
}
};
Ok((project, role))
}
pub async fn is_hosted_project(&self, project_id: ProjectId) -> Result<bool> {
self.transaction(|tx| async move {
Ok(project::Entity::find_by_id(project_id)
.one(&*tx)
.await?
.map(|project| project.hosted_project_id.is_some())
.ok_or_else(|| anyhow!(ErrorCode::NoSuchProject))?)
})
.await
}
}

View File

@@ -12,8 +12,8 @@ impl Database {
user_id: UserId,
) -> Result<()> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
channel_chat_participant::ActiveModel {
id: ActiveValue::NotSet,
@@ -87,8 +87,8 @@ impl Database {
before_message_id: Option<MessageId>,
) -> Result<Vec<proto::ChannelMessage>> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
let mut condition =
@@ -105,7 +105,7 @@ impl Database {
.all(&*tx)
.await?;
self.load_channel_messages(rows, &*tx).await
self.load_channel_messages(rows, &tx).await
})
.await
}
@@ -127,16 +127,16 @@ impl Database {
for row in &rows {
channels.insert(
row.channel_id,
self.get_channel_internal(row.channel_id, &*tx).await?,
self.get_channel_internal(row.channel_id, &tx).await?,
);
}
for (_, channel) in channels {
self.check_user_is_channel_participant(&channel, user_id, &*tx)
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
}
let messages = self.load_channel_messages(rows, &*tx).await?;
let messages = self.load_channel_messages(rows, &tx).await?;
Ok(messages)
})
.await
@@ -171,7 +171,7 @@ impl Database {
.filter(channel_message_mention::Column::MessageId.is_in(messages.iter().map(|m| m.id)))
.order_by_asc(channel_message_mention::Column::MessageId)
.order_by_asc(channel_message_mention::Column::StartOffset)
.stream(&*tx)
.stream(tx)
.await?;
let mut message_ix = 0;
@@ -200,6 +200,7 @@ impl Database {
}
/// Creates a new channel message.
#[allow(clippy::too_many_arguments)]
pub async fn create_channel_message(
&self,
channel_id: ChannelId,
@@ -211,8 +212,8 @@ impl Database {
reply_to_message_id: Option<MessageId>,
) -> Result<CreatedChannelMessage> {
self.transaction(|tx| async move {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &*tx)
let channel = self.get_channel_internal(channel_id, &tx).await?;
self.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
let mut rows = channel_chat_participant::Entity::find()
@@ -302,13 +303,13 @@ impl Database {
channel_id: channel_id.to_proto(),
},
false,
&*tx,
&tx,
)
.await?,
);
}
self.observe_channel_message_internal(channel_id, user_id, message_id, &*tx)
self.observe_channel_message_internal(channel_id, user_id, message_id, &tx)
.await?;
}
_ => {
@@ -321,7 +322,7 @@ impl Database {
}
}
let mut channel_members = self.get_channel_participants(&channel, &*tx).await?;
let mut channel_members = self.get_channel_participants(&channel, &tx).await?;
channel_members.retain(|member| !participant_user_ids.contains(member));
Ok(CreatedChannelMessage {
@@ -341,7 +342,7 @@ impl Database {
message_id: MessageId,
) -> Result<NotificationBatch> {
self.transaction(|tx| async move {
self.observe_channel_message_internal(channel_id, user_id, message_id, &*tx)
self.observe_channel_message_internal(channel_id, user_id, message_id, &tx)
.await?;
let mut batch = NotificationBatch::default();
batch.extend(
@@ -352,7 +353,7 @@ impl Database {
sender_id: Default::default(),
channel_id: Default::default(),
},
&*tx,
&tx,
)
.await?,
);
@@ -383,7 +384,7 @@ impl Database {
.to_owned(),
)
// TODO: Try to upgrade SeaORM so we don't have to do this hack around their bug
.exec_without_returning(&*tx)
.exec_without_returning(tx)
.await?;
Ok(())
}
@@ -400,7 +401,7 @@ impl Database {
observed_channel_messages::Column::ChannelId
.is_in(channel_ids.iter().map(|id| id.0)),
)
.all(&*tx)
.all(tx)
.await?;
Ok(rows
@@ -451,7 +452,7 @@ impl Database {
let stmt = Statement::from_string(self.pool.get_database_backend(), sql);
let mut last_messages = channel_message::Model::find_by_statement(stmt)
.stream(&*tx)
.stream(tx)
.await?;
let mut results = Vec::new();
@@ -500,9 +501,9 @@ impl Database {
.await?;
if result.rows_affected == 0 {
let channel = self.get_channel_internal(channel_id, &*tx).await?;
let channel = self.get_channel_internal(channel_id, &tx).await?;
if self
.check_user_is_channel_admin(&channel, user_id, &*tx)
.check_user_is_channel_admin(&channel, user_id, &tx)
.await
.is_ok()
{

View File

@@ -95,7 +95,7 @@ impl Database {
content: ActiveValue::Set(proto.content.clone()),
..Default::default()
}
.save(&*tx)
.save(tx)
.await?;
Ok(Some((
@@ -184,7 +184,7 @@ impl Database {
tx: &DatabaseTransaction,
) -> Result<Option<(UserId, proto::Notification)>> {
if let Some(id) = self
.find_notification(recipient_id, notification, &*tx)
.find_notification(recipient_id, notification, tx)
.await?
{
let row = notification::Entity::update(notification::ActiveModel {
@@ -236,7 +236,7 @@ impl Database {
}),
)
.into_values::<_, QueryIds>()
.one(&*tx)
.one(tx)
.await?)
}
}

View File

@@ -57,13 +57,14 @@ impl Database {
}
let project = project::ActiveModel {
room_id: ActiveValue::set(participant.room_id),
host_user_id: ActiveValue::set(participant.user_id),
room_id: ActiveValue::set(Some(participant.room_id)),
host_user_id: ActiveValue::set(Some(participant.user_id)),
host_connection_id: ActiveValue::set(Some(connection.id as i32)),
host_connection_server_id: ActiveValue::set(Some(ServerId(
connection.owner_id as i32,
))),
..Default::default()
id: ActiveValue::NotSet,
hosted_project_id: ActiveValue::Set(None),
}
.insert(&*tx)
.await?;
@@ -153,8 +154,12 @@ impl Database {
self.update_project_worktrees(project.id, worktrees, &tx)
.await?;
let room_id = project
.room_id
.ok_or_else(|| anyhow!("project not in a room"))?;
let guest_connection_ids = self.project_guest_connection_ids(project.id, &tx).await?;
let room = self.get_room(project.room_id, &tx).await?;
let room = self.get_room(room_id, &tx).await?;
Ok((room, guest_connection_ids))
})
.await
@@ -181,7 +186,7 @@ impl Database {
.update_column(worktree::Column::RootName)
.to_owned(),
)
.exec(&*tx)
.exec(tx)
.await?;
}
@@ -189,7 +194,7 @@ impl Database {
.filter(worktree::Column::ProjectId.eq(project_id).and(
worktree::Column::Id.is_not_in(worktrees.iter().map(|worktree| worktree.id as i64)),
))
.exec(&*tx)
.exec(tx)
.await?;
Ok(())
@@ -382,7 +387,6 @@ impl Database {
language_server_id: ActiveValue::set(summary.language_server_id as i64),
error_count: ActiveValue::set(summary.error_count as i32),
warning_count: ActiveValue::set(summary.warning_count as i32),
..Default::default()
})
.on_conflict(
OnConflict::columns([
@@ -434,7 +438,6 @@ impl Database {
project_id: ActiveValue::set(project_id),
id: ActiveValue::set(server.id as i64),
name: ActiveValue::set(server.name.clone()),
..Default::default()
})
.on_conflict(
OnConflict::columns([
@@ -506,8 +509,42 @@ impl Database {
.await
}
/// Adds the given connection to the specified project.
pub async fn join_project(
/// Adds the given connection to the specified hosted project
pub async fn join_hosted_project(
&self,
id: ProjectId,
user_id: UserId,
connection: ConnectionId,
) -> Result<(Project, ReplicaId)> {
self.transaction(|tx| async move {
let (project, hosted_project) = project::Entity::find_by_id(id)
.find_also_related(hosted_project::Entity)
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("hosted project is no longer shared"))?;
let Some(hosted_project) = hosted_project else {
return Err(anyhow!("project is not hosted"))?;
};
let channel = channel::Entity::find_by_id(hosted_project.channel_id)
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("no such channel"))?;
let role = self
.check_user_is_channel_participant(&channel, user_id, &tx)
.await?;
self.join_project_internal(project, user_id, connection, role, &tx)
.await
})
.await
}
/// Adds the given connection to the specified project
/// in the current room.
pub async fn join_project_in_room(
&self,
project_id: ProjectId,
connection: ConnectionId,
@@ -534,180 +571,240 @@ impl Database {
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("no such project"))?;
if project.room_id != participant.room_id {
if project.room_id != Some(participant.room_id) {
return Err(anyhow!("no such project"))?;
}
self.join_project_internal(
project,
participant.user_id,
connection,
participant.role.unwrap_or(ChannelRole::Member),
&tx,
)
.await
})
.await
}
let mut collaborators = project
async fn join_project_internal(
&self,
project: project::Model,
user_id: UserId,
connection: ConnectionId,
role: ChannelRole,
tx: &DatabaseTransaction,
) -> Result<(Project, ReplicaId)> {
let mut collaborators = project
.find_related(project_collaborator::Entity)
.all(tx)
.await?;
let replica_ids = collaborators
.iter()
.map(|c| c.replica_id)
.collect::<HashSet<_>>();
let mut replica_id = ReplicaId(1);
while replica_ids.contains(&replica_id) {
replica_id.0 += 1;
}
let new_collaborator = project_collaborator::ActiveModel {
project_id: ActiveValue::set(project.id),
connection_id: ActiveValue::set(connection.id as i32),
connection_server_id: ActiveValue::set(ServerId(connection.owner_id as i32)),
user_id: ActiveValue::set(user_id),
replica_id: ActiveValue::set(replica_id),
is_host: ActiveValue::set(false),
..Default::default()
}
.insert(tx)
.await?;
collaborators.push(new_collaborator);
let db_worktrees = project.find_related(worktree::Entity).all(tx).await?;
let mut worktrees = db_worktrees
.into_iter()
.map(|db_worktree| {
(
db_worktree.id as u64,
Worktree {
id: db_worktree.id as u64,
abs_path: db_worktree.abs_path,
root_name: db_worktree.root_name,
visible: db_worktree.visible,
entries: Default::default(),
repository_entries: Default::default(),
diagnostic_summaries: Default::default(),
settings_files: Default::default(),
scan_id: db_worktree.scan_id as u64,
completed_scan_id: db_worktree.completed_scan_id as u64,
},
)
})
.collect::<BTreeMap<_, _>>();
// Populate worktree entries.
{
let mut db_entries = worktree_entry::Entity::find()
.filter(
Condition::all()
.add(worktree_entry::Column::ProjectId.eq(project.id))
.add(worktree_entry::Column::IsDeleted.eq(false)),
)
.stream(tx)
.await?;
while let Some(db_entry) = db_entries.next().await {
let db_entry = db_entry?;
if let Some(worktree) = worktrees.get_mut(&(db_entry.worktree_id as u64)) {
worktree.entries.push(proto::Entry {
id: db_entry.id as u64,
is_dir: db_entry.is_dir,
path: db_entry.path,
inode: db_entry.inode as u64,
mtime: Some(proto::Timestamp {
seconds: db_entry.mtime_seconds as u64,
nanos: db_entry.mtime_nanos as u32,
}),
is_symlink: db_entry.is_symlink,
is_ignored: db_entry.is_ignored,
is_external: db_entry.is_external,
git_status: db_entry.git_status.map(|status| status as i32),
});
}
}
}
// Populate repository entries.
{
let mut db_repository_entries = worktree_repository::Entity::find()
.filter(
Condition::all()
.add(worktree_repository::Column::ProjectId.eq(project.id))
.add(worktree_repository::Column::IsDeleted.eq(false)),
)
.stream(tx)
.await?;
while let Some(db_repository_entry) = db_repository_entries.next().await {
let db_repository_entry = db_repository_entry?;
if let Some(worktree) = worktrees.get_mut(&(db_repository_entry.worktree_id as u64))
{
worktree.repository_entries.insert(
db_repository_entry.work_directory_id as u64,
proto::RepositoryEntry {
work_directory_id: db_repository_entry.work_directory_id as u64,
branch: db_repository_entry.branch,
},
);
}
}
}
// Populate worktree diagnostic summaries.
{
let mut db_summaries = worktree_diagnostic_summary::Entity::find()
.filter(worktree_diagnostic_summary::Column::ProjectId.eq(project.id))
.stream(tx)
.await?;
while let Some(db_summary) = db_summaries.next().await {
let db_summary = db_summary?;
if let Some(worktree) = worktrees.get_mut(&(db_summary.worktree_id as u64)) {
worktree
.diagnostic_summaries
.push(proto::DiagnosticSummary {
path: db_summary.path,
language_server_id: db_summary.language_server_id as u64,
error_count: db_summary.error_count as u32,
warning_count: db_summary.warning_count as u32,
});
}
}
}
// Populate worktree settings files
{
let mut db_settings_files = worktree_settings_file::Entity::find()
.filter(worktree_settings_file::Column::ProjectId.eq(project.id))
.stream(tx)
.await?;
while let Some(db_settings_file) = db_settings_files.next().await {
let db_settings_file = db_settings_file?;
if let Some(worktree) = worktrees.get_mut(&(db_settings_file.worktree_id as u64)) {
worktree.settings_files.push(WorktreeSettingsFile {
path: db_settings_file.path,
content: db_settings_file.content,
});
}
}
}
// Populate language servers.
let language_servers = project
.find_related(language_server::Entity)
.all(tx)
.await?;
let project = Project {
id: project.id,
role,
collaborators: collaborators
.into_iter()
.map(|collaborator| ProjectCollaborator {
connection_id: collaborator.connection(),
user_id: collaborator.user_id,
replica_id: collaborator.replica_id,
is_host: collaborator.is_host,
})
.collect(),
worktrees,
language_servers: language_servers
.into_iter()
.map(|language_server| proto::LanguageServer {
id: language_server.id as u64,
name: language_server.name,
})
.collect(),
};
Ok((project, replica_id as ReplicaId))
}
pub async fn leave_hosted_project(
&self,
project_id: ProjectId,
connection: ConnectionId,
) -> Result<LeftProject> {
self.transaction(|tx| async move {
let result = project_collaborator::Entity::delete_many()
.filter(
Condition::all()
.add(project_collaborator::Column::ProjectId.eq(project_id))
.add(project_collaborator::Column::ConnectionId.eq(connection.id as i32))
.add(
project_collaborator::Column::ConnectionServerId
.eq(connection.owner_id as i32),
),
)
.exec(&*tx)
.await?;
if result.rows_affected == 0 {
return Err(anyhow!("not in the project"))?;
}
let project = project::Entity::find_by_id(project_id)
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("no such project"))?;
let collaborators = project
.find_related(project_collaborator::Entity)
.all(&*tx)
.await?;
let replica_ids = collaborators
.iter()
.map(|c| c.replica_id)
.collect::<HashSet<_>>();
let mut replica_id = ReplicaId(1);
while replica_ids.contains(&replica_id) {
replica_id.0 += 1;
}
let new_collaborator = project_collaborator::ActiveModel {
project_id: ActiveValue::set(project_id),
connection_id: ActiveValue::set(connection.id as i32),
connection_server_id: ActiveValue::set(ServerId(connection.owner_id as i32)),
user_id: ActiveValue::set(participant.user_id),
replica_id: ActiveValue::set(replica_id),
is_host: ActiveValue::set(false),
..Default::default()
}
.insert(&*tx)
.await?;
collaborators.push(new_collaborator);
let db_worktrees = project.find_related(worktree::Entity).all(&*tx).await?;
let mut worktrees = db_worktrees
let connection_ids = collaborators
.into_iter()
.map(|db_worktree| {
(
db_worktree.id as u64,
Worktree {
id: db_worktree.id as u64,
abs_path: db_worktree.abs_path,
root_name: db_worktree.root_name,
visible: db_worktree.visible,
entries: Default::default(),
repository_entries: Default::default(),
diagnostic_summaries: Default::default(),
settings_files: Default::default(),
scan_id: db_worktree.scan_id as u64,
completed_scan_id: db_worktree.completed_scan_id as u64,
},
)
})
.collect::<BTreeMap<_, _>>();
// Populate worktree entries.
{
let mut db_entries = worktree_entry::Entity::find()
.filter(
Condition::all()
.add(worktree_entry::Column::ProjectId.eq(project_id))
.add(worktree_entry::Column::IsDeleted.eq(false)),
)
.stream(&*tx)
.await?;
while let Some(db_entry) = db_entries.next().await {
let db_entry = db_entry?;
if let Some(worktree) = worktrees.get_mut(&(db_entry.worktree_id as u64)) {
worktree.entries.push(proto::Entry {
id: db_entry.id as u64,
is_dir: db_entry.is_dir,
path: db_entry.path,
inode: db_entry.inode as u64,
mtime: Some(proto::Timestamp {
seconds: db_entry.mtime_seconds as u64,
nanos: db_entry.mtime_nanos as u32,
}),
is_symlink: db_entry.is_symlink,
is_ignored: db_entry.is_ignored,
is_external: db_entry.is_external,
git_status: db_entry.git_status.map(|status| status as i32),
});
}
}
}
// Populate repository entries.
{
let mut db_repository_entries = worktree_repository::Entity::find()
.filter(
Condition::all()
.add(worktree_repository::Column::ProjectId.eq(project_id))
.add(worktree_repository::Column::IsDeleted.eq(false)),
)
.stream(&*tx)
.await?;
while let Some(db_repository_entry) = db_repository_entries.next().await {
let db_repository_entry = db_repository_entry?;
if let Some(worktree) =
worktrees.get_mut(&(db_repository_entry.worktree_id as u64))
{
worktree.repository_entries.insert(
db_repository_entry.work_directory_id as u64,
proto::RepositoryEntry {
work_directory_id: db_repository_entry.work_directory_id as u64,
branch: db_repository_entry.branch,
},
);
}
}
}
// Populate worktree diagnostic summaries.
{
let mut db_summaries = worktree_diagnostic_summary::Entity::find()
.filter(worktree_diagnostic_summary::Column::ProjectId.eq(project_id))
.stream(&*tx)
.await?;
while let Some(db_summary) = db_summaries.next().await {
let db_summary = db_summary?;
if let Some(worktree) = worktrees.get_mut(&(db_summary.worktree_id as u64)) {
worktree
.diagnostic_summaries
.push(proto::DiagnosticSummary {
path: db_summary.path,
language_server_id: db_summary.language_server_id as u64,
error_count: db_summary.error_count as u32,
warning_count: db_summary.warning_count as u32,
});
}
}
}
// Populate worktree settings files
{
let mut db_settings_files = worktree_settings_file::Entity::find()
.filter(worktree_settings_file::Column::ProjectId.eq(project_id))
.stream(&*tx)
.await?;
while let Some(db_settings_file) = db_settings_files.next().await {
let db_settings_file = db_settings_file?;
if let Some(worktree) =
worktrees.get_mut(&(db_settings_file.worktree_id as u64))
{
worktree.settings_files.push(WorktreeSettingsFile {
path: db_settings_file.path,
content: db_settings_file.content,
});
}
}
}
// Populate language servers.
let language_servers = project
.find_related(language_server::Entity)
.all(&*tx)
.await?;
let project = Project {
collaborators: collaborators
.into_iter()
.map(|collaborator| ProjectCollaborator {
connection_id: collaborator.connection(),
user_id: collaborator.user_id,
replica_id: collaborator.replica_id,
is_host: collaborator.is_host,
})
.collect(),
worktrees,
language_servers: language_servers
.into_iter()
.map(|language_server| proto::LanguageServer {
id: language_server.id as u64,
name: language_server.name,
})
.collect(),
};
Ok((project, replica_id as ReplicaId))
.map(|collaborator| collaborator.connection())
.collect();
Ok(LeftProject {
id: project.id,
connection_ids,
host_user_id: None,
host_connection_id: None,
})
})
.await
}
@@ -774,7 +871,7 @@ impl Database {
.exec(&*tx)
.await?;
let room = self.get_room(project.room_id, &tx).await?;
let room = self.get_room(room_id, &tx).await?;
let left_project = LeftProject {
id: project_id,
host_user_id: project.host_user_id,
@@ -998,7 +1095,9 @@ impl Database {
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("project {} not found", project_id))?;
Ok(project.room_id)
Ok(project
.room_id
.ok_or_else(|| anyhow!("project not in room"))?)
})
.await
}
@@ -1061,7 +1160,7 @@ impl Database {
.insert(&*tx)
.await?;
let room = self.get_room(room_id, &*tx).await?;
let room = self.get_room(room_id, &tx).await?;
Ok(room)
})
.await
@@ -1095,7 +1194,7 @@ impl Database {
.exec(&*tx)
.await?;
let room = self.get_room(room_id, &*tx).await?;
let room = self.get_room(room_id, &tx).await?;
Ok(room)
})
.await

View File

@@ -321,7 +321,7 @@ impl Database {
}
let participant_index = self
.get_next_participant_index_internal(room_id, &*tx)
.get_next_participant_index_internal(room_id, &tx)
.await?;
let result = room_participant::Entity::update_many()
@@ -374,7 +374,7 @@ impl Database {
.select_only()
.column(room_participant::Column::ParticipantIndex)
.into_values::<_, QueryParticipantIndices>()
.all(&*tx)
.all(tx)
.await?;
let mut participant_index = 0;
@@ -407,7 +407,7 @@ impl Database {
tx: &DatabaseTransaction,
) -> Result<JoinRoom> {
let participant_index = self
.get_next_participant_index_internal(room_id, &*tx)
.get_next_participant_index_internal(room_id, tx)
.await?;
room_participant::Entity::insert_many([room_participant::ActiveModel {
@@ -441,12 +441,12 @@ impl Database {
])
.to_owned(),
)
.exec(&*tx)
.exec(tx)
.await?;
let (channel, room) = self.get_channel_room(room_id, &tx).await?;
let channel = channel.ok_or_else(|| anyhow!("no channel for room"))?;
let channel_members = self.get_channel_participants(&channel, &*tx).await?;
let channel_members = self.get_channel_participants(&channel, tx).await?;
Ok(JoinRoom {
room,
channel_id: Some(channel.id),
@@ -468,15 +468,7 @@ impl Database {
Condition::all()
.add(room_participant::Column::RoomId.eq(room_id))
.add(room_participant::Column::UserId.eq(user_id))
.add(room_participant::Column::AnsweringConnectionId.is_not_null())
.add(
Condition::any()
.add(room_participant::Column::AnsweringConnectionLost.eq(true))
.add(
room_participant::Column::AnsweringConnectionServerId
.ne(connection.owner_id as i32),
),
),
.add(room_participant::Column::AnsweringConnectionId.is_not_null()),
)
.set(room_participant::ActiveModel {
answering_connection_id: ActiveValue::set(Some(connection.id as i32)),
@@ -499,7 +491,7 @@ impl Database {
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("project does not exist"))?;
if project.host_user_id != user_id {
if project.host_user_id != Some(user_id) {
return Err(anyhow!("no such project"))?;
}
@@ -859,7 +851,7 @@ impl Database {
}
if collaborator.is_host {
left_project.host_user_id = collaborator.user_id;
left_project.host_user_id = Some(collaborator.user_id);
left_project.host_connection_id = Some(collaborator_connection_id);
}
}
@@ -1018,7 +1010,7 @@ impl Database {
.ok_or_else(|| anyhow!("only admins can set participant role"))?;
if role.requires_cla() {
self.check_user_has_signed_cla(user_id, room_id, &*tx)
self.check_user_has_signed_cla(user_id, room_id, &tx)
.await?;
}
@@ -1029,7 +1021,7 @@ impl Database {
.add(room_participant::Column::UserId.eq(user_id)),
)
.set(room_participant::ActiveModel {
role: ActiveValue::set(Some(ChannelRole::from(role))),
role: ActiveValue::set(Some(role)),
..Default::default()
})
.exec(&*tx)
@@ -1038,7 +1030,7 @@ impl Database {
if result.rows_affected != 1 {
Err(anyhow!("could not update room participant role"))?;
}
Ok(self.get_room(room_id, &tx).await?)
self.get_room(room_id, &tx).await
})
.await
}
@@ -1050,11 +1042,11 @@ impl Database {
tx: &DatabaseTransaction,
) -> Result<()> {
let channel = room::Entity::find_by_id(room_id)
.one(&*tx)
.one(tx)
.await?
.ok_or_else(|| anyhow!("could not find room"))?
.find_related(channel::Entity)
.one(&*tx)
.one(tx)
.await?;
if let Some(channel) = channel {
@@ -1065,13 +1057,13 @@ impl Database {
.is_in(channel.ancestors())
.and(channel::Column::RequiresZedCla.eq(true)),
)
.count(&*tx)
.count(tx)
.await?
> 0;
if requires_zed_cla {
if contributor::Entity::find()
.filter(contributor::Column::UserId.eq(user_id))
.one(&*tx)
.one(tx)
.await?
.is_none()
{
@@ -1084,10 +1076,9 @@ impl Database {
pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()> {
self.transaction(|tx| async move {
self.room_connection_lost(connection, &*tx).await?;
self.channel_buffer_connection_lost(connection, &*tx)
.await?;
self.channel_chat_connection_lost(connection, &*tx).await?;
self.room_connection_lost(connection, &tx).await?;
self.channel_buffer_connection_lost(connection, &tx).await?;
self.channel_chat_connection_lost(connection, &tx).await?;
Ok(())
})
.await
@@ -1107,7 +1098,7 @@ impl Database {
.eq(connection.owner_id as i32),
),
)
.one(&*tx)
.one(tx)
.await?;
if let Some(participant) = participant {
@@ -1115,7 +1106,7 @@ impl Database {
answering_connection_lost: ActiveValue::set(true),
..participant.into_active_model()
})
.exec(&*tx)
.exec(tx)
.await?;
}
Ok(())
@@ -1304,7 +1295,7 @@ impl Database {
drop(db_followers);
let channel = if let Some(channel_id) = db_room.channel_id {
Some(self.get_channel_internal(channel_id, &*tx).await?)
Some(self.get_channel_internal(channel_id, tx).await?)
} else {
None
};

Some files were not shown because too many files have changed in this diff Show More