Compare commits

...

1796 Commits

Author SHA1 Message Date
Max Brunsfeld
806da0e9ba 0.42.0 2022-06-28 14:33:19 -07:00
Keith Simmons
26215a0d6e Merge pull request #1254 from zed-industries/command-palette-filter
Command palette filter
2022-06-28 14:31:21 -07:00
Max Brunsfeld
fc3ec6966b Merge pull request #1235 from zed-industries/diagnostics-in-hidden-worktrees
Allow diagnostics to be published for hidden worktrees
2022-06-28 14:29:41 -07:00
Max Brunsfeld
8fe6809932 Exclude hidden worktrees from project's diagnostic summaries 2022-06-28 14:23:24 -07:00
Keith Simmons
cea7d3f5a2 add test for filter 2022-06-28 13:45:34 -07:00
Keith Simmons
f6292437fa Add command palette filter global and update it when vim mode is enabled/disabled 2022-06-28 13:35:43 -07:00
Max Brunsfeld
809f330566 Merge pull request #1253 from zed-industries/rust-autoindent-fix
Fix rust auto-indent regression
2022-06-28 13:34:56 -07:00
Max Brunsfeld
f05e94d0de Allow diagnostics to be published for hidden worktrees 2022-06-28 13:31:04 -07:00
Max Brunsfeld
fae1cc36d6 In most languages, use prev non-empty line as basis for preserving indent 2022-06-28 12:21:54 -07:00
Antonio Scandurra
431d71fe92 v0.41.0 2022-06-28 11:21:06 +02:00
Antonio Scandurra
a53de67e6f Merge pull request #1247 from zed-industries/ignore-non-created-progress-tokens
Ignore tokens that were not created via `WorkDoneProgressCreate`
2022-06-28 10:14:42 +02:00
Antonio Scandurra
6cf9514e00 Merge pull request #1246 from zed-industries/python-autoindent
Fix Python auto-indent using new auto-indent features
2022-06-28 10:14:22 +02:00
Antonio Scandurra
ca1d0a6e59 Ignore tokens that were not created via WorkDoneProgressCreate
With the new version of rust-analyzer, we were seeing stray `WorkDoneProgress::End`
messages that create an imbalance in the `pending_diagnostic_updates` that never
resolves. This was causing the diagnostic status bar item to never update because
we wouldn't emit `DiskBasedDiagnosticsStarted` nor `DiskBasedDiagnosticsFinished`.

This commit fixes the above situation by only acknowledging progress report for tokens
that have explicitly been created via the `WorkDoneProgressCreate` request, as stated
by the protocol.

In addition to that, we are replacing the `pending_diagnostic_updates: isize` with
a `has_pending_diagnostic_updates: bool`. We added it at some point to prevent a similar
issue where we would observe begin/end reports in a seemingly random order, which would cause
us to permanently display a `checking...` message in the status bar. I believe this commit
fixes that as well because the `isize` was just a less general solution for the same
underlying issue. As the protocol states: "the token provided in the create request should
only be used once (e.g. only one begin, many report and one end notification should be sent
to it)."
2022-06-28 10:08:43 +02:00
Antonio Scandurra
c127eb56ce Merge pull request #1241 from zed-industries/reopen-closed-item
Introduce `pane::ReopenClosedItem` bound to `cmd-shift-t`
2022-06-28 08:09:03 +02:00
Antonio Scandurra
57f34c6992 💄 2022-06-28 08:04:39 +02:00
Max Brunsfeld
929615964d Add new indentation features to support Python 2022-06-27 22:34:14 -07:00
Keith Simmons
d16ed327f2 Merge pull request #1244 from zed-industries/address-go-hover-panic
Address hover panic add hint for installing go language server
2022-06-27 16:34:02 -07:00
Keith Simmons
1eb8351440 add hover popover setting 2022-06-27 16:21:22 -07:00
Keith Simmons
a477733bcb Address hover panic and add hint to install go when language server failed to install 2022-06-27 15:48:15 -07:00
Keith Simmons
bc82d98ae5 Merge pull request #1237 from zed-industries/jump-to-definition
Mouse jump to definition
2022-06-27 15:20:07 -07:00
Max Brunsfeld
095f18d661 Upgrade Tree-sitter, Tree-sitter-python 2022-06-27 15:12:31 -07:00
Keith Simmons
f73af85218 bump protocol version and fix panic from storing display points instead of anchors 2022-06-27 15:10:36 -07:00
Keith Simmons
a0577f5f46 Fix usage of existing definitions 2022-06-27 10:07:44 -07:00
Antonio Scandurra
c6e7ae528f Add test for reopening closed items 2022-06-27 17:59:25 +02:00
Antonio Scandurra
0652542f60 Introduce pane::ReopenClosedItem bound to cmd-shift-t 2022-06-27 17:44:33 +02:00
Antonio Scandurra
024dfd760c Merge pull request #1239 from zed-industries/ignore-scan-child-errors
Don't stop scanning directory if reading one of the children errors
2022-06-27 08:47:21 +02:00
Antonio Scandurra
7bfd7093b1 Don't stop scanning directory if reading one of the children errors 2022-06-27 08:40:37 +02:00
Antonio Scandurra
9fbcf0e640 Merge pull request #1238 from zed-industries/users-with-no-invites
Allow users with no invites to be fetched from the API
2022-06-27 08:18:19 +02:00
Keith Simmons
a8ea1048cf Change mouse cursor when link is visible 2022-06-24 21:55:57 -07:00
Keith Simmons
a190eb0537 fix rebase merge error 2022-06-24 15:11:57 -07:00
Keith Simmons
92ab107fc9 working jump to definition with tests 2022-06-24 15:09:31 -07:00
Keith Simmons
848445455d Working underline based on symbol origin 2022-06-24 15:05:35 -07:00
Keith Simmons
4286a9b564 wip 2022-06-24 15:03:24 -07:00
Keith Simmons
f78b55f92d wip 2022-06-24 15:03:24 -07:00
Nathan Sobo
4da3005b5c Allow users with no invites to be fetched from the API 2022-06-24 09:57:52 -06:00
Antonio Scandurra
b0eb692760 WIP 2022-06-24 17:21:58 +02:00
Antonio Scandurra
9fcebe783c Merge pull request #1236 from zed-industries/reduce-server-memory-footprint
Reduce memory footprint on server
2022-06-24 09:34:04 +02:00
Antonio Scandurra
fc5517b6be Gather metrics only when /metrics endpoint is retrieved 2022-06-24 09:28:52 +02:00
Antonio Scandurra
a04adbcac1 Don't trace message payload 2022-06-24 09:27:22 +02:00
Max Brunsfeld
4f643baeee 0.40.0 2022-06-23 13:29:32 -07:00
Max Brunsfeld
c91451a1b2 Merge pull request #1234 from zed-industries/fix-editor-cloning
Clone fold and selection state correctly when splitting an editor
2022-06-23 13:27:40 -07:00
Max Brunsfeld
f4e7e8b231 Merge pull request #1229 from zed-industries/non-zero-tabsize
Use NonZeroU32 to ensure settings tabsize cannot be zero
2022-06-23 13:27:30 -07:00
Max Brunsfeld
fb2a7787a1 Clone fold and selection state correctly when splitting an editor 2022-06-23 13:15:50 -07:00
Keith Simmons
755636d10e Use NonZeroU32 to ensure settings tabsize cannot be zero 2022-06-23 12:55:38 -07:00
Max Brunsfeld
1720933597 Merge pull request #1228 from zed-industries/python
Add Python support
2022-06-23 11:25:18 -07:00
Max Brunsfeld
dc056fc46f Treat .pyi files as Python 2022-06-23 11:14:11 -07:00
Max Brunsfeld
4d4db6ec4b Syntax-highlight Python project symbols and completions 2022-06-23 11:14:01 -07:00
Max Brunsfeld
981e53784d Upgrade tree-sitter-python for error recovery improvement 2022-06-23 11:13:30 -07:00
Antonio Scandurra
555847449b Use BTreeMap in Server so we release memory when maps are cleared
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-06-23 18:02:17 +02:00
Antonio Scandurra
63df644d8f Merge pull request #1232 from zed-industries/language-defaults
Don't override top-level settings with language defaults
2022-06-23 16:48:08 +02:00
Antonio Scandurra
2cb8a3ccfb Don't override top-level settings with language defaults
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-06-23 16:40:57 +02:00
Antonio Scandurra
f2f9cad375 Merge pull request #1231 from zed-industries/prompt-to-save-on-window-close
Prompt user to save changed buffers when closing window via the mouse
2022-06-23 14:44:20 +02:00
Antonio Scandurra
90102f22fd Improve testing of window edit state 2022-06-23 14:41:47 +02:00
Antonio Scandurra
a21dbdd0d6 Update window edited status when pane item is removed 2022-06-23 14:28:10 +02:00
Antonio Scandurra
2dae0ddcdb Add test to verify closing window via the mouse 2022-06-23 14:18:53 +02:00
Antonio Scandurra
d9b5357234 Always prevent window from closing and manually invoke Workspace::close
This ensures we ask the user to save their state if there are unsaved
changes.
2022-06-23 11:44:14 +02:00
Antonio Scandurra
06033d7fa9 Introduce ViewContext::on_window_should_close
This is a new callback that can be used to interrupt closing the window
when the user has unsaved changes.
2022-06-23 11:43:19 +02:00
Antonio Scandurra
ca8ddcdeec Set window's edited = true when there are unsaved changes 2022-06-23 10:59:50 +02:00
Antonio Scandurra
a6262b97ff Merge pull request #1230 from zed-industries/wrap-panic
Fix panic when `Text` contained carriage returns
2022-06-23 10:28:01 +02:00
Antonio Scandurra
01349e1d42 Fix panic when Text contained carriage returns 2022-06-23 10:21:21 +02:00
Antonio Scandurra
b715e521ce Merge pull request #1227 from zed-industries/maintain-keepalive-under-high-message-volume
Maintain keepalive under high message volume
2022-06-23 07:56:17 +02:00
Max Brunsfeld
11f73bfa4e Integrate pyright language server 2022-06-22 16:58:19 -07:00
Max Brunsfeld
c0dbd8f9b9 Add python outline and bracket queries 2022-06-22 16:28:09 -07:00
Max Brunsfeld
074caa09c2 Make python indent query more general
Upgrade Tree-sitter for a query bugfix that I found while
writing this indent query.
2022-06-22 16:18:52 -07:00
Max Brunsfeld
4cb68b2966 Prioritize keepalive pings over incoming message handling in Peer 2022-06-22 14:44:05 -07:00
Max Brunsfeld
36f8c68099 Remove redundant run_until_parked call in Foreground::advance_clock 2022-06-22 14:43:21 -07:00
Max Brunsfeld
a14b626927 Enable env log in peer tests 2022-06-22 14:42:20 -07:00
Max Brunsfeld
c0a434fe27 Merge pull request #1225 from zed-industries/fix-randomized-test-failure
Don't wait for host's worktree updates if they disconnected
2022-06-22 11:01:25 -07:00
Antonio Scandurra
2d8ffbdfa2 Don't wait for host's worktree updates if they disconnected
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-22 19:45:55 +02:00
Antonio Scandurra
48ff443d10 Remove stray log statement when contacts are updated
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-22 19:40:52 +02:00
Antonio Scandurra
49addc9937 Merge pull request #1224 from zed-industries/forward-deadlock
Prevent deadlocks when two clients perform a request to each other
2022-06-22 19:04:07 +02:00
Antonio Scandurra
f2d134917e Remove non-determinism from Peer caused by smol's timeout helper 2022-06-22 18:39:12 +02:00
Antonio Scandurra
071d940a88 Ensure receive timeout is triggered before waiting on disconnection 2022-06-22 18:02:42 +02:00
Antonio Scandurra
9b521d6097 Use Arc<Deterministic> to understand which await points are parking 2022-06-22 17:39:34 +02:00
Antonio Scandurra
62521531a6 💄 2022-06-22 15:06:22 +02:00
Antonio Scandurra
fb2590d913 Use a FuturesUnordered to process foreground messages
This prevents deadlocks when e.g., client A performs a request to client B and
client B performs a request to client A. If both clients stop processing further
messages until their respective request completes, they won't have a chance to
respond to the other client's request and cause a deadlock.

This arrangement ensures we will attempt to process earlier messages first, but fall
back to processing messages arrived later in the spirit of making progress.
2022-06-22 15:04:17 +02:00
Antonio Scandurra
6eb3e72c36 Add test demonstrating hang when peers wait on each other's response 2022-06-22 14:41:14 +02:00
Antonio Scandurra
f09a997d2d Merge pull request #1223 from zed-industries/update-metadata-when-worktrees-are-removed
Update project metadata when releasing a worktree's weak handle
2022-06-22 10:50:44 +02:00
Antonio Scandurra
2f09a4af16 Update project metadata when releasing a worktree's weak handle
When a project was getting unshared, we would remove invisible worktrees
from the project's state without notifying the server, which was causing
the randomized tests to fail.

This commit calls `Project::remove_worktree` when a worktree's handle gets
released. Doing so ensures that we update both our local metadata database
as well as the state on the server.
2022-06-22 10:26:10 +02:00
Max Brunsfeld
34351c0a51 Start work on Python support 2022-06-21 17:04:54 -07:00
Keith Simmons
484e98c0bb Merge pull request #1216 from zed-industries/hover-context-menu-fix
Don't trigger hover popover action when mouse is over context menu
2022-06-21 13:43:24 -07:00
Keith Simmons
19feb627d8 Add comment linking to long term plan 2022-06-21 12:38:27 -07:00
Max Brunsfeld
dc8d5f4ae3 Merge pull request #1217 from zed-industries/fix-lsp-statuses-for-guests
Report running language servers when sharing project for the first time
2022-06-21 11:50:58 -07:00
Antonio Scandurra
83f38aa1ba Merge pull request #1215 from zed-industries/suggest-upgrade-on-reconnect
Show upgrade required message when reconnecting after a protocol change
2022-06-21 20:41:36 +02:00
Antonio Scandurra
69aa3d848e Report running language servers when sharing project for the first time
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-21 20:39:54 +02:00
Max Brunsfeld
e9d19457d6 Add failing test for replication of lsp statuses
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-21 11:27:08 -07:00
Keith Simmons
057a7ec989 Don't trigger hover popover action when mouse is over context menu 2022-06-21 11:23:25 -07:00
Antonio Scandurra
a5ae8d9072 Merge pull request #1214 from zed-industries/fix-error-on-empty-worktree-update
Fix error when worktree has no file extensions
2022-06-21 20:08:20 +02:00
Max Brunsfeld
30d75620f1 Fix error when worktree has no file extensions
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-21 11:02:13 -07:00
Keith Simmons
e88f115467 Merge pull request #1213 from zed-industries/hover-dismiss-fix
hide hover on editor blur
2022-06-21 10:47:52 -07:00
Keith Simmons
fb881b2eda hide hover on editor blur 2022-06-21 10:37:59 -07:00
Max Brunsfeld
6a2c5e0dc1 Show upgrade required message when reconnecting after a protocol change
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-21 10:26:34 -07:00
Antonio Scandurra
69bd6bf1f3 Merge pull request #1212 from zed-industries/persist-project-activity
Add an API that returns the most active zed users and the projects where they've been active
2022-06-21 18:16:29 +02:00
Antonio Scandurra
db77601aa2 Expose project metadata via GET /project_metadata 2022-06-21 18:06:31 +02:00
Antonio Scandurra
ebaf3224fd Exclude staff from activity recording 2022-06-21 16:07:59 +02:00
Antonio Scandurra
c90e8c08a6 Accept a datetime range when querying project activity 2022-06-21 14:03:10 +02:00
Antonio Scandurra
95a629d200 Unregister project from db when user disconnects or manually does so 2022-06-21 10:37:34 +02:00
Antonio Scandurra
7acebc4eb8 Register projects in the database and record worktree extensions 2022-06-21 10:29:26 +02:00
Max Brunsfeld
44160869eb Add an API that returns the most active users and the projects where they've been active 2022-06-20 19:46:37 -07:00
Antonio Scandurra
bc3287e5d0 Merge pull request #1209 from zed-industries/mdx-highlighting
Highlight files ending in `mdx` as Markdown
2022-06-20 15:56:14 +02:00
Antonio Scandurra
0e20782b53 Highlight files ending in mdx as Markdown
This is clearly a stopgap solution but it'll make our life easier
while hacking on zed.dev.
2022-06-20 15:53:45 +02:00
Antonio Scandurra
041e230d24 Merge pull request #1208 from zed-industries/enhance-autoclose
Enhance auto-closing bracket behavior
2022-06-20 12:17:10 +02:00
Antonio Scandurra
d425d9fa64 Allow wrapping selected text with ' in Rust 2022-06-20 11:56:46 +02:00
Antonio Scandurra
6040429f93 Auto-close ' for TypeScript and don't do so for Rust 2022-06-20 11:55:40 +02:00
Antonio Scandurra
d5efae609e Respect close in language configuration when autoclosing bracket 2022-06-20 11:50:44 +02:00
Antonio Scandurra
d6c630f8eb Add missing auto-close brackets from various languages 2022-06-20 11:38:12 +02:00
Antonio Scandurra
9cf1774ca8 Merge pull request #1207 from zed-industries/remove-folder-from-project
Replace "Remove Folder from Project" label with "Remove from Project`
2022-06-20 10:58:20 +02:00
Antonio Scandurra
137a3996a1 Replace "Remove Folder from Project" label with "Remove from Project` 2022-06-20 10:53:26 +02:00
Max Brunsfeld
4bb5a2f19e Merge pull request #1206 from zed-industries/fix-offline-project-leak
Fix project leak in contacts panel
2022-06-17 15:55:43 -07:00
Max Brunsfeld
71534d4412 Avoid holding a strong project handle in an on_click callback 2022-06-17 15:41:48 -07:00
Max Brunsfeld
6359535c52 v0.39.0 2022-06-17 14:22:49 -07:00
Antonio Scandurra
9319cbdd0b Merge pull request #1205 from zed-industries/bypass-app-menu
Override `performKeyEquivalent` to handle key events
2022-06-17 17:31:51 +02:00
Antonio Scandurra
a35d7c5e15 Use BOOL instead of Rust booleans in handle_key_equivalent 2022-06-17 17:19:18 +02:00
Antonio Scandurra
8f6d081de8 Override performKeyEquivalent to handle key events
This lets us bypass the application menu and invoke the event handler
in Zed first. If that doesn't handle the event, the application menu
item corresponding to the shortcut will be actioned. Prior to this
commit the opposite would happen, which would dramatically limit the
throughput at which we could handle events.
2022-06-17 17:12:56 +02:00
Antonio Scandurra
607903eed5 Return true in the Window::on_event callback if event was handled 2022-06-17 17:09:16 +02:00
Antonio Scandurra
ae2273b40a Merge pull request #1204 from zed-industries/accurate-is-dirty
Determine `Buffer::is_dirty` based on the rope's fingerprint
2022-06-17 16:08:07 +02:00
Antonio Scandurra
4f215a77cd Don't compute fingerprint for every text summary 2022-06-17 15:15:27 +02:00
Antonio Scandurra
5654684d30 Fix editor tests after changing the semantics of is_dirty 2022-06-17 12:57:40 +02:00
Antonio Scandurra
052222c91c Bump protocol version 2022-06-17 12:39:59 +02:00
Antonio Scandurra
6f7a893ec9 Determine Buffer::is_dirty based on the rope's fingerprint 2022-06-17 12:38:25 +02:00
Antonio Scandurra
c31a233aad Introduce a new fingerprint field to TextSummary
This is calculated in `Rope` and uses the `bromberg_sl2` homomorphic
hash function to determine the fingerprint of a single chunk and
compose each chunk fingerprint into a single fingerprint for the entire
rope that is equivalent to hashing all the rope's bytes at once.
2022-06-17 12:12:37 +02:00
Max Brunsfeld
7d70011ef1 Merge pull request #1203 from zed-industries/themes-in-app-menu
Themes in app menu
2022-06-16 17:59:10 -07:00
Max Brunsfeld
21ecbce9b8 Add a Zed > Preferences submenu with prefs, bindings, theme 2022-06-16 17:50:44 -07:00
Max Brunsfeld
2c61bc2b1f Always use capital letters when rendering a keystroke 2022-06-16 17:48:10 -07:00
Max Brunsfeld
a3b17ffd15 Allow creating application menus with submenus 2022-06-16 17:47:39 -07:00
Max Brunsfeld
619c874984 Merge pull request #1202 from zed-industries/avoid-bad-markdown-autoindent
Disable auto-indent entirely for markdown
2022-06-16 15:00:07 -07:00
Max Brunsfeld
216a275ef2 Disable auto-indent entirely for markdown 2022-06-16 14:20:09 -07:00
Max Brunsfeld
bb63f57073 Merge pull request #1201 from zed-industries/focus-workspace-center-on-escape
Return focus to the workspace center on escape
2022-06-16 11:45:47 -07:00
Max Brunsfeld
dd7b874039 Return focus to the workspace center on escape 2022-06-16 11:30:02 -07:00
Antonio Scandurra
cef85f5d84 Merge pull request #1198 from zed-industries/keyboard-toggle-search-options
Toggle search options via the keyboard
2022-06-16 14:49:37 +02:00
Antonio Scandurra
04c9f849da Merge pull request #1197 from zed-industries/fix-typescript-completions
Use word boundaries instead of syntax to infer completion edit ranges
2022-06-16 14:49:27 +02:00
Antonio Scandurra
9defbf7c76 Bind CloseInactiveItems to alt-cmd-t 2022-06-16 14:42:55 +02:00
Antonio Scandurra
88d8696414 Display tooltip for select prev/next match buttons 2022-06-16 14:37:33 +02:00
Antonio Scandurra
649185da9c Allow toggling search options via the command palette 2022-06-16 14:28:37 +02:00
Antonio Scandurra
29e57c8e3c Toggle project search options via the keyboard 2022-06-16 14:18:45 +02:00
Antonio Scandurra
d0d6c27ae9 Don't select next match when toggling buffer search option 2022-06-16 14:06:47 +02:00
Antonio Scandurra
a835dcefa2 Toggle buffer search options via the keyboard 2022-06-16 13:44:00 +02:00
Antonio Scandurra
dc75b70724 Use word boundaries instead of syntax to infer completion edit ranges 2022-06-16 11:27:22 +02:00
Antonio Scandurra
35889add40 Add failing test for wrong typescript completion 2022-06-16 11:26:35 +02:00
Antonio Scandurra
fcd99c865e Merge pull request #1196 from zed-industries/context-menu-max-width
Cap context menu's width to cover at most 70% of the window
2022-06-16 10:51:04 +02:00
Antonio Scandurra
edd758eb67 Cap context menu's width to cover at most 70% of the window 2022-06-16 10:40:12 +02:00
Antonio Scandurra
48776be9c6 Merge pull request #1195 from zed-industries/lsp-errors
Open a buffer for every language server error when clicking on status
2022-06-16 10:09:47 +02:00
Antonio Scandurra
e09a6890f3 Remove unnecessary dependencies from lsp_status crate 2022-06-16 10:02:23 +02:00
Antonio Scandurra
4e4210ac39 Open a buffer for every language server error when clicking on status 2022-06-16 10:00:29 +02:00
Antonio Scandurra
7239aac532 Merge pull request #1193 from zed-industries/tooltips
Add some tooltips to aid discoverability
2022-06-15 17:19:50 +02:00
Antonio Scandurra
d02bc2f9f8 Add tooltip for project diagnostics 2022-06-15 17:12:47 +02:00
Antonio Scandurra
516bd13474 Add tooltip to follow collaborators 2022-06-15 17:08:39 +02:00
Antonio Scandurra
8a146e49ca Use a different fit mode for tooltips 2022-06-15 16:45:04 +02:00
Antonio Scandurra
f2a48c6b02 Add tooltips for sidebar buttons 2022-06-15 13:50:04 +02:00
Antonio Scandurra
0c8d33bd2d Merge pull request #1192 from zed-industries/fix-autoscroll-on-cursor-click
Autoscroll to newest selection when adding it via the cursor
2022-06-15 13:26:15 +02:00
Antonio Scandurra
4750727586 Autoscroll to newest selection when adding it via the cursor 2022-06-15 13:21:01 +02:00
Antonio Scandurra
16ef5f43bb Merge pull request #1191 from zed-industries/show-split-actions
Replace `pane::Split` action with `Split{Left,Up,Right,Down}`
2022-06-15 13:12:49 +02:00
Antonio Scandurra
da1eb91935 Replace pane::Split action with Split{Left,Up,Right,Down}
This allows us to show them in the command palette.
2022-06-15 13:06:59 +02:00
Antonio Scandurra
fa942e6b3d Merge pull request #1190 from zed-industries/fix-surround-with-pairs
Fix surrounding text with bracket pairs with multiple selections
2022-06-15 11:56:26 +02:00
Antonio Scandurra
7a81983c62 Fix surrounding text with bracket pairs with multiple selections
This was probably a regression that was introduced with the new batched
`Buffer::edit` API and was caused by providing selection ranges in a
non-ordered fashion (we were passing all the starts first and then all the
ends).

With this commit we are adding a unit test to verify the behavior of
`Editor::surround_with_bracket_pair` and changing the order in which
we pass edit ranges to respect the selection order.
2022-06-15 11:48:21 +02:00
Antonio Scandurra
d95e1e6795 Merge pull request #1189 from zed-industries/improve-metrics
Exclude staff from metrics and start tracking active projects
2022-06-15 11:30:12 +02:00
Antonio Scandurra
197a4342d0 Fix tests 2022-06-15 11:16:26 +02:00
Antonio Scandurra
a85f9e74b1 Harvest the latest metrics when /metrics is requested
Now that we track active projects, if nothing happens to the store
during the activity timeout we would still serve some old metrics
that may not account for the staleness of a project.

This commit changes it so that we grab a mutable reference to the store
before serving the metrics, which has the side effect of updating
all the metrics.
2022-06-15 10:54:51 +02:00
Antonio Scandurra
e373e05d27 🎨 2022-06-15 10:42:37 +02:00
Antonio Scandurra
3a1d0dd692 Track active projects in metrics
An active project is defined as a project where there has been at
least a buffer edit, a join request/response, or a follow update
in the last minute.
2022-06-15 10:33:20 +02:00
Antonio Scandurra
6d93a41f40 Exclude admins from collected metrics 2022-06-14 16:26:00 +02:00
Antonio Scandurra
226fa6e3be Merge pull request #1184 from zed-industries/invisible-setting-files
Don't show invisible worktrees in project and contacts panel
2022-06-14 15:21:58 +02:00
Antonio Scandurra
f89977ba41 Bump protocol version 2022-06-14 15:21:37 +02:00
Antonio Scandurra
68093342e7 Broadcast only visible worktree root names 2022-06-14 15:15:23 +02:00
Antonio Scandurra
cfbd8b94d1 Prevent setting files from showing up in project and contacts panels 2022-06-14 14:47:16 +02:00
Antonio Scandurra
7e23bc0c98 Merge pull request #1183 from zed-industries/project-panel-refinements
Polish project panel UX
2022-06-14 14:04:25 +02:00
Antonio Scandurra
5dd28b7e57 🎨 2022-06-14 14:03:25 +02:00
Antonio Scandurra
a5a4246e6c Attempt to open new entry only if it is a file 2022-06-14 14:01:49 +02:00
Antonio Scandurra
572e295854 Open files in project panel using enter instead of right 2022-06-14 13:56:56 +02:00
Antonio Scandurra
146e2b5089 Open files when creating them in project panel 2022-06-14 13:49:47 +02:00
Antonio Scandurra
53387e22f2 Merge pull request #1175 from zed-industries/users-api
Allow specifying `query`, `limit` and `page` when hitting `/api/users`
2022-06-14 11:19:37 +02:00
Antonio Scandurra
76da93d260 Merge branch 'main' into users-api 2022-06-14 11:14:16 +02:00
Antonio Scandurra
bf0fda3141 Merge pull request #1174 from zed-industries/bulk-user-creation
Expose a new `POST /api/bulk_users` API to create many users at once
2022-06-14 09:24:19 +02:00
Antonio Scandurra
49d7b4bc12 Allow specifying query, limit and page when hitting /api/users
This is needed to introduce pagination and search in our admin panel.
2022-06-13 17:30:01 +02:00
Antonio Scandurra
fe1a861bf3 Expose a new POST /api/bulk_users API to create many users at once
This API will accept a vector of JSON entries containing the GitHub login,
the email address and the invite count. If that user already exist, the
invite count will be updated to the new one.
2022-06-13 15:18:18 +02:00
Antonio Scandurra
b1e8e81513 Merge pull request #1172 from zed-industries/more-logs
Add more logging to `collab` to better understand user behavior
2022-06-13 09:22:37 +02:00
Antonio Scandurra
502625c570 Exclude ignored files from the logged extension count 2022-06-13 09:16:16 +02:00
Antonio Scandurra
dcdc6311df Don't retain message payloads in span, just log the payload instead 2022-06-13 09:06:58 +02:00
Antonio Scandurra
3b8388dcdd Log extension counts when worktree is updated 2022-06-13 08:57:21 +02:00
Max Brunsfeld
1bc2bc0e95 Merge pull request #1171 from zed-industries/prompt-save-before-quit
Prompt to save changes before quitting the app
2022-06-10 17:32:57 -07:00
Max Brunsfeld
b9eb875bf4 Prompt to save changes before quitting the app 2022-06-10 17:26:33 -07:00
Max Brunsfeld
d5f360aa0a Merge pull request #1170 from zed-industries/open-metrics
Report collab server metrics to DataDog via OpenMetrics
2022-06-10 17:02:26 -07:00
Max Brunsfeld
e2935100db Move prometheus annotations from deployment to pod spec 2022-06-10 14:32:36 -07:00
Max Brunsfeld
2311534c3c Add DataDog OpenMetrics annotations to collab k8s deployment
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-10 13:35:52 -07:00
Max Brunsfeld
2e6fa889ea Add OpenMetrics endpoint exposing the basic RPC store metrics as guages
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-10 13:32:56 -07:00
Max Brunsfeld
b2798787b4 Merge pull request #1161 from zed-industries/style-jump-to-diagnostic-arrows
Style jump to buffer arrows in diagnostics
2022-06-10 12:35:44 -07:00
Max Brunsfeld
4032e517f9 v0.38.0 2022-06-10 10:19:21 -07:00
Antonio Scandurra
63fdf1398a WIP: Start adding more logs 2022-06-10 18:17:02 +02:00
Antonio Scandurra
799b32c8a9 Merge pull request #1167 from zed-industries/block-scroll-width
Introduce a new `BlockStyle` field for blocks
2022-06-10 14:03:46 +02:00
Antonio Scandurra
f91fb48a4c Simplify EditorElement::layout_blocks 2022-06-10 13:57:43 +02:00
Antonio Scandurra
666ea61dbc Introduce a new BlockStyle field for blocks
This new field allows blocks to specify how they want to be laid out:

- If `Fixed` they can take up all the width they want and they will impact
the scroll width of the editor. This is useful for diagnostic messages and
allows scrolling the editor further to the right to visualize the entire message.
- If `Flex` they can extend all the way to the scroll width without impacting it
any further. This is useful for the rename editor that we insert as a block
decoration when hitting `F2`.
- If `Sticky`, they will be as wide as the editor element and won't participate
in the horizontal scrolling of the editor. This is useful for headers in general,
where we want e.g. the filename and the jump button to always be visible
independently of how much the user has scrolled to the right.
2022-06-10 13:47:40 +02:00
Keith Simmons
8e440bf7ca Merge pull request #1166 from zed-industries/hover-fixes
Always delay hover display
2022-06-09 18:18:01 -07:00
Keith Simmons
02f0fee6ae Always delay hover display 2022-06-09 18:08:23 -07:00
Keith Simmons
699f14ff73 Merge pull request #1144 from zed-industries/hover-fixes
Hover fixes. Addresses delay issues with current hover implementation, shrinks the hover popover, and tweaks the display of markdown data
2022-06-09 17:18:26 -07:00
Keith Simmons
e21d1b1acb Merge fix 2022-06-09 17:07:32 -07:00
Keith Simmons
3cec157335 fix compile error in EditorLspTestContext 2022-06-09 17:03:45 -07:00
Keith Simmons
8378590d57 Test fixes 2022-06-09 17:03:45 -07:00
Keith Simmons
93158bfcff Fix delayed lsp request 2022-06-09 17:03:45 -07:00
Keith Simmons
722023e347 test and build fixes 2022-06-09 17:03:45 -07:00
Keith Simmons
dddfc7beae Add hover test and tweak dismiss logic 2022-06-09 17:03:45 -07:00
Keith Simmons
1da1853a76 Hide hover when font changes, and handle case where delay was preventing hover with large symbol range 2022-06-09 17:03:44 -07:00
Keith Simmons
b51bd87c10 Rework hover delay, respect editor font size, and enable hover in multibuffers 2022-06-09 17:03:44 -07:00
Keith Simmons
ee33fb03f2 wip 2022-06-09 17:03:44 -07:00
Max Brunsfeld
87ba68e3ea Merge pull request #1155 from zed-industries/golang
Add Go support
2022-06-09 14:18:37 -07:00
Max Brunsfeld
924e9648e9 Tweak golang outline query 2022-06-09 13:31:30 -07:00
Max Brunsfeld
9495717421 Add project symbol labels for Go 2022-06-09 13:16:08 -07:00
Max Brunsfeld
861f4c7230 Add syntax highlighting for Go completions 2022-06-09 13:08:18 -07:00
Max Brunsfeld
4ce4c0ef03 Ignore completions from gopls that we can't yet handle
We only support additionalEdits if they are provided when resolving the
completion, not if they are provided immediately.
2022-06-09 13:08:08 -07:00
Max Brunsfeld
7bb7187619 Add tests and fix bugs for editor indent/outdent commands w/ hard tabs 2022-06-09 10:26:09 -07:00
Nate Butler
80e04702de Style jump to diagnostic arrows 2022-06-09 12:31:13 -04:00
Max Brunsfeld
77b9ab0885 Add buffer test for autoindent with hard tabs 2022-06-09 09:05:07 -07:00
Antonio Scandurra
d0898676f8 Merge pull request #1157 from zed-industries/align-editor-menu-to-fit
Snap overlay's bottom/right edge to same window's edge on overflow
2022-06-09 13:59:13 +02:00
Antonio Scandurra
ea8b5016f7 Snap overlay's bottom/right edge to same window's edge on overflow 2022-06-09 13:48:02 +02:00
Antonio Scandurra
e0ecf3bc4c Merge pull request #1156 from zed-industries/disable-language-server
Introduce a new language-overrideable `enable_language_server` setting
2022-06-09 11:35:54 +02:00
Antonio Scandurra
213b31607c Remove language server statuses synchronously when stopping a server 2022-06-09 10:59:02 +02:00
Antonio Scandurra
69170fc33a Add unit test to ensure changing enable_language_server works 2022-06-09 10:48:06 +02:00
Antonio Scandurra
36a1a7a819 Start/stop language servers when enable_language_server changes 2022-06-09 10:08:11 +02:00
Antonio Scandurra
55cc8631cc Introduce a new language-overrideable enable_language_server setting 2022-06-09 10:07:31 +02:00
Antonio Scandurra
9d7476afc6 Extract a Project::stop_language_server method when restarting server
This will be useful later to stop a language server when detecting
configuration changes.
2022-06-09 10:05:35 +02:00
Antonio Scandurra
0408a8259e Add ModelContext::observe_global 2022-06-09 10:05:00 +02:00
Antonio Scandurra
4d615655aa Merge pull request #1142 from zed-industries/multibuffer-jump-to
Show "Jump to Buffer" icon on every excerpt header
2022-06-09 08:58:42 +02:00
Max Brunsfeld
f62fd3cddd Add support for hard tabs
* Add a `hard_tabs` setting that causes indentation to be performed
  using a tab instead of multiple spaces.
* Change Buffer's indentation-related APIs to return an `IndentSize`
  struct with a length and a kind, instead of just a single u32.
* Use hard tabs by default in Go.
2022-06-08 18:30:10 -07:00
Max Brunsfeld
129fc515ef Add parser and queries for go
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-08 10:44:13 -07:00
Max Brunsfeld
36ce3eb5ef Handle messages associated with LSP WorkDoneProgress::Begin messages
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-08 10:26:41 -07:00
Max Brunsfeld
a41f164ffe Launch gopls with the right arguments
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-08 10:25:58 -07:00
Antonio Scandurra
712d47d94f Render a "Jump to Buffer" icon on all excerpt headers 2022-06-08 15:31:29 +02:00
Antonio Scandurra
c2eaf6128e Move ProjectDiagnosticsEditor::jump to Editor::jump 2022-06-08 15:08:11 +02:00
Antonio Scandurra
5fdafbe8c9 Expose a unique key: usize in ExcerptBoundary 2022-06-08 15:02:52 +02:00
Antonio Scandurra
eda569d6b2 Snapshot file instead of path when creating a buffer snapshot 2022-06-08 14:29:14 +02:00
Antonio Scandurra
15b13fe511 Introduce an optional primary field to ExcerptRange 2022-06-08 12:23:12 +02:00
Antonio Scandurra
ffb75b0f02 Extract an ExcerptRange containing a context field in multi_buffer
This lays the groundwork for adding an optional `primary` field that can
be supplied to provide the "jump to" feature.
2022-06-08 12:13:04 +02:00
Antonio Scandurra
d56cc1a5c1 Merge pull request #1141 from zed-industries/fix-status-bar-click
Use visible bounds to determine hit bounds for cursor/mouse regions
2022-06-08 10:23:12 +02:00
Antonio Scandurra
a26af194e7 Use visible bounds to determine hit bounds for cursor/mouse regions 2022-06-08 10:17:22 +02:00
Antonio Scandurra
5c84f4b92c Merge pull request #1140 from zed-industries/fix-range-formatting
Provide `tab_size` when formatting document using LSP range formatting
2022-06-08 10:00:44 +02:00
Antonio Scandurra
d8b885e3ec Provide tab_size when formatting document using LSP range formatting 2022-06-08 09:56:11 +02:00
Antonio Scandurra
71046bf911 Merge pull request #1138 from zed-industries/reduce-log-level
Reduce log level on `collab`
2022-06-08 09:15:35 +02:00
Antonio Scandurra
494a1b332f Reduce log level on collab
This is generating way too much data and doesn't seem very cost-effective
to investigate the issues we've had with the stale contacts panel.
2022-06-08 09:06:13 +02:00
Max Brunsfeld
8f4387a252 Start work on installing gopls 2022-06-07 18:38:37 -07:00
Max Brunsfeld
209ff619ef Simplify interface of latest_github_release helper function 2022-06-07 16:26:01 -07:00
Max Brunsfeld
6efd4e0da6 Merge pull request #1134 from zed-industries/feedback-button
Add status bar link and help menu item to open an issue on feedback repo
2022-06-07 16:06:03 -07:00
Max Brunsfeld
8311458931 Add status bar link and Help menu item to open an issue on feedback repo 2022-06-07 15:48:12 -07:00
Keith Simmons
9d5111e86a Merge pull request #1078 from zed-industries/lsp-hover
LSP Hover Information
2022-06-07 14:45:43 -07:00
Max Brunsfeld
26cd20e38b Merge pull request #1132 from zed-industries/refresh-on-save
Don't refresh the project diagnostics until the user saves
2022-06-07 14:28:07 -07:00
Keith Simmons
1b66e1e185 Add integration test and fix hovering over the wire 2022-06-07 14:22:02 -07:00
Max Brunsfeld
b53f887ecc Merge pull request #1129 from zed-industries/update-notification
Show a notification after Zed auto-updates
2022-06-07 13:16:04 -07:00
Keith Simmons
a6c0ee472c Add vim bindings for hover
Allow scrolling in hover popover
2022-06-07 13:07:53 -07:00
Keith Simmons
67d9abc00f Move highlighting to editor code and implement proto message types for hover response 2022-06-07 11:54:52 -07:00
Keith Simmons
c7cc07aafb working markdown rendering 2022-06-07 11:54:51 -07:00
Isaac Clayton
efd798f5f6 Quick documentation pass 2022-06-07 11:54:33 -07:00
Keith Simmons
b014352740 Syntax highlighting working. Getting started on markdown support 2022-06-07 11:54:33 -07:00
Isaac Clayton
863a3b1886 Clean up impl a bit 2022-06-07 11:54:33 -07:00
Isaac Clayton
d529a1deb4 Add basic debounce, fix flickering 2022-06-07 11:54:31 -07:00
Keith Simmons
560dff7329 Pull hover popover out of context menu 2022-06-07 11:54:00 -07:00
Isaac Clayton
470c70d394 Get minimal POC working 2022-06-07 11:52:52 -07:00
Isaac Clayton
24ad60a651 Add hover action and style context menu 2022-06-07 11:50:49 -07:00
Keith Simmons
0ed8a42bb4 WIP 2022-06-07 11:49:28 -07:00
Keith Simmons
02249dc2e8 Rework darkest color in base16, shadows, and add hoverPopover styleTree 2022-06-07 11:47:38 -07:00
Keith Simmons
0c4f798a2d WIP jump to definition with mouse 2022-06-07 11:47:23 -07:00
Antonio Scandurra
b04e62d895 Fix tracking of in-progress disk-based diagnostics on indicator
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-07 19:35:53 +02:00
Antonio Scandurra
bbfa6580a4 Avoid refreshing diagnostics for language servers that didn't update
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-07 19:05:06 +02:00
Antonio Scandurra
96cdf3b9dd Merge pull request #1130 from zed-industries/prepopulate-project-search
Pre-populate project search query when deploying it from an editor
2022-06-07 10:17:11 +02:00
Antonio Scandurra
6b4e7da7d6 Prepopulate project search query when deploying it from an editor 2022-06-07 10:02:04 +02:00
Max Brunsfeld
c86b12e1b6 Show a notification after Zed auto-updates 2022-06-06 17:42:31 -07:00
Max Brunsfeld
6a086f62d5 Merge pull request #1121 from zed-industries/update-invite-code
Update connected users' invite info when they are granted invite codes
2022-06-06 11:53:16 -07:00
Max Brunsfeld
7efd68966c Merge pull request #1123 from zed-industries/add-context-menu-borders
Add border to context menu
2022-06-06 11:53:11 -07:00
Nate Butler
c920a4229d Add border to context menu 2022-06-06 14:47:28 -04:00
Max Brunsfeld
ce080e9520 Update connected users' invite info when they are granted invite codes 2022-06-06 11:14:01 -07:00
Max Brunsfeld
6899eacf3d v0.37.0 2022-06-06 10:37:27 -07:00
Max Brunsfeld
075dd83a43 Merge pull request #1115 from zed-industries/offset-out-of-range
Fix `offset out of range` panic during `FoldMap::sync`
2022-06-06 10:32:18 -07:00
Max Brunsfeld
436c989e4b Merge pull request #1109 from zed-industries/fix-vim-clearing-selections
Avoid collapsing selections on editor creation when vim_mode is disabled
2022-06-06 10:32:12 -07:00
Antonio Scandurra
1ecc51f035 Fix warnings 2022-06-06 16:23:49 +02:00
Antonio Scandurra
70afc06666 Handle out-of-order edits coming from LSP 2022-06-06 16:15:11 +02:00
Antonio Scandurra
8826ad5ddd Make Buffer::edit and MultiBuffer::edit resilient to inverted ranges
Previously, we would accept edits containing out-of-order ranges. When
generating such ranges in our randomized tests, many invariants started
breaking causing e.g. undo/redo to misbehave and operation application
to panic.

In theory, we should never pass inverted ranges, but this commit changes
the above functions to swap the start and the end when that occurs to avoid
breaking the entire system and panicking.
2022-06-06 15:22:36 +02:00
Antonio Scandurra
939020a652 Merge pull request #1114 from zed-industries/fix-menu-bindings
Add keystroke for menu item only when action is equal to binding
2022-06-06 09:35:38 +02:00
Antonio Scandurra
c22aedfe69 Fix tests 2022-06-06 09:29:42 +02:00
Antonio Scandurra
22dd68fbfb Add keystroke for menu item only when action is equal to binding
This fixes a bug where we would show `cmd-e` instead of `cmd-f` for
`Edit -> Find` because both bindings would have the `buffer_search::Deploy`
action and we were mistakenly selecting the former.
2022-06-06 09:26:33 +02:00
Antonio Scandurra
3a69943df3 Require that PartialEq is implemented for Action 2022-06-06 09:18:44 +02:00
Antonio Scandurra
492cc716d3 Don't manipulate selections when syncing options if vim-mode is disabled
Previously, we were always mutating selections when `sync_editor_options`
was called. This seems to happen every time vim is enabled/disabled, but also
when vim is disabled and editors are simply focused/blurred.

This commit changes it so that we only manipulate selections when vim-mode is active.
2022-06-06 08:14:49 +02:00
Max Brunsfeld
905fbacbc7 vim: Avoid collapsing selections on editor creation when vim_mode is disabled 2022-06-04 15:01:43 -07:00
Antonio Scandurra
eae7c2267c Merge pull request #1107 from zed-industries/event-handler-capture-all
Capture mouse events when rendering disconnected overlay
2022-06-04 10:51:29 +02:00
Antonio Scandurra
74aa9c1320 Capture mouse events when rendering disconnected overlay
We do so by replacing `EventHandler::capture` with a new `::capture_all` method.
After switching to mouse regions as part of zed-industries/zed#1081, overriding
`dispatch_event` on `EventHandler` wasn't enough anymore because mouse interactions
take place on a privileged code path that runs *before* dispatching any event.

With this change, `EventHandler` will now push a mouse region that intercepts all
mouse interactions, as well as pushing a cursor region that resets the cursor style
to `Arrow`.

One interesting change as part of this is that we've removed the ability to see which
event we are capturing: we were not using this capability anyway and `capture_all` provides
a simpler interface, so I went with that. In the future, we can opt into capturing specific
events or mouse interactions if there's a code path that needs that.
2022-06-04 10:41:29 +02:00
Max Brunsfeld
ff3e3d0799 Merge pull request #1084 from zed-industries/private-projects
Offline projects
2022-06-03 17:14:46 -07:00
Max Brunsfeld
41b7fd4a27 Rename a public/private to online/offline in a few more places 2022-06-03 17:08:44 -07:00
Max Brunsfeld
ed14fd6e0d Add setting to make projects online/offline by default 2022-06-03 17:01:15 -07:00
Max Brunsfeld
24aafde1e8 Avoid persisting project's state before it has been initialized 2022-06-03 16:40:16 -07:00
Max Brunsfeld
e18bc24989 Rename project's 'public'/'private' flag to 'online'/'offline' 2022-06-03 14:39:06 -07:00
Max Brunsfeld
b2aa831017 Store a FakeFs on TestClient 2022-06-03 13:49:47 -07:00
Max Brunsfeld
8bd4a0ab81 Don't store Project on TestClient in integration tests 2022-06-03 13:00:56 -07:00
Max Brunsfeld
afdd386057 Move persistence and restoration logic from workspace into project
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-03 11:52:14 -07:00
Max Brunsfeld
3ce739f759 Merge pull request #1098 from zed-industries/cpp
Introduce support for C++
2022-06-03 10:52:17 -07:00
Max Brunsfeld
6a3a3a1124 Add tooltip to the toggle public button in the contacts panel
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-03 10:36:29 -07:00
Antonio Scandurra
55fc2341d8 Consolidate C and C++ LSP adapters
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-03 18:05:43 +02:00
Antonio Scandurra
1db4970c5a Implement CppLspAdapter::name by delegating to CLspAdapter::name
This makes it more evident that both languages share the same language
server.

Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-03 17:49:31 +02:00
Antonio Scandurra
416496225e Syntax-highlight project-wide symbols for C++ 2022-06-03 11:47:56 +02:00
Antonio Scandurra
c6e6a9f1eb Show prettier completions for C++ 2022-06-03 11:33:03 +02:00
Antonio Scandurra
8ca0127658 Make LspAdapter::process_diagnostics optional 2022-06-03 10:56:26 +02:00
Antonio Scandurra
d4da5135f4 Introduce support for C++ 2022-06-03 10:52:34 +02:00
Max Brunsfeld
98b54763b9 Bump protocol version 2022-06-02 18:06:29 -07:00
Max Brunsfeld
36a4d31b5b Keep unregistered projects' ids until pending contact updates are done 2022-06-02 18:04:54 -07:00
Max Brunsfeld
db97dcd76f Don't update contacts when a project is first registered
Until the host has sent an UpdateProject message to populate the project's
metadata, there is no reason to update contacts.
2022-06-02 17:41:21 -07:00
Max Brunsfeld
f7e7a7c6a7 Use rocksdb to store project paths' public/private state 2022-06-02 17:38:33 -07:00
Max Brunsfeld
724affc442 Upgrade deps to avoid multiple versions of transitive deps
* env_logger
* prost-build
* bindgen
2022-06-02 17:38:33 -07:00
Max Brunsfeld
d45db1718e Style the contact panel while public/private operations are in-flight 2022-06-02 17:38:33 -07:00
Max Brunsfeld
d11beb3c02 Change project registration RPC APIs to smooth out UI updates
* Make `UnregisterProject` a request. This way the client-side project can wait
  to clear out its remote id until the request has completed, so that the
  contacts panel can avoid showing duplicate private/public projects in the
  brief time after unregistering a project, before the next UpdateCollaborators
  message is received.
* Remove the `RegisterWorktree` and `UnregisterWorktree` methods and replace
  them with a single `UpdateProject` method that idempotently updates the
  Project's list of worktrees.
2022-06-02 17:32:43 -07:00
Max Brunsfeld
4d4ec793e2 Remove stray println 2022-06-02 17:32:43 -07:00
Max Brunsfeld
b70396b8fb Disconnect FakeServer when dropping it
This prevents memory leak errors in tests, due to parked tasks waiting
for RPC responses.
2022-06-02 17:32:43 -07:00
Max Brunsfeld
3ea061a11e Allow making projects private 2022-06-02 17:32:42 -07:00
Max Brunsfeld
8f676e76b3 Fix mismatched client/context in integration test 2022-06-02 17:29:11 -07:00
Max Brunsfeld
8d46edd26c Avoid holding RefCell borrow while calling TestAppContext::spawn callback 2022-06-02 17:29:11 -07:00
Max Brunsfeld
7ef9de32b1 Show private projects in the contacts panel
Introduce a ProjectStore that lets you iterate through all open projects.
Allow projects to be made public by clicking the lock.
2022-06-02 17:29:11 -07:00
Max Brunsfeld
a60fef52c4 Start work on private projects 2022-06-02 17:29:11 -07:00
Antonio Scandurra
3ffbd56c65 Merge pull request #1093 from zed-industries/fix-panic-version
Report the correct app version when sending panics to server
2022-06-02 13:55:00 +02:00
Antonio Scandurra
7ecc67bcd5 Report the correct app version when sending panics to server
Previously, we were just relying on the `ZED_APP_VERSION` environment
variable without consulting `Platform::app_version`. That would always
report "dev" as the app version because `ZED_APP_VERSION` is only used
for testing.
2022-06-02 13:00:21 +02:00
Antonio Scandurra
a8cde09070 v0.36.1 2022-06-02 12:11:49 +02:00
Antonio Scandurra
7beb1946b2 Merge pull request #1091 from zed-industries/fix-project-diagnostics-panic
Don't reuse the same diagnostic group id across buffers
2022-06-02 12:11:09 +02:00
Antonio Scandurra
6baf8b033b Don't reuse the same diagnostic group id across buffers
This lets us use the group id as the key for an `ElementState`, which
fixes a panic that would occur in project diagnostics when opening it
while there were multiple diagnostic groups with the same id.
2022-06-02 12:05:28 +02:00
Antonio Scandurra
c34b30e739 Merge pull request #1090 from zed-industries/context-menu-polish
Context menu polish
2022-06-02 10:06:44 +02:00
Antonio Scandurra
12267308e4 Don't dismiss context menu when right-clicking project panel again 2022-06-02 10:00:52 +02:00
Antonio Scandurra
701e2090cd Align context menu to fit within the window bounds 2022-06-02 09:47:06 +02:00
Antonio Scandurra
f1964cf2a0 Merge pull request #1089 from zed-industries/jump-to-diagnostic
Jump to diagnostic
2022-06-02 09:35:57 +02:00
Antonio Scandurra
6979e67bed Use anchors to jump to diagnostic whenever possible 2022-06-02 09:30:07 +02:00
Antonio Scandurra
cc028cca78 Simplify usage of tooltip
Now you simply specify a text, an action and a style and GPUI will
take of rendering it properly. This is simpler compared to always
providing a custom element and should make tooltip more consistent
across the UI.
2022-06-02 09:12:50 +02:00
Antonio Scandurra
ba6be46e82 v0.36.0 2022-06-02 08:38:36 +02:00
Antonio Scandurra
9ca9f63046 Match figma styling for tooltips 2022-06-02 08:36:42 +02:00
Max Brunsfeld
b9dc476e74 Avoid sending unnecessary messages for local projects that aren't shared 2022-06-01 14:49:12 -07:00
Antonio Scandurra
0e1307fb23 📝 2022-06-01 10:18:10 +02:00
Antonio Scandurra
b63d965b46 Space out tooltip a little bit to ensure it doesn't overlap cursor 2022-06-01 10:08:25 +02:00
Antonio Scandurra
238827642a Align tooltip based on the available window space 2022-06-01 10:03:46 +02:00
Antonio Scandurra
b3242417b3 Show tooltip when hovering over jump to diagnostic icon 2022-06-01 09:55:45 +02:00
Antonio Scandurra
982de971fa Introduce a new Tooltip element and a with_tooltip helper 2022-06-01 09:55:25 +02:00
Antonio Scandurra
94fc28b29d WIP: start on tooltips 2022-05-31 19:00:44 +02:00
Antonio Scandurra
d180f7a2c3 Jump to primary diagnostic when clicking on header's jump icon 2022-05-31 16:25:14 +02:00
Antonio Scandurra
4f9c207425 Show a clickable jump icon for each diagnostic group header 2022-05-31 15:57:22 +02:00
Antonio Scandurra
aefdde66a6 Pass a &mut BlockContext when rendering blocks
This wraps and derefs to `RenderContext<Editor>`, so that we can
easily use `MouseEventHandler`s in blocks.
2022-05-31 15:50:34 +02:00
Antonio Scandurra
9fa03b2f28 Merge pull request #1086 from zed-industries/server-memory-improvements
Improve server memory usage
2022-05-31 13:27:44 +02:00
Antonio Scandurra
1ce8682b94 Clear language server and worktree statuses when unsharing on server 2022-05-31 11:22:41 +02:00
Antonio Scandurra
339069b1d3 Cap MessageStream buffer size to 1MB
We temporarily let it grow when the message size exceed the limit,
but restore the buffer's capacity shortly after. This ensures that,
for each connection in its entire lifetime, we only ever use 1MB.
2022-05-31 11:16:32 +02:00
Antonio Scandurra
da46d78ea5 Merge pull request #1081 from zed-industries/project-panel-with-new-mouse-events
Introduce context menu to project panel
2022-05-31 10:40:42 +02:00
Antonio Scandurra
34bf248614 Avoid notifying views that have been removed 2022-05-31 10:36:10 +02:00
Antonio Scandurra
e067212ad4 Always re-render visible elements in List 2022-05-31 09:52:44 +02:00
Antonio Scandurra
0fd47da880 Prevent mouse down events from piercing through overlays 2022-05-31 09:34:37 +02:00
Antonio Scandurra
e4641da598 Don't show "add/remove folder to/from project" for remote projects 2022-05-31 08:17:52 +02:00
Antonio Scandurra
1eb03f2f4e Bump protocol version 2022-05-31 08:13:05 +02:00
Antonio Scandurra
354488ebdf Don't eagerly populate copied subdirectory
This can race anyway with snapshot updates, so we just eagerly refresh
the root entry and wait for updates to come in to populate it.
2022-05-31 08:11:07 +02:00
Max Brunsfeld
7f292dadac Merge pull request #1082 from zed-industries/no-honeycomb
Remove opentelemetry tracing subscriber
2022-05-30 10:50:38 -07:00
Max Brunsfeld
365cda0fab Remove opentelemetry tracing subscriber
We'll see if this stops the server from leaking memory. We still
have spans in our logs.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-30 09:58:25 -07:00
Antonio Scandurra
604b737d7c 💄 2022-05-30 18:38:43 +02:00
Antonio Scandurra
06ab2ace72 Don't steal focus from context menu when dispatching an action 2022-05-30 18:36:36 +02:00
Antonio Scandurra
f832c0074f Fix memory leak in ListState 2022-05-30 18:29:51 +02:00
Antonio Scandurra
20e1044d49 Merge branch 'main' into project-panel-with-new-mouse-events 2022-05-30 18:29:46 +02:00
Antonio Scandurra
88fdd8606a Eagerly populate child entries when copying a directory via RPC 2022-05-30 18:01:46 +02:00
Antonio Scandurra
51adc6517e WIP: start on an integration test for copy_entry 2022-05-30 14:53:10 +02:00
Antonio Scandurra
3336bc6ab3 Implement copy paste for ProjectPanel 2022-05-30 14:52:34 +02:00
Antonio Scandurra
37a0c7f046 Implement cut/paste for ProjectPanel 2022-05-30 12:23:21 +02:00
Antonio Scandurra
6c145b2abc Show keystrokes as uppercase 2022-05-30 12:23:03 +02:00
Antonio Scandurra
63900612b0 Dismiss context menu when one of its action is dispatched 2022-05-30 10:05:21 +02:00
Antonio Scandurra
2b9015c096 Introduce {MutableAppContext,ViewContext}::observe_actions 2022-05-30 10:01:23 +02:00
Antonio Scandurra
e7ab61d125 Dismiss context menu when (right-)mousing down outside of it 2022-05-28 08:51:46 +02:00
Antonio Scandurra
fb26f8195b Sort mouse regions by their stacking context's depth 2022-05-28 08:45:10 +02:00
Max Brunsfeld
733cf4c271 Merge pull request #1075 from zed-industries/integration-test-cleanup
Integration test cleanup
2022-05-27 17:45:56 -07:00
Max Brunsfeld
bc6f8da029 Move integration tests into their own file 2022-05-27 17:20:05 -07:00
Max Brunsfeld
8393ae88b7 Clean up integration tests
* Use 'build_local_project' helper to reduce boilerplate
* Peform the setup steps in a consistent order
2022-05-27 17:10:45 -07:00
Max Brunsfeld
35ada0d3a0 Merge pull request #1074 from zed-industries/misc-menu-items
Add a few more important menu items
2022-05-27 13:27:03 -07:00
Max Brunsfeld
1c932ae4ce Add help menu items to visit zed.dev and the zed twitter page 2022-05-27 13:18:00 -07:00
Max Brunsfeld
df4f3051bc Add app menu items for opening settings and keymap 2022-05-27 13:06:35 -07:00
Max Brunsfeld
e1a05d451f Add "Reset Zoom" action and application menu item 2022-05-27 13:06:12 -07:00
Nathan Sobo
44c8ee5709 Add mouse down out handlers
These will fire whenever the left/right mouse button is pressed down outside a specific region. I'll use these to cancel the context menu in the next commit.
2022-05-27 12:56:44 -06:00
Keith Simmons
4a5317b6e4 Remove unused context_menu file in rust crate 2022-05-27 11:32:15 -07:00
Keith Simmons
48abbb7e63 Merge pull request #1019 from zed-industries/vim-visual-line-mode
Vim visual line mode
2022-05-27 11:22:56 -07:00
Max Brunsfeld
b2adff63e7 Merge pull request #1073 from zed-industries/window-menu
Add a Window application menu
2022-05-27 11:22:13 -07:00
Nathan Sobo
9909fc529b Allow context menu to be cancelled after deploying it twice
Previously, two right clicks would cause an issue with cancelling the context menu via escape.
2022-05-27 12:00:11 -06:00
Nathan Sobo
c3baf2748f Block hovering behind overlays 2022-05-27 11:54:51 -06:00
Max Brunsfeld
23cd948b5f Adjust test to flush effects between splitting pane and following
Panes now emit an event when adding the first item, so we need to flush
effects between splitting and following in order to avoid accidentally
cancelling the follow.
2022-05-27 10:53:14 -07:00
Max Brunsfeld
a88b4eb3c5 Populate the window title whenever worktrees or active path change
* Refactor the way the project's active entry is assigned. Assign it
  together with the window title, as opposed to on every notification
  from a pane.
* Emit the ActiveItem event from panes consistently, even when adding
  the first item to an empty pane.
2022-05-27 10:51:14 -07:00
Max Brunsfeld
e6be151a64 Emit the WorktreeRemoved event when removing a worktree from a project 2022-05-27 10:49:10 -07:00
Max Brunsfeld
a1a4c70845 Emit an event when adding a worktree to a project 2022-05-27 10:48:47 -07:00
Max Brunsfeld
04bd57b2c7 Add an API for setting a window's title
This controls how the window appears in the Window menu.
2022-05-27 10:45:55 -07:00
Nathan Sobo
5413a97c7e Restrict multiple hovered regions to a single stacking context
We won't hover regions from stacking contexts that are below the one being hovered.
2022-05-27 11:09:07 -06:00
Antonio Scandurra
9099c40364 Merge branch 'mouse-events' into project-panel-context-menu 2022-05-27 12:07:00 +02:00
Antonio Scandurra
82d6e606fc Use a MouseEventHandler for activating tabs on mouse down
Previously, we were using an `EventHandler` which doesn't take into
account other mouse regions floating above the rendered element. This
was problematic because, when clicking the `x` icon on a tab that was
not active, we were first activating it and then closing it.
2022-05-27 11:43:58 +02:00
Antonio Scandurra
98de269b4a Don't focus editor when clicking on sidebar resize handle 2022-05-27 11:36:37 +02:00
Antonio Scandurra
be0e66ef21 Invoke mouse_down and right_mouse_down callbacks 2022-05-27 11:20:39 +02:00
Antonio Scandurra
7c7917494c Don't dispatch events down the tree if they were handled by mouse region 2022-05-27 11:20:32 +02:00
Antonio Scandurra
1d7fc12229 Add right-click support to MouseEventHandler 2022-05-27 10:47:54 +02:00
Antonio Scandurra
307eb1726c Compute dispatch path based on the view id that dispatched the action 2022-05-27 09:59:24 +02:00
Nathan Sobo
aedfd74d30 Use the hit bounds when painting mouse regions 2022-05-26 20:05:20 -06:00
Nathan Sobo
893f15ddab Switch MouseEventHandler to use MouseRegions
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 20:00:01 -06:00
Nathan Sobo
50edcb06dd Add drag callbacks to mouse regions
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 18:59:38 -06:00
Nathan Sobo
bd62a68234 Eliminate ElementStateContext trait
We now always have a RenderContext when rendering MouseEventHandlers or scrollable Flex columns/rows.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 18:37:28 -06:00
Nathan Sobo
b6b16fc9c3 In UniformList, guard against misbehavior of append_items
If for some reason the handle got dropped and we call it, we'll deal with it somewhat gracefully.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 18:30:28 -06:00
Nathan Sobo
8dd82fdce1 Take a RenderContext in ListState's build item callback
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 18:23:44 -06:00
Nathan Sobo
2ea085b178 Pass a RenderContext to UniformList
In some cases, we need to render during layout. Previously, we were rendering with a LayoutContext in some cases, but this commit adds the ability to retrieve a render context with a given handle and we use that feature in UniformList.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-26 18:03:34 -06:00
Keith Simmons
8e7c6871db Track selection changes in mutable selections collection 2022-05-26 17:02:05 -07:00
Max Brunsfeld
42cd2ae142 Avoid switching to visual mode when following in vim mode
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-05-26 17:02:05 -07:00
Max Brunsfeld
c53412efcb Bump protocol version 2022-05-26 17:02:05 -07:00
Keith Simmons
d11bc2a4b7 Fixup paste locations 2022-05-26 17:02:05 -07:00
Keith Simmons
e104cb94e7 fix bug in marked_range utils 2022-05-26 17:02:05 -07:00
Keith Simmons
98f9575653 WIP 2022-05-26 17:02:05 -07:00
Keith Simmons
e93c49f4f0 Unify visual line_mode and non line_mode operators 2022-05-26 17:02:05 -07:00
Keith Simmons
11569a869a in progress working on aborting operators on unhandled editor input 2022-05-26 17:02:05 -07:00
Keith Simmons
61f0daa5c5 Visual line mode handles soft wraps 2022-05-26 17:02:05 -07:00
Keith Simmons
33940b5dd9 Add visual line mode operator tests 2022-05-26 17:02:05 -07:00
Keith Simmons
082036161f Enable copy and paste in vim mode 2022-05-26 17:02:05 -07:00
Keith Simmons
d094d1d891 WIP copy on delete 2022-05-26 17:02:05 -07:00
Keith Simmons
f8f316cc64 Working change and delete in line mode 2022-05-26 17:02:05 -07:00
Keith Simmons
d7d17b2148 WIP line mode operations 2022-05-26 17:02:05 -07:00
Keith Simmons
8044586296 Merge pull request #1070 from zed-industries/fix-seed-script
Fix failing seed bin build and add bin builds to ci pipeline
2022-05-26 17:01:31 -07:00
Keith Simmons
125d83b3ec Fix failing seed bin build and add bin builds to ci pipeline 2022-05-26 15:41:24 -07:00
Nathan Sobo
d69776585d Add mouse_state method to RenderContext
We can use this to determine if a region is hovered or clicked.
2022-05-26 13:22:23 -06:00
Nathan Sobo
3a59d2a331 Allow hovered and clicked mouse regions to be tracked in the presenter 2022-05-26 12:44:52 -06:00
Nathan Sobo
0866f0ed55 Introduce CursorRegion struct
This will blend in with an upcoming MouseRegion struct that sits next to it in the scene.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-26 11:00:10 -06:00
Antonio Scandurra
eedb29963c Implement CopyPath 2022-05-26 16:45:41 +02:00
Antonio Scandurra
5b2d6e41f3 Introduce keyboard navigation in context menus 2022-05-26 16:36:30 +02:00
Antonio Scandurra
991eb742b0 Start adding project panel context menu actions 2022-05-26 15:23:40 +02:00
Antonio Scandurra
82ddac8e7e Restore focus when closing context menu 2022-05-26 15:21:55 +02:00
Antonio Scandurra
a5044ccbba WIP 2022-05-26 11:17:10 +02:00
Antonio Scandurra
580f1a4125 Style context menu 2022-05-26 10:40:53 +02:00
Nathan Sobo
c0aafac387 Put keystrokes in their own column
This requires rendering the menu for measurement in a totally different way, where the top level is a flex row. We don't want to render the menu like this for presentation because of hovers / highlights on individual items needing to include the keystrokes.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-26 09:59:25 +02:00
Antonio Scandurra
a8483ba458 WIP 2022-05-26 09:59:25 +02:00
Antonio Scandurra
85ed7b41f1 Select right-clicked entry before deploying context menu
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-26 09:59:25 +02:00
Antonio Scandurra
3b2f1644fb Constrain context menu to the width of the widest item
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-26 09:59:25 +02:00
Antonio Scandurra
f403d87eff WIP 2022-05-26 09:59:25 +02:00
Nathan Sobo
dcee8439b6 Start on context_menu crate 2022-05-26 09:59:25 +02:00
Nathan Sobo
b428d0de38 Break context menu items out in theme 2022-05-26 09:59:25 +02:00
Nathan Sobo
6b96822c1a Fix editor tests 2022-05-26 09:59:25 +02:00
Nathan Sobo
5b7825d5de Add MutableAppContext::keystrokes_for_action
This can be used to lookup keystrokes that will dispatch an action based on the currently focused view. There might be multiple, but we return the first found, meaning the most recently added bindings matching that action for the closest view to the focused view in the hierarchy.
2022-05-26 09:59:25 +02:00
Nathan Sobo
b110fd5fb7 Render a context menu when right-clicking in project panel
It doesn't currently do anything, but I managed to get it rendering in an absolutely positioned way.
2022-05-26 09:59:25 +02:00
Antonio Scandurra
f4d13ef596 Merge pull request #1068 from zed-industries/collab-snapshots
Implement /rpc_server_snapshot endpoint in collab server API
2022-05-26 09:42:39 +02:00
Antonio Scandurra
3ac6fc89c1 Pretty-print JSON of server snapshot 2022-05-26 09:34:39 +02:00
Nathan Sobo
742dd75041 Implement /rpc_server_snapshot endpoint
This returns a JSON snapshot of the state of the server
2022-05-25 17:42:25 -06:00
Nathan Sobo
6a32d55d85 Merge pull request #1065 from zed-industries/fix-build-script
Fix theme build issue in build.rs
2022-05-25 15:51:32 -06:00
Keith Simmons
42e88c43a4 Use npm install rather than ci and only run build.rs when styles/src is changed rather than all styles 2022-05-25 11:08:40 -07:00
Nate Butler
d6024117d8 Merge pull request #1060 from zed-industries/fix-disconnected-message
Fix disconnected from project message
2022-05-25 11:35:43 -04:00
Nate Butler
db0c2f24c4 Fix disconnected from project message 2022-05-25 11:19:06 -04:00
Nate Butler
6a8fe60424 Merge pull request #1059 from zed-industries/fix-theme-occurence-color
fix theme occurrence color
2022-05-25 10:57:10 -04:00
Nate Butler
e39089697d Merge pull request #1048 from zed-industries/onMedia-theme-text-color
Add onMedia text color for use in disconnect overlay text
2022-05-25 10:52:37 -04:00
Nate Butler
d0f0013f4d fix theme occurence color 2022-05-25 10:45:37 -04:00
Isaac Clayton
1f91e4c41a Merge pull request #1054 from zed-industries/abruzzo-theme
Add Abruzzo Dark color theme
2022-05-24 20:01:08 +02:00
Isaac Clayton
505b305b90 Adjust the orange/yellow a bit 2022-05-24 19:48:44 +02:00
Nathan Sobo
5fd2c5cb2e v0.35.0 2022-05-24 11:32:12 -06:00
Isaac Clayton
9bb1a5636f Add the fall-colored abruzzo theme 2022-05-24 18:32:44 +02:00
Antonio Scandurra
26295334d2 Remove accidentally checked-in theme assets and scripts 2022-05-24 14:31:58 +02:00
Antonio Scandurra
ca368453e2 Merge pull request #1052 from zed-industries/upgrade-tree-sitter
Upgrade tree-sitter to v0.20.6
2022-05-24 14:28:11 +02:00
Antonio Scandurra
8ebefa143a Upgrade tree-sitter to v0.20.6
This commit also adds a regression test to verify that with this new
version we don't mistakenly compute a different suggestion on Rust
buffer where the only change is leading whitespace.
2022-05-24 14:13:11 +02:00
Antonio Scandurra
5c4bd9393f Merge pull request #1050 from zed-industries/ignored-files
Show ignored entries in project panel
2022-05-24 10:57:16 +02:00
Antonio Scandurra
99573ca270 Fix unit tests assuming ignored files were not displayed 2022-05-24 10:50:27 +02:00
Antonio Scandurra
ec88288d5e Bump chunk size to 256 2022-05-24 09:54:53 +02:00
Antonio Scandurra
138a0b042d Make fade of ignored entries styleable 2022-05-24 09:12:57 +02:00
Antonio Scandurra
85f228dade Fix logic error when streaming ignored entries
We were calling `next` twice, which led us to skip every other entry.
This commit also enhances the `test_share_project` integration test
to exercise this new streaming logic.
2022-05-24 09:03:05 +02:00
Max Brunsfeld
acf9a59cc2 Merge pull request #1027 from zed-industries/missing-menu-commands
Add missing File menu commands, improve handling of unsaved multibuffers
2022-05-23 21:29:32 -07:00
Max Brunsfeld
ece8604547 Fix comments in Pane::close_items 2022-05-23 18:07:22 -07:00
Nathan Sobo
d30d2d67e7 Merge pull request #1049 from zed-industries/invite-codes-2
Support inviting new Zed users
2022-05-23 18:29:51 -06:00
Nathan Sobo
4cedf056a9 Bump protocol version 2022-05-23 18:18:15 -06:00
Nathan Sobo
6ed503fe6e Implement get_invite_code_for_user on test db 2022-05-23 18:07:23 -06:00
Nathan Sobo
5c2fdc01ff Update foreign key constraints to allow users to be deleted
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-23 17:46:06 -06:00
Nathan Sobo
51a61cc485 Don't assign invite code when updating count from 0 to 0
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-23 17:28:05 -06:00
Max Brunsfeld
7f92401bca Add key binding and menu item for Save All 2022-05-23 16:06:56 -07:00
Max Brunsfeld
0becbe482a Distinguish between singleton and non-singleton workspace items
* Prompt to save singleton items before non-singleton ones
* Don't prompt to save multi-buffers if they contain excerpts to items that are open elsewhere and not being closed.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-23 16:03:00 -07:00
Nathan Sobo
4b8f24c84e Set INVITE_LINK_PREFIX in K8s 2022-05-23 15:49:51 -06:00
Nathan Sobo
d8dbbf1c05 Merge remote-tracking branch 'origin/main' into invite-codes-2 2022-05-23 15:46:39 -06:00
Keith Simmons
e05695c4a6 Add onMedia text color for use in disconnect overlay text 2022-05-23 14:34:34 -07:00
Antonio Scandurra
94e70bc1a6 WIP: log received updated_entries on remote worktree
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-23 19:39:24 +02:00
Antonio Scandurra
c65dae8095 Correctly assign ignored status in refresh_entry
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-23 19:19:13 +02:00
Antonio Scandurra
23ca9dce2e WIP: stream ignored entries 2022-05-23 16:38:16 +02:00
Antonio Scandurra
1a6cc6f964 Show ignored entries in project panel 2022-05-23 16:37:57 +02:00
Antonio Scandurra
fcc6deceb9 Merge pull request #1035 from zed-industries/notify-guests-on-project-close
Broadcast `proto::UnregisterProject` when host closes a project
2022-05-23 15:41:29 +02:00
Antonio Scandurra
fe1498dc1d Fix worktree::Snapshot::entries(true) always being empty 2022-05-23 15:38:20 +02:00
Antonio Scandurra
2af4bdef42 Broadcast proto::UnregisterProject when host closes a project 2022-05-23 15:38:01 +02:00
Antonio Scandurra
e4c73b24fd Merge pull request #1033 from zed-industries/historical-events
Restart FSEventStream at the last seen event when "dropped" is reported
2022-05-23 11:10:22 +02:00
Antonio Scandurra
ce46efff2e 🎨 2022-05-23 09:48:00 +02:00
Antonio Scandurra
663173d2f5 Restart FSEventStream at the last seen event when "dropped" is reported 2022-05-23 09:33:10 +02:00
Antonio Scandurra
f3bc4feaf0 Pass a richer State pointer to fsevents trampoline
This will be useful to re-instate a new stream when dropping events.
2022-05-23 09:08:32 +02:00
Antonio Scandurra
e287425dee Merge pull request #1032 from zed-industries/clear-redo-stack-on-edit
Clear redo stack on edit
2022-05-23 08:25:38 +02:00
Max Brunsfeld
fbd589b589 Start work on handling multibuffers properly when closing unsaved buffers 2022-05-22 16:48:33 -07:00
Antonio Scandurra
37ca06df53 Clear multi-buffer redo stack when pushing transaction onto undo stack 2022-05-22 10:44:32 +02:00
Antonio Scandurra
03dc7c8eb0 Clear redo stack when pushing remote transaction or ending a local one 2022-05-22 10:33:26 +02:00
Nate Butler
5f69996604 Merge pull request #1025 from zed-industries/add-new-themes
Add multiple Zed themes
2022-05-21 21:08:50 -04:00
Nathan Sobo
7a8ff5abd7 Accept an optional email address when creating new users 2022-05-20 20:25:21 -06:00
Max Brunsfeld
21206800bc Add "Close Window" command 2022-05-20 16:53:03 -07:00
Max Brunsfeld
b08cad9ef5 Add "Save As" command 2022-05-20 16:24:42 -07:00
Max Brunsfeld
8ed33cadeb Add "Add Folder to Project" command to application menu 2022-05-20 16:19:43 -07:00
Max Brunsfeld
e72f5cea22 Add "New Window" command 2022-05-20 11:01:20 -07:00
Max Brunsfeld
c4fc3d9c7f Merge pull request #1023 from zed-industries/app-menu-improvements
Correctly populate application menus' keystrokes and enabled status
2022-05-20 10:22:20 -07:00
Max Brunsfeld
b72d97ce78 Disable menu item key equivalents while there are pending keystrokes 2022-05-20 10:04:43 -07:00
Nate Butler
b61153266b Add multiple Zed themes
Add the following themes:
- Andromeda
- Brushtree Light & Dark
- Rose-pine
- Rose-pine-dawn
- Sandcastle dark
- Summercamp dark
- Summerfruit
2022-05-20 11:51:59 -04:00
Antonio Scandurra
b751156cd7 Rename first_connection to connected_once
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-20 17:35:00 +02:00
Antonio Scandurra
0597c662e4 Show contacts panel the first time a new user connects to collab
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-20 17:33:09 +02:00
Antonio Scandurra
d8ee4378c9 Send a ShowContacts message the first time a user connects to collab 2022-05-20 15:47:14 +02:00
Antonio Scandurra
6f2c3f1e37 Update users and invite count after an invite gets redeemed 2022-05-20 12:02:31 +02:00
Max Brunsfeld
21862faa58 Convert function keys to the correct macOS codes for menu items 2022-05-19 17:37:46 -07:00
Nathan Sobo
eedb8ba59f Add affordance to copy user's invite link if they have a code
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-19 17:57:46 -06:00
Max Brunsfeld
df4cfa56cf Add application menu items 2022-05-19 16:50:40 -07:00
Max Brunsfeld
ea85473f4f Enable and disable application menu items based on the active view 2022-05-19 16:50:40 -07:00
Max Brunsfeld
c4554c1720 Replace build_workspace fn with an initialize function that takes a workspace
This makes it clearer that the function is not providing necessary
dependencies to a workspace, but rather configuring it with all of
the panels and widgets which are defined in downstream crates.
2022-05-19 16:50:22 -07:00
Max Brunsfeld
9e47e19f4e Pass UserStore to ContactsPanel instead of AppState 2022-05-19 14:43:36 -07:00
Max Brunsfeld
de99dcb0c3 Add cmd-n and cmd-o to the default keymap 2022-05-19 14:39:06 -07:00
Max Brunsfeld
ef0b584532 Remove AppState from workspace actions
This allows those actions to be bound to keystrokes in the keymap.
Also, remove the WorkspaceParams struct, simplify how Workspaces are
constructed.
2022-05-19 14:37:26 -07:00
Keith Simmons
1bf5f361d3 Merge pull request #1022 from zed-industries/editor-clone-selections
Clone selections on editor split
2022-05-19 12:49:43 -07:00
Nathan Sobo
a3bbabaaac Add ability to get the user for an invite code in collab API
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-19 12:35:07 -06:00
Keith Simmons
bacfed37b7 Clone selections on editor split 2022-05-19 11:22:53 -07:00
Nathan Sobo
3d7e912c6b Enable descriptive HTTP errors to be returned from DB layer
For now, we only use this when redeeming an invite code.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-19 11:55:55 -06:00
Nathan Sobo
d1b7a249b4 WIP 2022-05-19 11:09:44 -06:00
Max Brunsfeld
7445197f4d Derive application menu key equivalents from the keymap 2022-05-19 10:04:01 -07:00
Nathan Sobo
51f9b915a0 WIP 2022-05-18 16:14:58 -06:00
Max Brunsfeld
8dd6ad3116 Merge pull request #1018 from zed-industries/generate-themes-on-build
Remove checked-in theme JSON files
2022-05-18 14:26:54 -07:00
Max Brunsfeld
fbacc12672 Delete theme files more selectively when regenerating them
Avoid deleting files that will be rewritten later, so that Zed
won't observe states where themes are missing if two zed
processes are running at once.
2022-05-18 14:17:26 -07:00
Max Brunsfeld
89e91939e4 Write theme files atomically 2022-05-18 14:07:32 -07:00
Max Brunsfeld
47591ec9a7 Ensure /assets/themes directory exists 2022-05-18 12:43:26 -07:00
Max Brunsfeld
185bafcc05 Install node for run tests CI job
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-05-18 12:43:26 -07:00
Max Brunsfeld
ec41dd9f18 Remove checked-in theme JSON files
* Generate the themes on build
* In debug builds, watch the theme sources. When they change, re-generate
  the themes and reload the current theme, removing the need for the
  `theme_selector::Reload` command.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-05-18 12:43:26 -07:00
Max Brunsfeld
bdeac6b66a 🔥 .zed.toml 2022-05-18 11:01:35 -07:00
Nathan Sobo
37fcfeab8d WIP 2022-05-18 11:51:47 -06:00
Nathan Sobo
b3038c2de9 Return 404 from API if no user is found
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-18 10:32:58 -06:00
Nathan Sobo
7e2d1fefc4 Add ability to update invite count to collab API
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-18 10:23:08 -06:00
Nathan Sobo
cfb31067a5 Add invite codes / counts to users table
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-18 09:56:37 -06:00
Nate Butler
56553c3f90 Merge pull request #1012 from zed-industries/clean-up-themes
Clean up themes
2022-05-18 11:52:39 -04:00
Nate Butler
50e3745b92 Clean up themes
- Allow themes to have only a light or dark variant
- Added a commented template file
- Run formatter
2022-05-18 11:41:56 -04:00
Antonio Scandurra
610812eca0 Merge pull request #1010 from zed-industries/fix-stale-wrap-snapshot
Bump `FoldSnapshot` version if excerpt gets edited outside of its bounds
2022-05-18 10:44:08 +02:00
Antonio Scandurra
c0bf4a5bfd Bump FoldSnapshot version if excerpt gets edited outside of its bounds
This will cause layers above `FoldMap` to grab a fresh snapshot of the `FoldMap`
and, as a result, of the underlying `MultiBufferSnapshot`. It is a necessary change
because, even though the coordinate space is not affected, a buffer edit taking place
*before* an excerpt range could cause the excerpt buffer rows to change, e.g. if
lines were added or removed. This manifested itself in a randomized test.
2022-05-18 10:13:18 +02:00
Max Brunsfeld
efd9563b25 Merge pull request #1007 from zed-industries/dedup-contact-notifications
Avoid creating duplicate notifications
2022-05-17 11:29:10 -07:00
Max Brunsfeld
9b29245590 Avoid duplicate notifications
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-17 11:19:22 -07:00
Nate Butler
d5c7a96f98 Merge pull request #1005 from zed-industries/update-light-theme-borders
Update light theme borders
2022-05-17 13:30:15 -04:00
Nate Butler
72ab5740f1 Update light theme borders 2022-05-17 13:14:11 -04:00
Nathan Sobo
1c9ad942df v0.34.0 2022-05-17 11:10:21 -06:00
Nathan Sobo
1e366b8093 Merge pull request #1003 from zed-industries/moar-logs
Log JSON in Kubernetes
2022-05-17 11:09:10 -06:00
Nathan Sobo
fb246ac343 Log JSON in Kubernetes
If you set LOG_JSON=true, we'll output JSON from the tracing subscriber instead of pretty-printing trace output.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-17 11:05:22 -06:00
Antonio Scandurra
ad94b4cc73 Merge pull request #1001 from zed-industries/request-to-join-project
Request to join projects instead of sharing/unsharing
2022-05-17 16:30:25 +02:00
Antonio Scandurra
2d986c7968 Show guest only once even if they joined on two different windows
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-17 16:21:09 +02:00
Antonio Scandurra
692be10b10 Dynamically load all themes listed under styles/src/themes/*.ts
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-17 16:08:14 +02:00
Antonio Scandurra
8f88803695 Automatically follow host when joining a project 2022-05-17 15:35:57 +02:00
Antonio Scandurra
225536accc Merge branch 'main' into request-to-join-project 2022-05-17 14:55:20 +02:00
Antonio Scandurra
8393bfe032 Ensure join request reaches the server before disconnecting host in test 2022-05-17 14:50:28 +02:00
Antonio Scandurra
a828282771 Fix Store::remove_connection not removing guests from projects 2022-05-17 14:50:00 +02:00
Antonio Scandurra
7b161b81b5 WIP: accept to join requests if user is already participating
There's a panic caused by `Store::check_invariants` that we still
need to figure out.
2022-05-17 13:21:20 +02:00
Antonio Scandurra
e0c772db3e Hold a weak handle to Presenter when dispatching events
This ensures that the only strong reference to the presenter is held
by `App`. This is important because we want to call `flush_effects`
when removing a window and implicit drops of the `Presenter` would
make that hard.

Before this commit, if a rendered view contained strong handles to
views and models, we would only drop them on the next `flush_effects`.
This was manifesting itself in `Project`s not being released when
closing their containing window.
2022-05-17 13:04:38 +02:00
Antonio Scandurra
cc598a6f71 Send LeaveProject when waiting room is dismissed while waiting 2022-05-17 11:25:14 +02:00
Nathan Sobo
d821e7a4c1 Cancel join requests when the requester closes the window 2022-05-16 20:29:36 -06:00
Nathan Sobo
7c3eebf93e Refine messages on waiting to join screen and include host avatar 2022-05-16 16:52:31 -06:00
Keith Simmons
25427f0ff8 Merge pull request #999 from zed-industries/update-theme-system
Rework color schemes
2022-05-16 15:28:18 -07:00
Nate Butler
af5bb92847 Rework color schemes
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-05-16 18:11:22 -04:00
Nate Butler
7d22ede804 Remove the focused token
Currently we don't have any concept of a true focus state. All states we currently use focus should actually be `active`.

Removing this token until we introduce a distinction between active and focused states.
2022-05-16 15:38:06 -04:00
Nathan Sobo
91257f308e Remove "They won't know if you decline" message 2022-05-16 13:15:46 -06:00
Antonio Scandurra
ed6ed99d8f Show the reason why a join request was declined
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-16 19:57:50 +02:00
Antonio Scandurra
740ec3d192 WIP: decline pending join requests when project is unregistered 2022-05-16 17:46:08 +02:00
Antonio Scandurra
aa90c06012 Display a temporary window while remote project is loading 2022-05-16 17:45:50 +02:00
Antonio Scandurra
e6576b32b2 Don't show "they won't know if you decline" when request is accepted 2022-05-16 15:37:29 +02:00
Antonio Scandurra
c2973f33c2 Uncomment randomized tests for contacts 2022-05-16 15:13:32 +02:00
Antonio Scandurra
47ce8ae05c Poll snapshot after refreshing entry 2022-05-16 11:50:21 +02:00
Antonio Scandurra
b144995f27 Grab share state after retrieving metadata when refreshing entry 2022-05-16 11:46:49 +02:00
Antonio Scandurra
576656ccf2 Delete commented-out code 2022-05-16 09:50:36 +02:00
Antonio Scandurra
bf638afac5 Initialize UserStore before client connects in integration tests
This fixes a failure in `test_contacts` where we were receiving the
initial `proto::UpdateContacts` message before `UserStore` had a chance
to register a message handler for it.
2022-05-16 09:48:24 +02:00
Keith Simmons
a7937f2d48 Merge pull request #997 from zed-industries/fix-outline-panic
Make multibuffer read pub(crate) and replace with accessors
2022-05-13 17:07:43 -07:00
Max Brunsfeld
842bfae3af WIP - update worktree's scan_id when mutating it in the foreground 2022-05-13 17:03:48 -07:00
Keith Simmons
a2fd41174f Reduce accessibility of multibuffer read to reduce risk of borrowing snapshot and buffer refcells twice 2022-05-13 16:58:30 -07:00
Keith Simmons
2f7eb6dbc5 Merge pull request #973 from zed-industries/selections-refactor
Pull selections out of editor into selections collection
2022-05-13 16:07:26 -07:00
Keith Simmons
45ea3d4c38 Review fixes 2022-05-13 15:55:27 -07:00
Keith Simmons
20c97637a4 minor tweaks to selections collection api 2022-05-13 15:55:27 -07:00
Keith Simmons
c3a36e6d8a Rename selected_ranges and selected_display_ranges to remove redundant selected 2022-05-13 15:55:27 -07:00
Keith Simmons
de9dc27980 store buffer and display_map model handles on selections collection 2022-05-13 15:55:27 -07:00
Keith Simmons
db0a9114c2 Passing tests and removed local argument. Also pulled autoscroll argument out to change_selections 2022-05-13 15:55:27 -07:00
Keith Simmons
c9dcfff607 Move selection helpers to SelectionCollection, add update_anchor_selections, add a number of invariant preserving mutation functions to the MutableSelectionCollection 2022-05-13 15:55:17 -07:00
Max Brunsfeld
f2eee6692b Send RemoveProjectCollaborator to host in addition to ProjectUnshared 2022-05-13 15:04:48 -07:00
Max Brunsfeld
1996b01a74 Tell host to unshare project when last guest leaves 2022-05-13 14:57:55 -07:00
Nathan Sobo
08206dc78d Merge pull request #996 from zed-industries/fix-cursor-flicker
Only synthesize mouse moves on scene construction if window is active
2022-05-13 14:21:21 -06:00
Nathan Sobo
a620665bed Only synthesize mouse moves on scene construction if window is active 2022-05-13 14:05:13 -06:00
Antonio Scandurra
5789aeea24 Fix randomized test failure caused by unsharing while guest was joining
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-13 17:39:13 +02:00
Antonio Scandurra
dd684d26a1 Make Project::share and Project::unshare private
This is still in-progress because randomized tests are failing.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-13 17:17:20 +02:00
Max Brunsfeld
be51a58311 Start work on requesting to join projects
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-12 17:53:11 -07:00
Nathan Sobo
02e39e756b 0.33.0 2022-05-12 14:46:33 -06:00
Nathan Sobo
7847707090 Merge pull request #990 from zed-industries/more-tracing
Improve tracing support
2022-05-12 14:45:50 -06:00
Nathan Sobo
451338061d Try to improve tracing messages when client disconnects 2022-05-12 13:05:05 -06:00
Nathan Sobo
a3b9ad75b0 Include login in connection-related tracing spans/events
Also, include metadata on more events and add an event called "signing out" with all this metadata to make it easier to search for.
2022-05-12 12:06:06 -06:00
Nathan Sobo
3226e07dcc Remove commented method 2022-05-12 11:37:33 -06:00
Max Brunsfeld
e199b7e50e Merge pull request #988 from zed-industries/contact-panel-keyboard-nav
Allow interacting with the contacts panel using the keyboard
2022-05-12 10:06:27 -07:00
Max Brunsfeld
47ed9c76ed Select the first contact when changing the filter in the contacts panel
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-05-12 09:56:32 -07:00
Nathan Sobo
de555e3423 Enable logging of rpc crate trace events when no subscriber is present
This allows these events to be logged in the Zed client (until we setup tracing there).

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-12 10:17:37 -06:00
Nathan Sobo
e795a7a578 💄
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-12 10:16:50 -06:00
Nathan Sobo
9ca6e29a17 Use tracing instead of log in collab and rpc crates
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-12 10:05:49 -06:00
Nathan Sobo
9f6e82720d WIP: Enhance tracing in Peer
- Add a bunch of events to Peer's async connection handling logic
- Use an EnvFilter to allow more control over the verbosity level of tracing on a per-module basis
- Wire up logging to emit trace events (we actually probably want to do this the other way around)

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-12 09:58:17 -06:00
Antonio Scandurra
c7802af88b Use cmd-9 and cmd-shift-9 to toggle contacts panel focus/visibility 2022-05-12 12:11:27 +02:00
Antonio Scandurra
77b524c83e Allow toggling sections in contacts panel by clicking on them 2022-05-12 11:48:11 +02:00
Max Brunsfeld
f54d74eda9 Merge branch 'main' into contact-panel-keyboard-nav 2022-05-11 17:45:44 -07:00
Max Brunsfeld
85d9ac5b95 Merge pull request #987 from zed-industries/notifications
Notify when someone requests to add you as a contact or accepts your contact request
2022-05-11 17:40:11 -07:00
Max Brunsfeld
72e7079005 Add the ability to expand and collapse sections of the contacts panel
Also, allow joining projects using the keyboard.
2022-05-11 17:28:35 -07:00
Max Brunsfeld
615319b2ab Rework the contact panel's styling to allow keyboard navigation
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-11 16:50:51 -07:00
Max Brunsfeld
4739c683af Fix bug where Contacts included projects for which the use was a guest 2022-05-11 16:49:56 -07:00
Max Brunsfeld
0ba656aa0e Improve layout and styling of contact notifications
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-11 14:20:05 -07:00
Max Brunsfeld
3bc9b8ec85 Add notifications for accepted contact requests
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-11 11:39:01 -07:00
Keith Simmons
61b4a4202f Merge pull request #984 from zed-industries/deterministic-marked-text-ranges
Order returned ranges from marked_text_ranges by start index
2022-05-11 10:31:33 -07:00
Keith Simmons
a33ef65f57 Order returned ranges from marked_text_ranges by start index 2022-05-11 10:18:40 -07:00
Antonio Scandurra
a5fd664b00 Add the ability to notify when a user accepts a contact request
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-05-11 18:51:40 +02:00
Nate Butler
5247246e91 Merge pull request #983 from zed-industries/add-onMedia-border-token
Add onMedia border token
2022-05-11 12:48:11 -04:00
Nate Butler
50b44ebe85 Add onMedia border token 2022-05-11 12:35:00 -04:00
Antonio Scandurra
933a1f2cd6 Show badge when there are pending contact requests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-11 17:39:03 +02:00
Antonio Scandurra
c71b264786 Allow accepting/rejecting incoming requests via notification 2022-05-11 15:25:33 +02:00
Antonio Scandurra
97d3616ed9 Show incoming request notification and implement dismissal 2022-05-11 15:13:37 +02:00
Max Brunsfeld
08a7543913 WIP - start work on keyboard navigation in contacts panel 2022-05-10 21:45:49 -07:00
Max Brunsfeld
297fa1af55 Avoid possible memory leak of FakeServer in tests 2022-05-10 21:45:12 -07:00
Max Brunsfeld
d0052ccfb5 Avoid panic when trying to fetch an invalid URL 2022-05-10 21:44:33 -07:00
Nathan Sobo
fe89de8b11 Dismiss contact request notification if request is cancelled 2022-05-10 18:50:18 -06:00
Nathan Sobo
3bca1c29e2 Present a blank notification upon receipt of a contact request 2022-05-10 18:33:39 -06:00
Nathan Sobo
bd2ae304fa Start on workspace notifications 2022-05-10 17:46:46 -06:00
Nathan Sobo
9c68c3e8a9 Put context parameter last in toggle_modal callback
This is more consistent with our treatment of context params everywhere else.
2022-05-10 16:46:53 -06:00
Max Brunsfeld
6b5cab5db1 Bump protocol version number 2022-05-10 15:38:49 -07:00
Max Brunsfeld
c5360172e4 Merge pull request #979 from zed-industries/contacts
Manage users' contact relationships on the server
2022-05-10 15:11:30 -07:00
Max Brunsfeld
b1a75805cc Consolidate logic for rendering contact requests 2022-05-10 14:52:13 -07:00
Max Brunsfeld
834c485300 Don't use pointing hand cursor for the user's own projects 2022-05-10 14:46:42 -07:00
Keith Simmons
93f8f47cc0 Merge pull request #980 from zed-industries/coerce-multibuffer-changes
Filter overlapping multibuffer edits
2022-05-10 14:45:35 -07:00
Keith Simmons
c4738d7316 Add test coverage for same cursor in multiple excerpts of the same buffer 2022-05-10 14:30:27 -07:00
Max Brunsfeld
334f246df3 Include every user in their own list of contacts 2022-05-10 14:05:07 -07:00
Keith Simmons
68de51ba8a Fix multiple cursors inserting repeated text in multibuffers 2022-05-10 13:32:27 -07:00
Keith Simmons
6c57fcf9be Merge pull request #968 from zed-industries/vim-visual-mode
Vim visual mode
2022-05-10 12:51:58 -07:00
Max Brunsfeld
dc465839e1 Round sidebar panels' widths to whole numbers of pixels
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-10 11:25:51 -07:00
Max Brunsfeld
de9a7b1927 Give the contact panel's filter editor some placeholder text
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-10 11:25:12 -07:00
Max Brunsfeld
14ec3c86e5 Clear contact panel filter editor on escape
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-10 11:18:30 -07:00
Max Brunsfeld
b33cbccc31 Improve layout of contact panel rows
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-10 11:14:31 -07:00
Keith Simmons
3f1640a9a0 Fix up assertion errors in set_eq and visual tests 2022-05-10 11:12:34 -07:00
Keith Simmons
37c921f972 Initial visual mode 2022-05-10 11:12:28 -07:00
Max Brunsfeld
2cf9659f88 Style the buttons in the contact panel and contact finder
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-05-10 10:47:25 -07:00
Antonio Scandurra
a121576545 WIP 2022-05-10 18:25:47 +02:00
Antonio Scandurra
6c3e3c84ec Eliminate flicker when contact status is pending
We do this by using a bullet. When we have animations, a spinner would be better.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-10 17:32:57 +02:00
Antonio Scandurra
b00338195e Make user fuzzy search case-insensitive
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-10 17:30:09 +02:00
Antonio Scandurra
93688cbe22 Fix bug when determining contact status
Users are sorted by login but we were binary-searching them by id.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-10 17:26:53 +02:00
Antonio Scandurra
d4e6ab4975 Seed first users from GitHub when running script/seed-db --github-users
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-10 17:19:39 +02:00
Antonio Scandurra
f81edb88fe Pull out contact finder as a picker
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-10 16:43:51 +02:00
Nathan Sobo
b721f0064a Start on contact finder modal
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-10 07:24:14 -06:00
Nathan Sobo
eef99f059d Make flex elements fill available space when they contain a float
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-10 06:14:30 -06:00
Antonio Scandurra
12783a588c Prevent users from fuzzy searching and adding themselves as contacts 2022-05-10 12:22:50 +02:00
Antonio Scandurra
09580516a0 Start on adding icon for requesting contacts 2022-05-10 12:09:24 +02:00
Antonio Scandurra
52c36d3e3d Maintain online status in contacts panel 2022-05-10 10:33:57 +02:00
Nathan Sobo
4e9924c717 Filter out empty projects in contacts panel 2022-05-09 20:57:41 -06:00
Nathan Sobo
ef868ff023 Fix test after changing fuzzy matching for empty queries 2022-05-09 20:41:18 -06:00
Max Brunsfeld
3dee656490 Avoid panic when language server is dropped before being initialized in tests
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-09 18:05:10 -07:00
Max Brunsfeld
45b6a9df36 Avoid sending a GetUsers request for an emptly list of user ids
We don't actually need to return the users at this time. We just call this for its side effect.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-09 18:03:24 -07:00
Max Brunsfeld
b8aba0972d Wait until contacts have been cleared when disconnecting
Also, use an mpsc for UpdateContacts messages, not a watch, since
the messages now represent changes instead of snapshots.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-09 17:23:39 -07:00
Max Brunsfeld
2a2698b8db Remove stray printing in contacts panel 2022-05-09 16:31:30 -07:00
Max Brunsfeld
0533a0bd3c Allow users to remove contact relationships that they initiated 2022-05-09 16:31:30 -07:00
Max Brunsfeld
054d697fb7 Remove remaining code associated with .zed.toml files 2022-05-09 16:31:30 -07:00
Max Brunsfeld
d7cba73ead Decrement pending_contact_requests even if a request fails 2022-05-09 16:19:00 -07:00
Max Brunsfeld
2aec4ff234 Pick files directly from the Fs in simulate_host
Previously, the list of all existing files was maintained separately, but
it was not updated when a guest created a file.
2022-05-09 15:39:45 -07:00
Nathan Sobo
3d6db9083d Update a user's contacts when they connect; fix test failures
The test failure we fixed doesn't seem directly related to the contact update. Maybe it just caused a failure to occur earlier than it would have in the sequence of seeds.

We fixed the test failure by responding to a user joining the project while holding the lock on the Store. This ensures that we don't send messages related to the project to that user until they've had a chance to setup event handlers after receiving the response.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-09 15:57:16 -06:00
Nathan Sobo
40f1427885 Show requests in contacts panel
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-09 12:48:07 -06:00
Nathan Sobo
e9d8cc94cc Rename script to match others (dashes)
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-09 11:24:16 -06:00
Nathan Sobo
e3ee19b123 Wire up UI for requesting contacts and cancelling requests
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-05-09 11:24:05 -06:00
Antonio Scandurra
e4f1952657 WIP 2022-05-09 17:06:21 +02:00
Antonio Scandurra
ca56b0d6d5 Forbid joining projects if users are not contacts 2022-05-09 15:51:54 +02:00
Antonio Scandurra
95d29c4a7b Update contacts when peers join/leave and when project status changes 2022-05-09 15:08:18 +02:00
Antonio Scandurra
3319e0a613 Implement contact rejection 2022-05-09 10:02:14 +02:00
Nathan Sobo
9b1b61355a Fully test contact request acceptance
* Be sure we send updates to multiple clients for the same user
* Be sure we send a full contacts update on initial connection

As part of this commit, I fixed an issue where we couldn't disconnect and reconnect in tests. The first disconnect would cause the I/O future to terminate asynchronously, which caused us to sign out even though the active connection didn't belong to that future. I added a guard to ensure that we only sign out if the I/O future is associated with the current connection.
2022-05-08 15:19:56 -06:00
Nathan Sobo
5d20338f69 Get basic test of accepting a contact request passing 2022-05-07 15:09:27 -06:00
Nathan Sobo
93dae88cac WIP: Fix compile errors by commenting stuff out 2022-05-07 14:04:13 -06:00
Nathan Sobo
4f06dca78b WIP: Update contacts based on deltas rather than snapshots 2022-05-06 20:50:59 -06:00
Max Brunsfeld
8a3425477f Start work on RPC endpoints for dealing with contact requests
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-06 15:44:47 -07:00
Max Brunsfeld
274c4c244c Implement persistence for contacts
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-06 13:33:23 -07:00
Antonio Scandurra
989b82d664 Refactor add_request_handler to respond via a Response struct
This also removes `add_sync_request_handler`.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-06 17:01:27 +02:00
Antonio Scandurra
9555b93bca Wait on RECEIVE_TIMEOUT in tests when testing disconnection
We were waiting for 3 seconds, but the timeout had changed in the meantime,
making some iterations of the tests fail.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-06 16:47:08 +02:00
Antonio Scandurra
44f37afa95 Define data types for the new contacts model
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-06 16:24:44 +02:00
Antonio Scandurra
95d848fe1e Ensure flex_float works even when re-painting without layout
Previously, we were mutating the remaining space stored on the layout
state, which would cause re-paints to always have a `remaining_space`
of 0 and therefore not align `flex_float` elements to the right/bottom.
2022-05-06 10:20:03 +02:00
Max Brunsfeld
8445eaab85 Fix crash when emptying atlases
Previously, when an atlas was emptied, we would move it into a different
vector: free_atlases. This removal could cause existing atlas ids to
refer to the wrong atlases.
2022-05-05 17:52:47 -07:00
Max Brunsfeld
4620c7a1e5 Filter existing contacts when searching in the contacts panel 2022-05-05 15:04:50 -07:00
Max Brunsfeld
ea81737a88 Allow fuzzy-search for potential contacts in the contacts panel
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-05 14:14:44 -07:00
Max Brunsfeld
35fea43089 Adjust fuzzy search to avoid filtering based on edit distance threshold 2022-05-05 12:43:38 -07:00
Max Brunsfeld
439a5dad80 0.32.0 2022-05-05 09:49:11 -07:00
Nathan Sobo
342bdfc7e0 Render a user query editor in the contacts panel 2022-05-05 10:24:21 -06:00
Nathan Sobo
6050e0ead7 Add fuzzy_search_users to Db trait, PostgresDb 2022-05-05 09:58:18 -06:00
Antonio Scandurra
079e514379 Merge pull request #948 from zed-industries/project-browser-refinements
Add commands for manipulating files in the project panel
2022-05-05 15:54:59 +02:00
Antonio Scandurra
76ad563b45 Fix memory leak of ProjectPanel
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 15:52:46 +02:00
Antonio Scandurra
2e9bdfbeac Improve delete prompt in project browser
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 15:49:40 +02:00
Antonio Scandurra
6021ab12c9 Clear project browser editor even if an operation fails
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 15:43:42 +02:00
Antonio Scandurra
954fabec42 Don't hide sidebar when hitting cmd-1
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 15:34:36 +02:00
Antonio Scandurra
2e6cf2011d When opening items via project panel, only focus them on double-click
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 15:27:27 +02:00
Antonio Scandurra
61346f734d WIP 2022-05-05 15:15:58 +02:00
Antonio Scandurra
6b22c47d47 Introduce guest file creation in randomized collaboration test
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-05 14:54:35 +02:00
Antonio Scandurra
6212f2fe30 Wait for remote worktree to catch up with host before mutating entries
This ensures that entries don't randomly re-appear on remote worktrees
due to observing an update too late. In fact, it ensures that the remote
worktree has the same starting state of the host before preemptively applying
the fs operation locally.
2022-05-05 13:47:53 +02:00
Antonio Scandurra
ecb847a027 Fix bugs in FakeFs::{remove_dir,rename} 2022-05-05 09:02:31 +02:00
Max Brunsfeld
4b1c46fa45 Allow deleting entries from the project panel 2022-05-04 18:00:23 -07:00
Max Brunsfeld
509ede0e80 Allow guests to create directories 2022-05-04 16:52:46 -07:00
Max Brunsfeld
40e0f10195 Allow creating directories from the project panel 2022-05-04 16:47:11 -07:00
Max Brunsfeld
a2c22a5e43 Prevent eager snapshot mutations from being clobbered by background updates
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-04 15:10:39 -07:00
Max Brunsfeld
821dff0e2d Keep showing edited filename in project panel while edit is in-progress 2022-05-04 13:03:50 -07:00
Max Brunsfeld
ff3cf3c0c3 Bump protocol version number 2022-05-04 10:33:26 -07:00
Max Brunsfeld
438e4e7a19 Allow guests to rename stuff
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-04 10:28:44 -07:00
Nathan Sobo
470d693d5e Rename entries via the project to prepare for guest support
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
657ea264cc Allow guests to create files from the project panel
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
8291b8108d Update snapshot atomically when processing FS events 2022-05-04 10:28:44 -07:00
Max Brunsfeld
0ff39f1280 Select new files in the project panel after creating them 2022-05-04 10:28:44 -07:00
Max Brunsfeld
a19766931d Rename entry atomically in LocalWorktree::rename 2022-05-04 10:28:44 -07:00
Max Brunsfeld
8fdc5c9be3 Improve the appearance of project panel filename editor
* Always layout single-line editors with a fixed height
* Preserve directory chevron when editing folder names
* Allow theming the filename editor

Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
333b4aaf4e Implement Rename command in project panel 2022-05-04 10:28:09 -07:00
Max Brunsfeld
a217e2e64b Implement basic AddFile command in project panel 2022-05-04 10:28:09 -07:00
Max Brunsfeld
d4492086b3 Abstract more local project setup inside Project::test helper 2022-05-04 10:28:09 -07:00
Max Brunsfeld
12d45f1655 Clean up project panel theme 2022-05-04 10:28:08 -07:00
Antonio Scandurra
aa4919a76f Merge pull request #964 from zed-industries/transpose
Introduce `Editor::transpose` bound to `ctrl-t`
2022-05-04 10:04:55 +02:00
Antonio Scandurra
9a7c07f539 Improve transpose when cursors are two chars away from each other 2022-05-04 09:59:34 +02:00
Keith Simmons
5e2e859413 Merge pull request #947 from zed-industries/misc-normal-commands
Misc vim normal commands
2022-05-03 10:29:29 -07:00
Antonio Scandurra
c7007b64de Merge pull request #965 from zed-industries/avatar-margin
Parameterize `avatar_margin` and assign it a default of 8
2022-05-03 18:12:06 +02:00
Antonio Scandurra
3ee4d90c19 Parameterize avatar_margin and assign it a default of 8 2022-05-03 18:04:53 +02:00
Antonio Scandurra
95680aa5f2 Account for multi-byte characters in Editor::transpose 2022-05-03 14:35:03 +02:00
Antonio Scandurra
b6ff07afac Add failing test for multi-byte characters 2022-05-03 14:33:57 +02:00
Antonio Scandurra
070607c821 Implement Editor::transpose without accounting for multi-byte chars 2022-05-03 14:33:43 +02:00
Keith Simmons
797aecf7c1 Don't reset vim mode on editor focus 2022-05-02 11:49:10 -07:00
Keith Simmons
b2138f5935 Add insert line above and below 2022-05-02 11:49:10 -07:00
Keith Simmons
833a7b6e76 WIP just missing insert line above and below 2022-05-02 11:49:10 -07:00
Antonio Scandurra
c268099554 Merge pull request #960 from zed-industries/crash-reporting
Implement panic reporting
2022-05-02 19:12:12 +02:00
Antonio Scandurra
875cb13e6d Rename "crash" to "panic"
We are not really sending crash reports but Rust panics, so might
as well be clear about that.
2022-05-02 17:36:56 +02:00
Antonio Scandurra
da3870ea31 Pass secret token when uploading crashes 2022-05-02 15:42:52 +02:00
Antonio Scandurra
54a45095cd Retrieve app version from crash rather than from current binary
The crash might have been generated weeks before and the app may
have been updated since then.
2022-05-02 15:34:05 +02:00
Antonio Scandurra
09a8b8e675 Capture crash reports and upload them the next time Zed launches 2022-05-02 15:17:43 +02:00
Antonio Scandurra
39c7b1fd51 Merge pull request #959 from zed-industries/fix-paste
Fix bugs when pasting text
2022-05-02 10:30:59 +02:00
Antonio Scandurra
2977b33dd9 Use the new batched edit API when pasting
This fixes a bug that would cause zed to paste text at the wrong
location when inside a multi-buffer where the same buffer was excerpted
more than once.
2022-05-02 10:21:53 +02:00
Antonio Scandurra
5821ce9b82 Insert newlines on paste if copied selections don't match current ones 2022-05-02 10:21:20 +02:00
Antonio Scandurra
a7c953cb30 Merge pull request #958 from zed-industries/titlebar-padding
Add right padding to titlebar instead of margins on elements
2022-05-02 09:32:15 +02:00
Antonio Scandurra
4518db0ce6 Update accidentally uncommitted Cargo.lock 2022-05-02 09:27:51 +02:00
Antonio Scandurra
5d0c3c43e8 Add right padding to titlebar instead of margins on elements
This fixes a visual glitch causing the avatar to be shown too close to
the right edge of the window when the share icon was not present.
2022-05-02 09:27:37 +02:00
Nate Butler
5b68534427 Merge pull request #949 from zed-industries/base16-theme-occurrence-style
Update base16 theme occurrence style
2022-04-30 00:57:55 -04:00
Nate Butler
f63444ce6d Update base16 theme occurrence style
- Update base16 theme occurrence style to be visible
- Update match styles to use the blend scaling value
  - This makes it so matches are less loud in light themes
2022-04-30 00:47:07 -04:00
Keith Simmons
d4bef67cf2 Merge pull request #929 from zed-industries/non-uniform-batched-edits
Allow batched edits where each range is associated with different insertion text
2022-04-29 16:14:38 -07:00
Keith Simmons
2eb1c107ce Convert common edit strings to Arc<str> and simplify duplicate line 2022-04-29 14:57:20 -07:00
Max Brunsfeld
2c2ca1bfbd Reduce string allocations in Editor::insert
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-29 10:07:21 -07:00
Antonio Scandurra
cddafa5fef Merge pull request #940 from zed-industries/telemetry
Instrument the collab server with OpenTelemetry collecting into Honeycomb.io
2022-04-29 17:50:55 +02:00
Antonio Scandurra
c8179a61ee Restore .zed.toml
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-29 17:41:49 +02:00
Antonio Scandurra
003bbe9aab Serialize payload in "handle message" span
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-29 17:34:22 +02:00
Antonio Scandurra
f4e5cb14bf Remove collaborators_per_project from Metrics
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-29 17:19:14 +02:00
Antonio Scandurra
63e1845537 Revert "WIP"
This reverts commit 47e7d924b2.
2022-04-29 16:45:29 +02:00
Nathan Sobo
47e7d924b2 WIP 2022-04-29 08:23:23 -06:00
Nathan Sobo
53e7c758f8 0.31.0 2022-04-29 05:58:34 -06:00
Antonio Scandurra
14b078dc0c Use f32s for metrics so that we can do aggregation math on honeycomb 2022-04-29 10:31:47 +02:00
Antonio Scandurra
6734793069 Start adding metrics to collab server 2022-04-29 10:25:20 +02:00
Antonio Scandurra
b51a53addb Replace log_err with trace_err on collab::rpc 2022-04-29 09:21:09 +02:00
Nate Butler
038f306ed8 Merge pull request #931 from zed-industries/add-size-token
WIP: Add the `size` token
2022-04-29 01:46:50 -04:00
Nate Butler
1ecd8551c6 Merge pull request #942 from zed-industries/style-status-bar
Update Zed styles
2022-04-29 01:46:27 -04:00
Nate Butler
f4dbe4d976 Update projectBrowser styles 2022-04-29 01:35:58 -04:00
Nate Butler
67181a16c0 Update search style 2022-04-29 01:24:21 -04:00
Nate Butler
098ad7dbfa Update base16 themes background states 2022-04-29 01:24:11 -04:00
Nate Butler
945d7c52a0 Remove unused import 2022-04-29 01:23:52 -04:00
Nate Butler
70a7bd2747 Style out of date message 2022-04-29 01:06:44 -04:00
Nate Butler
a352f8bad4 Update status bar style 2022-04-29 00:59:08 -04:00
Keith Simmons
920601cb94 Bump protocol version 2022-04-28 18:56:26 -07:00
Keith Simmons
b4b61b4bbc Consolidate edit and edit_batched functions 2022-04-28 16:52:04 -07:00
Max Brunsfeld
d9735f312f Merge pull request #936 from zed-industries/about-window
Make the 'About Zed' menu item display Zed's version number
2022-04-28 16:17:51 -07:00
Max Brunsfeld
b055d90b68 Make the 'About Zed' menu item display Zed's version number 2022-04-28 16:10:11 -07:00
Max Brunsfeld
c2b892d24d Merge pull request #935 from zed-industries/style-command-palette-active-keystroke
Allow the theme to style the keystroke of the active item in the command palette
2022-04-28 15:42:47 -07:00
Max Brunsfeld
d9497d49de 🎨 Use Interactive wrapper for search option buttons 2022-04-28 15:29:03 -07:00
Max Brunsfeld
8481834847 Give hover state to picker items, keystrokes in command palette 2022-04-28 15:17:56 -07:00
Max Brunsfeld
a60c75e343 Rename Selector -> Picker in theme 2022-04-28 14:45:32 -07:00
Max Brunsfeld
025d657e3a Merge pull request #933 from zed-industries/format-on-save-setting
Add format_on_save setting
2022-04-28 14:38:49 -07:00
Max Brunsfeld
fa358c01cf Add format_on_save setting
This lets you turn of formatting on save for specific languages.
2022-04-28 14:31:06 -07:00
Max Brunsfeld
79fad42424 Parse .mjs files as JavaScript
Closes #856
2022-04-28 14:09:39 -07:00
Keith Simmons
74b467aaa8 tweak editor selection mutating functions 2022-04-28 13:46:06 -07:00
Keith Simmons
42b900774e add anchor to selection fixup info in newline 2022-04-28 13:10:31 -07:00
Max Brunsfeld
c51d5b9165 Remove accidental background color on unhovered ok indicator
A follow-up to #921
2022-04-28 12:44:37 -07:00
Max Brunsfeld
37a3cead03 Merge pull request #921 from zed-industries/new-status-bar-design
Style the status bar according to the latest design
2022-04-28 12:42:25 -07:00
Max Brunsfeld
e48a975b1e Give no-error diagnostic indicator a hover state 2022-04-28 12:35:20 -07:00
Max Brunsfeld
6578ae5393 Use Interactive helper to theme titlebar buttons 2022-04-28 12:08:15 -07:00
Nate Butler
b41bf65c96 Statusbar style tweaks 2022-04-28 14:52:31 -04:00
Nate Butler
6fc68a8ddd Move projectDiagnostics to it's own file and remove unused code
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-28 14:52:12 -04:00
Nate Butler
425473d296 Update token build script for figma
- Use syntax tokens instead of manually adding token content
- Add solarized to output
- Add ramp step value to the token description in Figma Tokens

Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-04-28 14:08:59 -04:00
Nate Butler
607719ed26 Update size token function and types
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-04-28 14:07:20 -04:00
Max Brunsfeld
772f4579fc Restructure status bar theme to style interactive elements more concisely
Introduce an `Interactive` wrapper type that allows themes to selectively
override properties of items in a hovered or active state.
2022-04-28 10:59:32 -07:00
Nate Butler
0cc5a3839d Add the size token
Introduces the `size` token, a token that will be used for defining standardized sizes for paddings, margins & borders.

Available sizes are `px`, `xs`, `sm`, `md`, `lg`, `xl`

- Adds `size`, types, and token
- Adds the size() function
2022-04-28 12:31:44 -04:00
Keith Simmons
4c860dc82f Removed unnecessary debug statements 2022-04-28 09:20:56 -07:00
Nathan Sobo
1fe964ac16 Start moving from logging to tracing on collab server
Install some spans. Probably more work to do here.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-28 09:45:59 -06:00
Nathan Sobo
2d9d30f74a Set log level to info on Kubernetes
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-28 09:10:09 -06:00
Nathan Sobo
a3640eb8d4 Correctly trace async message handling
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-28 09:09:54 -06:00
Nathan Sobo
dc28305c9f Assign tracing-related environment variables in Kubernetes
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-28 08:48:57 -06:00
Antonio Scandurra
64ecfcd33f Merge pull request #927 from zed-industries/quad-border-visual-glitch
Correctly alpha-blend border and background in quad SDF
2022-04-28 16:36:51 +02:00
Antonio Scandurra
7ec5c04fdf Correctly alpha-blend border and background in quad SDF 2022-04-28 13:54:18 +02:00
Antonio Scandurra
0bb889afec Merge pull request #923 from zed-industries/navigate-panic
Clip `scroll_top_row` before navigating back to it
2022-04-28 10:22:09 +02:00
Antonio Scandurra
76d6c00e0c Fix randomized collaboration tests in language 2022-04-28 10:12:10 +02:00
Max Brunsfeld
e05793b52a Remove Option from Buffer edit APIs
Previously, buffer edits represented empty strings as None
variants of an Option. Now, the edit logic just explicitly
checks for empty strings.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-27 18:00:13 -07:00
Keith Simmons
04fc1d5982 Building, but failing test WIP 2022-04-27 17:25:38 -07:00
Max Brunsfeld
e88156645d Update the styling of the lsp status indicator 2022-04-27 16:48:33 -07:00
Nathan Sobo
6ef2d0fbec Trace handling of messages 2022-04-27 15:27:01 -06:00
Nathan Sobo
2db670308b Allow tracing level to be customized 2022-04-27 15:26:54 -06:00
Max Brunsfeld
a3700e0dd8 Combine diagnostic status w/ diagnostic message indicators
Improve the indicator styling
2022-04-27 14:25:39 -07:00
Max Brunsfeld
9e87be722e Start re-styling diagnostic indicator in status bar 2022-04-27 14:25:39 -07:00
Nate Butler
b23ff7c3ad Update semantic status colors in all themes
- for `ok`, `error`, `warning` and `info`:
  - backgroundColor values were all placeholder. Add real values
  - Update border values to new style
2022-04-27 14:25:39 -07:00
Max Brunsfeld
68a7f99c14 Update sidebar toggle icons 2022-04-27 14:25:39 -07:00
Max Brunsfeld
7f63ed3835 Allow styling sidebar icons and groups in themes 2022-04-27 14:25:39 -07:00
Max Brunsfeld
0291f2d54a Move sidebar toggle buttons to the status bar 2022-04-27 14:25:39 -07:00
Max Brunsfeld
53ef9b997f Merge pull request #925 from zed-industries/sort-refactor-multibuffers
Sort buffers by their path in refactor multi-buffers
2022-04-27 14:25:19 -07:00
Max Brunsfeld
3ad13bdd4f Display buffers in order of their path in refactor multibuffers
Previously, they were non-deterministically ordered via a HashMap iterator.
This was causing integration tests to fail spuriously on PRs.
2022-04-27 14:01:37 -07:00
Nathan Sobo
6a21a0f6b8 Wire up tracing crate to opentelemetry
Still need to

- Set a trace level and target via environment to avoid massive noise from other libraries
- Trace the operations we care about
2022-04-27 11:48:43 -06:00
Nathan Sobo
36b462182b Send telemetry to Honeycomb via GRPC
We updated the core-foundation crates because Tonic (the GRPC crate) relies on a newer version of core foundation to find TLS root certificates.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-27 09:58:55 -06:00
Nathan Sobo
2db20c4364 Introduce opentelemetry to collab
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-27 17:01:20 +02:00
Antonio Scandurra
c9478cab09 Don't panic when navigation data contains invalid anchors and/or points
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-27 16:51:48 +02:00
Antonio Scandurra
cde5a45318 Clip scroll_top_row before navigating back to it
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-27 16:25:26 +02:00
Antonio Scandurra
27e693d8f7 Merge pull request #922 from zed-industries/authenticate-after-showing-window
Attempt to automatically sign in after a window has been shown on startup
2022-04-27 14:17:44 +02:00
Antonio Scandurra
df69ac42fb Attempt to automatically sign in after a window has been shown 2022-04-27 13:53:16 +02:00
Antonio Scandurra
19a48a43c7 Merge pull request #919 from zed-industries/remove-async-std
Remove remaining `async-std` dependencies from `collab`
2022-04-27 13:22:53 +02:00
Antonio Scandurra
0e1e5b7d55 Make following redirects explicit in HttpClient::get 2022-04-27 13:14:45 +02:00
Nathan Sobo
78afbb3599 Remove async-std and surf from client
Switch to isahc library. It's not as fancy, but it works and has a smaller footprint.
2022-04-26 21:19:15 -06:00
Nathan Sobo
1293b21b2d Get db tests passing with Tokio Postgres adaptor
We now run tests that interact with the real database under a Tokio reactor. We make the tests run multi-threaded so we can block on the main thread on database teardown and still make progress actually tearing down the DB.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-26 13:30:21 -06:00
Antonio Scandurra
b4ae2b20a0 Remove remaining async-std dependencies from collab 2022-04-26 19:47:40 +02:00
Antonio Scandurra
dec88a42e7 Merge pull request #918 from zed-industries/tokio
Switch collab server to Tokio/Axum
2022-04-26 19:30:11 +02:00
Nathan Sobo
e2a92f4a86 Merge remote-tracking branch 'origin/main' into tokio 2022-04-26 11:16:35 -06:00
Nathan Sobo
2adb9fe472 Get zed.dev working with new collab backend
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-26 11:15:41 -06:00
Nathan Sobo
7c3bdf91d9 Merge pull request #916 from zed-industries/sort-themes
Sort themes by light/dark first and then alphabetically
2022-04-26 08:18:29 -06:00
Nathan Sobo
2ae2daefe1 Merge pull request #917 from zed-industries/titlebar-design
Implement titlebar design
2022-04-26 08:17:48 -06:00
Antonio Scandurra
c955645bc0 Update share icon and swap its posiiton 2022-04-26 14:35:13 +02:00
Antonio Scandurra
9d6a7a83a0 Show worktree root names in titlebar and align them left 2022-04-26 13:21:58 +02:00
Antonio Scandurra
bf27edfdee Sort themes by light/dark first and then alphabetically 2022-04-26 12:09:25 +02:00
Antonio Scandurra
d8eb749640 Commit v0.30.0 version to Cargo.lock 2022-04-26 12:09:04 +02:00
Nathan Sobo
be040b60b7 WIP 2022-04-25 20:21:43 -06:00
Nathan Sobo
3938f7c364 Fix compile error 2022-04-25 20:12:32 -06:00
Nathan Sobo
2bd08a7b3f Validate API token for all API routes 2022-04-25 20:10:14 -06:00
Nathan Sobo
538fc23a77 WIP 2022-04-25 20:05:09 -06:00
Nathan Sobo
35bec69fa4 Finish adding API routes
We haven't tested them yet.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-25 17:51:13 -06:00
Max Brunsfeld
9c03670d21 v0.30.0 2022-04-25 16:17:25 -07:00
Max Brunsfeld
5ec30323b8 Merge pull request #913 from zed-industries/update-themes
Add sulphurpool theme, update solarized
2022-04-25 16:16:56 -07:00
Nate Butler
a2591ce1e2 Create common base16 theme constructor
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-25 19:11:38 -04:00
Max Brunsfeld
e86152dc87 Merge pull request #911 from zed-industries/reduce-novel-bindings
Remove some novel key bindings
2022-04-25 15:53:21 -07:00
Nate Butler
9338cd9cf8 Add cave theme
Sneaking one more in, cave is a nice cool dark theme that isn't super blue.
2022-04-25 18:19:49 -04:00
Nate Butler
a3adefcf0d Remove generated JSON for the Forest theme 2022-04-25 18:14:10 -04:00
Nate Butler
e28d1828f0 Add sulphurpool theme, update solarized
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-04-25 18:07:24 -04:00
Max Brunsfeld
5be7c354f6 Merge pull request #900 from zed-industries/completion-insert-text
Respect lsp completions' 'insert_text' property when present
2022-04-25 14:36:47 -07:00
Max Brunsfeld
45922603f8 Infer completions old ranges based on the syntax tree 2022-04-25 13:14:05 -07:00
Max Brunsfeld
ec6652af73 Remove some novel key bindings
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-04-25 11:56:03 -07:00
Max Brunsfeld
065734e1de Merge pull request #898 from zed-industries/track-window-focus
Focus/blur views when application windows become active/inactive
2022-04-25 08:54:47 -07:00
Nathan Sobo
cb9d608e53 WIP
Continue adding in more API routes
2022-04-24 18:02:14 -06:00
Nathan Sobo
e30a3956d6 WIP: Switch to axum 2022-04-24 11:08:25 -06:00
Nathan Sobo
62f7c858e3 WIP 2022-04-24 10:45:20 -06:00
Nathan Sobo
ac6880b6ee Only set the cursor style once per mouse move event
This will hopefully prevent some of the intermittent flickering we seem to be seeing.
2022-04-22 18:57:49 -06:00
Nathan Sobo
f7f4aad00f WIP 2022-04-22 18:46:31 -06:00
Keith Simmons
5ab21cc0fd Merge pull request #891 from zed-industries/solarized
Add solarized dark and light syntax themes
2022-04-22 15:13:52 -07:00
Max Brunsfeld
e8d263274c Remove duplication between windowDid{Become,Resign}Key callbacks 2022-04-22 15:06:50 -07:00
Keith Simmons
50b5b56f60 Update solarized theme to match main 2022-04-22 15:04:45 -07:00
Max Brunsfeld
6b9e93ac6d Fix double-borrow crash by calling window activated callback asynchronously 2022-04-22 15:01:19 -07:00
Keith Simmons
a1576b7dca fix solarized element backgrounds 2022-04-22 14:58:45 -07:00
Keith Simmons
533ba474f1 Add some comments to the theme.ts explaining the logic behind them 2022-04-22 14:58:45 -07:00
Keith Simmons
d0ee686e09 add solarized dark and light syntax themes 2022-04-22 14:58:45 -07:00
Max Brunsfeld
8ddc7e6458 Respect lsp completions' 'insert_text' property when present
Fixes #839
2022-04-22 14:33:13 -07:00
Keith Simmons
c61ae6f31f Merge pull request #877 from zed-industries/misc-normal-commands
Add inclusive vs exclusive motions to vim mode
2022-04-22 14:25:56 -07:00
Max Brunsfeld
d12df4224a Merge pull request #894 from zed-industries/typescript-outline-fixes
Fix missing TypeScript outline entries and breadcrumbs
2022-04-22 14:21:46 -07:00
Max Brunsfeld
7f64076f8d Focus/blur views when application windows become active/inactive 2022-04-22 14:18:50 -07:00
Max Brunsfeld
bfec9e1ec2 Fix missing TypeScript outline entries and breadcrumbs 2022-04-22 13:49:03 -07:00
Max Brunsfeld
f881c2aa92 Merge pull request #892 from zed-industries/syntax-theme-fixes
Syntax theme fixes
2022-04-22 13:24:31 -07:00
Max Brunsfeld
03d7035630 Avoid spurious highlight runs in Language::highlight_text 2022-04-22 13:13:54 -07:00
Max Brunsfeld
d330f909e6 Allow each theme to style all aspects of syntax highlighting
Previously, some syntax highlights were controlled in editor.ts,
and shared across all themes.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-22 12:43:01 -07:00
Nathan Sobo
447c1d2f71 WIP: Get compiling with Tokio by commenting almost everything
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-22 13:33:19 -06:00
Nathan Sobo
ddc45eb24e Merge pull request #889 from zed-industries/cursor-style-revamp
Apply cursor styles during paint and make editor's cursor an I-Beam
2022-04-22 13:20:31 -06:00
Max Brunsfeld
f0c6a6ad18 Highlight punctuation uniformly in all supported languages
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-22 12:16:49 -07:00
Max Brunsfeld
6658fa58c0 Update languages' highlight mapppings when the theme changes
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-22 12:09:14 -07:00
Nathan Sobo
92f040df00 Apply cursor styles during paint
This makes the editor's cursor an IBeam and properly deals with nested cursor styles.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-22 10:54:18 -06:00
Antonio Scandurra
53bf7b61c0 Merge pull request #887 from zed-industries/fix-typescript-rename
Use document highlights to prepare rename if LSP doesn't support it
2022-04-22 16:37:13 +02:00
Antonio Scandurra
a2279422f5 Fix rpc::tests::test_collaborating_with_renames 2022-04-22 16:29:28 +02:00
Antonio Scandurra
63cdf61c53 Fix Project::test_rename 2022-04-22 15:59:20 +02:00
Antonio Scandurra
1dcaec7fb4 Merge pull request #886 from zed-industries/fix-delete-to-beginning-of-line
Delete selected text when deleting to beginning of line, regardless of selection direction
2022-04-22 15:55:51 +02:00
Antonio Scandurra
5e16adc6c9 Use document highlights to prepare rename if LSP doesn't support it 2022-04-22 15:43:57 +02:00
Antonio Scandurra
f91fdd2ba0 Return None when prepare rename is not available on language server 2022-04-22 15:43:23 +02:00
Nathan Sobo
8ec2b5e359 Delete selected text when deleting to beginning of line 2022-04-22 06:04:14 -06:00
Nathan Sobo
30f2604a8d Map shift-backspace to backspace
A user pointed out that it was weird that this didn't work and violated their muscle memory.
2022-04-22 06:04:12 -06:00
Antonio Scandurra
b355b5c1fb Merge pull request #884 from zed-industries/show-project-browser-when-opening-folder
Show project browser when opening folder
2022-04-22 12:04:53 +02:00
Antonio Scandurra
3def7a6803 Avoid flicker when toggling project browser on workspace open 2022-04-22 11:53:45 +02:00
Antonio Scandurra
9730213ed7 Move project browser toggling logic in workspace::open_paths 2022-04-22 11:25:23 +02:00
Antonio Scandurra
bba65e120d Add only one worktree when running zed /dir /dir/file 2022-04-22 11:06:17 +02:00
Antonio Scandurra
9d8e3f51c8 Show project panel when opening a folder via the CLI 2022-04-22 10:45:46 +02:00
Antonio Scandurra
67c55255fa Merge pull request #883 from zed-industries/humanize-underscores
Replace underscores with spaces when humanizing action names
2022-04-22 10:30:17 +02:00
Antonio Scandurra
033d000489 Replace underscores with spaces when humanizing action names 2022-04-22 10:24:12 +02:00
Max Brunsfeld
a9e1f6cb8a Merge pull request #876 from zed-industries/highlight-toml
Add syntax highlighting for TOML
2022-04-21 16:54:44 -07:00
Keith Simmons
5ea782de21 Add inclusive vs exclusive motions to vim mode 2022-04-21 16:50:23 -07:00
Max Brunsfeld
3a878c8d6c Add syntax highlighting for TOML 2022-04-21 16:39:49 -07:00
Max Brunsfeld
0c587ae73c Merge pull request #875 from zed-industries/keymap-improvements
Keymap improvements
2022-04-21 15:38:43 -07:00
Max Brunsfeld
14cf51638c 🎨 Tweak order of default key bindings 2022-04-21 15:28:15 -07:00
Max Brunsfeld
490b65b55f Reuse Confirm action in chat panel, go-to-line, and project search 2022-04-21 15:24:05 -07:00
Max Brunsfeld
915ba91888 Allow toggling line comments in JSON 2022-04-21 14:12:17 -07:00
Max Brunsfeld
d43f194342 Organize default key bindings into categories 2022-04-21 14:07:14 -07:00
Max Brunsfeld
066b4faf61 Restructure KeyMap file, make it easy to edit in Zed
Add a JSON schema for this file so that autocomplete can be used for the actions.
2022-04-21 13:35:10 -07:00
Max Brunsfeld
f52050a9ec Use the 'jsonc' language id for all JSON files
This way, comments are allowed by the language server.
2022-04-21 12:08:16 -07:00
Max Brunsfeld
3a28f09979 Allow comments in setting and keymap JSON files 2022-04-21 11:58:18 -07:00
Max Brunsfeld
066e572767 Merge pull request #864 from zed-industries/polish-project-panel
Sort directories before files in a case-insensitive manner
2022-04-21 11:48:04 -07:00
Max Brunsfeld
f9cd1b25d5 Merge pull request #866 from zed-industries/max-line-len-2
Always wrap lines that are wider than 512 em advances
2022-04-21 11:23:29 -07:00
Antonio Scandurra
5081eafa9d Always wrap lines that are wider than 512 em advances
We went with a more conservative upper bound so that the number of
characters (hopefully) never exceeds `MAX_LINE_LEN` (1024) when laying
out text.

Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-04-21 19:29:37 +02:00
Nathan Sobo
e52fad0fc7 Merge pull request #865 from zed-industries/remove-web-frontend
Remove web frontend from collab server
2022-04-21 11:17:21 -06:00
Nathan Sobo
c394b08b8a Fix path in migrator image 2022-04-21 11:02:07 -06:00
Nathan Sobo
23b5a80391 Fix paths in deploy-migrations script 2022-04-21 11:01:02 -06:00
Nathan Sobo
e63ebc5b24 Drop signups table 2022-04-21 10:59:13 -06:00
Nathan Sobo
396e4ba17b Remove signups-related methods from Db trait 2022-04-21 10:55:32 -06:00
Nathan Sobo
8ed1598346 Remove tailwind and related scripts 2022-04-21 10:01:56 -06:00
Nathan Sobo
0cf7bba483 Remove remaining bits of web front-end 2022-04-21 09:30:08 -06:00
Nathan Sobo
9f83417b58 Remove more files supporting the old web front-end 2022-04-21 09:06:34 -06:00
Nathan Sobo
9f0b044ba0 Remove more unused code related to GitHub auth and errors 2022-04-21 08:57:49 -06:00
Antonio Scandurra
953256b128 Sort (case-insensitive) directories before files 2022-04-21 15:08:45 +02:00
Antonio Scandurra
11828040cc Store visible entries in project panel by id rather than offset 2022-04-21 13:37:57 +02:00
Antonio Scandurra
80b4324807 Merge pull request #735 from zed-industries/auto-update
Introduce automatic updates
2022-04-21 12:20:22 +02:00
Antonio Scandurra
fb87bacc7e Merge branch 'main' into auto-update 2022-04-21 09:53:06 +02:00
Max Brunsfeld
9d3048ebe7 v0.29.0 2022-04-20 16:10:07 -07:00
Max Brunsfeld
b07b08862b Merge pull request #863 from zed-industries/fix-project-symbols-crash
Fix project symbols crash
2022-04-20 16:09:25 -07:00
Max Brunsfeld
3619d4c1c4 Always notify a Picker when its delegate notifies 2022-04-20 16:03:11 -07:00
Max Brunsfeld
84df1d6564 Add unit test for project symbols that demonstrates crash 2022-04-20 16:02:37 -07:00
Nathan Sobo
9150b77471 Remove some user-facing routes 2022-04-20 15:39:39 -06:00
Keith Simmons
b1f9d9d8ba Merge pull request #851 from zed-industries/vim-delete-jk-fix
Linewise motions fix
2022-04-20 14:34:05 -07:00
Nate Butler
7bc6f8b5ee Build tokens for Figma 2022-04-20 15:30:33 -04:00
Nate Butler
09634dffb8 Merge pull request #846 from zed-industries/update-themes-04-19
Update theme for command palette, inputs, tabs, autocomplete
2022-04-20 12:05:00 -04:00
Nate Butler
ea11f2e183 Increase min-width for all Pickers, minor style changes
- Increases the Picker min-width from 500 to 540
- Makes some changes to the styling of keyboard shortcuts in the command palette
2022-04-20 11:54:57 -04:00
Antonio Scandurra
1da515010b Merge pull request #859 from zed-industries/cli
Add a zed command-line tool
2022-04-20 17:49:08 +02:00
Antonio Scandurra
a210b05d00 Remove App::on_open_files, as it's a subset of on_open_urls
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:36:27 +02:00
Antonio Scandurra
d725876e64 💄
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:36:03 +02:00
Antonio Scandurra
07562c2ccd Locate app bundle based on location of CLI binary
The app bundle can also be specified via `-b` or `--bundle-path`.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:29:12 +02:00
Antonio Scandurra
f77239bd96 Add application menu to install CLI
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:29:10 +02:00
Antonio Scandurra
926c75dadf Implement zed --version
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:28:31 +02:00
Antonio Scandurra
5ab35bd6fd Remove stray dbg 2022-04-20 17:28:31 +02:00
Antonio Scandurra
f7055c2acc Implement zed --wait 2022-04-20 17:28:31 +02:00
Antonio Scandurra
b013b1ba5d Call language::init_test in test_single_file_worktrees_diagnostics 2022-04-20 17:28:31 +02:00
Antonio Scandurra
b3f2b7a92c Use osascript to escalate privileges and copy the CLI to /usr/local/bin 2022-04-20 17:28:30 +02:00
Max Brunsfeld
0d9a0e2cbe Avoid permissions error when installing CLI symlink 2022-04-20 17:27:33 +02:00
Max Brunsfeld
fbd1afc51f Add a command for installing the CLI 2022-04-20 17:27:33 +02:00
Max Brunsfeld
eee1cec3d4 🎨 Remove unnecessary JoinProjectParams struct 2022-04-20 17:27:33 +02:00
Max Brunsfeld
184a454f6f Update bundle script to include fat CLI binary 2022-04-20 17:27:33 +02:00
Max Brunsfeld
a81f7ebbf6 Locate the Zed app from the CLI using NSWorkspace API 2022-04-20 17:27:33 +02:00
Max Brunsfeld
43763fa2f8 Allow opening paths from the CLI
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-20 17:27:31 +02:00
Nathan Sobo
05c44b9414 Process incoming CLI requests on the main thread 2022-04-20 17:15:46 +02:00
Nathan Sobo
75f0326e54 Use ipc_channel crate to communicate between cli and app
We still aren't handling CLI requests in the app, but this lays the foundation for bi-directional communication.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-20 17:15:46 +02:00
Antonio Scandurra
01eb2dce24 WIP: Start on a new cli crate
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-20 17:15:45 +02:00
Antonio Scandurra
0c98168227 v0.28.1 2022-04-20 15:21:15 +02:00
Antonio Scandurra
b9511afa12 Merge pull request #860 from zed-industries/fix-more-project-diagnostics-cycles
Don't emit event when LSP reports consecutive empty diagnostics
2022-04-20 15:18:58 +02:00
Antonio Scandurra
8ef6b1d8a9 Don't emit event when LSP reports consecutive empty diagnostics
This is related to #849: in that pull request we avoided *storing*
empty diagnostics, but we'd still report an event when receiving
consecutive empty diagnostics. So if the project diagnostics editor
was open, it could happen that opening a buffer would cause the
language server to report zero diagnostics. We would therefore close
the buffer because there were no diagnostics, but doing so would cause
the LSP to report another event with zero diagnostics. This would repeat
forever, causing Zed to use a lot of CPU and the UI not to refresh properly.

With this commit we will simply avoid emitting a `DiagnosticsUpdated` event
altogether if no diagnostics were present before *and* the LSP is reporting
a `PublishDiagnostics` event with no diagnostics in it.
2022-04-20 15:02:38 +02:00
Max Brunsfeld
c2fa7b9bf9 Merge pull request #857 from zed-industries/file-finder-fixes
File finder fixes
2022-04-19 13:40:40 -07:00
Max Brunsfeld
717ebe6a4c Don't cancel match updates when picker query changes
The file finder often cancels an in-progress match task when
the project updates. But it still needs to take the matches
that it did find and add them to its results. So we should
not cancel the entire task, as this will cause the
partial results to be discarded.
2022-04-19 13:16:57 -07:00
Max Brunsfeld
47379677f2 Update file finder correctly when project files change 2022-04-19 13:10:36 -07:00
Keith Simmons
8ff0277103 Handle linewise motions correctly and fix panic when executing invalid actions 2022-04-19 11:36:44 -07:00
Nathan Sobo
93d307aecb Navigate to best match when updating outline view query
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-04-19 10:12:42 -06:00
Nathan Sobo
360b876f36 v0.28.0
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-19 09:40:32 -06:00
Antonio Scandurra
e8728f4ce2 Merge pull request #849 from zed-industries/fix-project-diagnostic-ui-glitch
Remove summaries that don't contain any errors or warnings
2022-04-19 17:13:32 +02:00
Antonio Scandurra
ef784cf21e Remove summaries that don't contain any errors or warnings
When opening a buffer, some language servers might start reporting
diagnostics. When closing a buffer, they might report that no diagnostics
are present for that buffer. Previously, we would keep an empty summary entry
which would cause us to open a buffer in the project diagnostics view, only to
drop it because it contained no diagnostics. However, the act of opening it
caused the language server to asynchronously report non-empty diagnostics.
We would therefore handle this as an update, but the previous closing of the
buffer would cause the language server to report empty diagnostics again. This
would cause the project diagnostics view to thrash infinitely between these two
states, pegging the CPU and constantly refreshing the UI.

With this commit we won't maintain empty summary entries for files that contain
no diagnostics, which fixes the above issue.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-19 15:30:46 +02:00
Antonio Scandurra
1cd23df4d8 Merge pull request #848 from zed-industries/out-of-sync-diagnostics
Use the entire `ProjectPath` to find open buffer for an LSP diagnostic
2022-04-19 13:03:19 +02:00
Antonio Scandurra
eaa6637b05 Use the entire ProjectPath to find open buffer for an LSP diagnostic
Previously, we would only compare the path relative to the worktree root, which
would cause Zed to sometimes update diagnostics on the wrong buffer. This
manifested in the project diagnostics not showing those errors/warnings while
the status bar and the tab title displayed a summary with errors/warnings.

This commit simply uses `Project::get_open_buffer` which correctly locates a
buffer with the given project path.
2022-04-19 12:06:14 +02:00
Nate Butler
484204c2a0 Reduce key icon size to avoid extra padding on command palette item
- Also remove unneeded imports
2022-04-19 02:48:35 -04:00
Nate Butler
408f8d4297 Update inputs, tabs, pickers, autocomplete 2022-04-19 02:34:45 -04:00
Max Brunsfeld
d99c74d874 Merge pull request #823 from zed-industries/command-palette
Command palette
2022-04-18 18:24:31 -07:00
Max Brunsfeld
0af129d50a Use primary text color for keystrokes in command palette 2022-04-18 18:14:45 -07:00
Max Brunsfeld
d8ad0d8e4e Format action names more readably in command palette
Also add a unit test for the command palette
2022-04-18 18:12:43 -07:00
Max Brunsfeld
a4f259066b tmp 2022-04-18 17:30:17 -07:00
Max Brunsfeld
11eba96cb8 Allow toggling other modals from the command palette 2022-04-18 17:11:39 -07:00
Max Brunsfeld
f5377c2f50 Highlight fuzzy match positions in command palette 2022-04-18 17:11:39 -07:00
Max Brunsfeld
3bbc021a7e Use Picker in Outline view 2022-04-18 17:11:39 -07:00
Max Brunsfeld
c56e2ead23 Fix hang when dropping ::scoped future under deterministic executor
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-18 17:11:39 -07:00
Max Brunsfeld
df0b5779a8 Remove unused crossbeam-channel dependency in zed crate
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-18 17:11:39 -07:00
Max Brunsfeld
d0413ac0e1 Fix crash when dropping a task that is awaiting a call to Background::scoped
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-18 17:11:39 -07:00
Max Brunsfeld
20657566b3 Make all pickers respect mouse clicks 2022-04-18 17:11:39 -07:00
Max Brunsfeld
c7527f92a4 Use Picker in FileFinder 2022-04-18 17:11:39 -07:00
Max Brunsfeld
c75ffc583c Use Picker in ProjectSymbolsView 2022-04-18 17:11:39 -07:00
Max Brunsfeld
7b16860806 Use Picker in ThemeSelector 2022-04-18 17:11:39 -07:00
Max Brunsfeld
7964464e3d Rename SelectorModal -> Picker, put it in its own crate 2022-04-18 17:11:39 -07:00
Max Brunsfeld
bde52d5c93 Add basic styling to keystrokes in command palette 2022-04-18 17:11:37 -07:00
Max Brunsfeld
3901d9d544 Display key bindings in the command palette
They still need to be styled.

Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-04-18 17:11:08 -07:00
Max Brunsfeld
4630071f58 Start work on a command palette 2022-04-18 17:11:08 -07:00
Max Brunsfeld
99f8466cb5 Add a gpui method for listing the available actions 2022-04-18 17:11:07 -07:00
Nate Butler
2a72c618b8 Merge pull request #833 from zed-industries/update-dark-theme-feature-color
update feature color in dark theme
2022-04-18 19:35:42 -04:00
Keith Simmons
5c6a2ac7e6 Merge pull request #812 from zed-industries/js-jsx-language
Add javascript and jsx specific languages
2022-04-18 16:19:54 -07:00
Keith Simmons
26f2aa4d69 Swap to parsing javascript as jsx 2022-04-18 15:26:57 -07:00
Keith Simmons
eb77976c9f Merge pull request #825 from zed-industries/vim-change-delete
Add c and d operators to vim normal mode
2022-04-18 15:21:58 -07:00
Keith Simmons
dd25ab5798 Revert d/c j and k binding special casing 2022-04-18 14:44:11 -07:00
Keith Simmons
dcd5922609 Merge jsx language into js 2022-04-18 14:21:23 -07:00
Nate Butler
ec704cae25 update feature color in dark theme 2022-04-17 22:37:08 -04:00
Keith Simmons
63278041e1 Add c and d operators to vim normal mode
Extracted motions from normal mode
Changed vim_submode to be vim_operator to enable better composition of operators
2022-04-15 16:05:50 -07:00
Nathan Sobo
670757e5c9 Merge pull request #824 from zed-industries/fix-cursor-hidden-after-rename
Always clear rename state when selections change
2022-04-15 15:22:07 -06:00
Antonio Scandurra
2695b13947 Always clear rename state when selections change
At some point during the implementation of rename, we added logic for
invalidating the rename state when the selection moved outside the original
rename range. After transitioning to displaying renames as a block decoration,
we don't need that anymore given that a new, temporary editor is used instead.

This commit removes that invalidation logic and always calls `Editor::take_rename`
when the editor selections change. Doing so also fixes a bug that was causing Zed
to hide the cursor when clicking on the editor to dismiss the rename.
2022-04-15 10:32:07 +02:00
Nathan Sobo
9820c6ba64 Merge pull request #822 from zed-industries/focus-project-search-query
Fix focus bugs in `ProjectSearchView`
2022-04-14 12:25:59 -06:00
Max Brunsfeld
3cdda79fc3 Merge pull request #817 from zed-industries/dynamic-editor-highlights
Store accessors for editor highlight colors not colors themselves
2022-04-14 10:36:38 -07:00
Antonio Scandurra
77d3cc359e Fix tests 2022-04-14 18:50:45 +02:00
Antonio Scandurra
ce3a31d8bd Persist project search focus state
...so that we can re-focus the previously-active editor when switching back
to the project search tab.
2022-04-14 18:36:42 +02:00
Antonio Scandurra
5a8297a02f Introduce ViewContext::observe_focus 2022-04-14 18:22:55 +02:00
Nathan Sobo
27057fdb1b Only process a single focus effect per batch
This allows us to focus the query editor of the project search when deploying it. Previously, a complex interplay between focus events was preventing this from working in an intuitive way. What happened previously:

- We'd activate the project search, which enqueued a focus effect for the project search view
- We'd focus the query editor, which enqueued an effect
- We'd process the focus effect for the search view, which would enqueue an effect to transfer focus to the results editor
- We'd process the effect to focus the query editor
- We'd process the effect to focus the results editor

Now...

- We activate the project search pane item, enqueuing a focus effect for the project search itself
- We focus the query editor and *remove* the previous pending focus change effect
- We process the focus effect
2022-04-14 08:52:24 -06:00
Nathan Sobo
c4203868ea Revert "Focus Project Search query editor always when deployed" 2022-04-14 07:53:15 -06:00
Antonio Scandurra
c4e0307c0b Merge pull request #820 from zed-industries/optimize-line-len
Speed up `WrapSnapshot::line_len` using the indexed transforms
2022-04-14 13:10:09 +02:00
Antonio Scandurra
6d33697e82 Fix warning 2022-04-14 13:03:46 +02:00
Antonio Scandurra
1a1d670104 Speed up WrapSnapshot::line_len using the indexed transforms 2022-04-14 13:01:29 +02:00
Antonio Scandurra
91d4c835ad Introduce TabMap::line_len 2022-04-14 12:55:33 +02:00
Max Brunsfeld
e1b4bbfcf1 Merge pull request #815 from zed-industries/stale-search-match-count
Notify when buffer search matches change
2022-04-13 15:41:30 -07:00
Max Brunsfeld
efa6af427d Merge pull request #816 from zed-industries/render-icon-panic
Don't panic when allocating tiny_skia pixmap
2022-04-13 15:31:47 -07:00
Keith Simmons
292d075f81 Store accessors for editor highlight colors not colors themselves 2022-04-13 15:30:57 -07:00
Max Brunsfeld
08e55f77b8 Merge pull request #814 from zed-industries/nav-history-scroll-position
Record scroll position in nav history
2022-04-13 15:23:53 -07:00
Keith Simmons
4b55b578b2 Don't panic when allocating tiny_skia pixmap 2022-04-13 14:57:16 -07:00
Keith Simmons
b893cb6d82 rename NavigationData anchor and offset to cursor_anchor and cursor_offset 2022-04-13 14:53:47 -07:00
Keith Simmons
8cde15cb72 Notify when buffer search matches change 2022-04-13 14:49:18 -07:00
Max Brunsfeld
031472dc5a 0.27.0 2022-04-13 14:00:09 -07:00
Keith Simmons
9cec6d8d65 add comment explaining offsets 2022-04-13 13:30:07 -07:00
Nathan Sobo
6985d360c8 Merge pull request #811 from zed-industries/font-fallback-3
Implement font fallback and emoji rendering
2022-04-13 14:08:57 -06:00
Keith Simmons
f20e3f35a1 Record scroll position in nav history 2022-04-13 12:30:33 -07:00
Max Brunsfeld
394d0b4cab Merge pull request #813 from zed-industries/fix-missing-bindings
Add back key bindings that were removed accidentally
2022-04-13 11:25:01 -07:00
Max Brunsfeld
2ea2ba358f Add back toggle sidebar key bindings 2022-04-13 11:14:10 -07:00
Keith Simmons
544ca443e3 Add javascript and jsx specific languages 2022-04-13 10:58:42 -07:00
Max Brunsfeld
1e0182f6c7 Add back key binding for confirming completions with tab 2022-04-13 10:35:05 -07:00
Antonio Scandurra
8e89074714 Reduce allocations when caching fonts
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-13 19:06:34 +02:00
Max Brunsfeld
847322215e 0.26.0 2022-04-13 09:34:42 -07:00
Antonio Scandurra
cdcdccfb89 Render emojis
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-13 17:31:10 +02:00
Antonio Scandurra
fff1d9c631 Implement glyph scaling in a way that works with emojis as well 2022-04-13 15:56:32 +02:00
Keith Simmons
4249b5687e Implement font fallback in layout_line
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-04-13 11:42:19 +02:00
Antonio Scandurra
6cc9306f00 Make room for font subpixel variants correctly 2022-04-13 11:36:54 +02:00
Antonio Scandurra
6b629dfa5c Use CTFont::draw_glyphs to rasterize glyphs
This API supports rendering emojis in addition to normal glyphs.
2022-04-12 19:37:26 +02:00
Nate Butler
fb33378040 Merge pull request #804 from zed-industries/update-theme-feature-colors
Update theme feature colors
2022-04-12 13:36:52 -04:00
Nate Butler
726045e78e Update theme feature colors
- border focus color
- Text feature color
- Match & active match highlight color

Matches should be more legible now in both themes. `activeMatch` is still not hooked up on the rust side, so it won't take any effect yet.

Co-Authored-By: gibusu <95764254+gibusu@users.noreply.github.com>
2022-04-12 12:44:38 -04:00
Nate Butler
409b818717 Fix incorrect path in theme build script
`buildThemes.ts` had an incorrect path for generating the theme json files.

It probably happened when we did some reorganization of the styles directory.

Co-Authored-By: gibusu <95764254+gibusu@users.noreply.github.com>
2022-04-12 12:37:38 -04:00
Antonio Scandurra
00fb5755a3 Merge pull request #802 from zed-industries/update-contacts-on-share
Update contacts list when a project is shared
2022-04-12 11:48:34 +02:00
Antonio Scandurra
4e057da69b Update contacts list when a project is shared 2022-04-12 11:41:20 +02:00
Antonio Scandurra
d17e9c071b Merge pull request #801 from zed-industries/randomized-test-improvements
Introduce guest disconnection in randomized collaboration test
2022-04-12 11:25:07 +02:00
Antonio Scandurra
71beebc913 Fix warning 2022-04-12 10:52:16 +02:00
Antonio Scandurra
1d84876cfd Adjust distribution in randomized test 2022-04-12 10:15:38 +02:00
Antonio Scandurra
3e4bc75160 Merge branch 'main' into randomized-test-improvements 2022-04-12 10:14:08 +02:00
Antonio Scandurra
56b9e5b0a0 Make Server::update_contacts_for_users always synchronous 2022-04-12 09:44:23 +02:00
Antonio Scandurra
c06e5f3d1e Limit incoming size to 1 in tests to more easily simulate backpressure 2022-04-12 09:43:36 +02:00
Max Brunsfeld
6317c049c5 Merge pull request #800 from zed-industries/tolerate-lsp-workspace-symbols-failure
Avoid bailing out of Project::symbols when one LSP request fails
2022-04-11 21:14:51 -07:00
Max Brunsfeld
ae9f71cc07 Avoid bailing out of Project::symbols when one LSP request fails 2022-04-11 21:09:01 -07:00
Max Brunsfeld
aa37c364bb Merge pull request #799 from zed-industries/debug-project-diagnostics-as-json
Allow dumping the project diagnostic view's state as JSON
2022-04-11 20:40:50 -07:00
Nathan Sobo
e9214dc05d Merge pull request #785 from zed-industries/collab-renames
Rename zed-server to collab
2022-04-11 20:56:37 -06:00
Max Brunsfeld
949fbe7cd3 Allow dumping the project diagnostic view's state as JSON
Also, improve DebugElements action so that it shows the JSON in an editor.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-04-11 19:51:46 -07:00
Nathan Sobo
d8e4e924cc Merge branch 'main' into collab-renames 2022-04-11 19:07:07 -06:00
Max Brunsfeld
54d49c13d9 Merge pull request #795 from zed-industries/cancel-buffer-search
Handle editor cancel in pane in order to dismiss find toolbar
2022-04-11 17:47:44 -07:00
Max Brunsfeld
a754c3015f Merge pull request #762 from zed-industries/safer-atlas-allocation
Safer Atlas Allocation
2022-04-11 17:42:53 -07:00
Max Brunsfeld
300feb5d57 Merge pull request #797 from zed-industries/project-search-focus
Focus Project Search query editor always when deployed
2022-04-11 17:41:08 -07:00
Max Brunsfeld
b3c64e47f1 Merge branch 'main' into cancel-buffer-search 2022-04-11 17:38:26 -07:00
Max Brunsfeld
50d5253eff Merge pull request #792 from zed-industries/fix-tsx-default-indent
Set default tsx tabsize
2022-04-11 17:35:54 -07:00
Keith Simmons
1d8afdff80 Set tsx default indent to 2 and remove js from extension list in tsx config.toml 2022-04-11 17:34:44 -07:00
Nathan Sobo
5a5506ae1d Update certificate 2022-04-11 18:33:55 -06:00
Max Brunsfeld
25e1e3d2df Merge pull request #786 from zed-industries/load-keymaps
Allow key bindings to be customized via a JSON file
2022-04-11 17:31:22 -07:00
Max Brunsfeld
2807d85a60 Merge pull request #791 from zed-industries/project-search-focus-fix
Properly activate project search item on mouse click
2022-04-11 17:31:06 -07:00
Nathan Sobo
72ea71ca52 Update paths to renamed collab crate 2022-04-11 18:18:12 -06:00
Max Brunsfeld
add0dad6d7 Use '*' to represent the default context in keymap files
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-11 17:17:03 -07:00
Nathan Sobo
3b852ee2bd Update Kubernetes manifest to refer to "collab" instead of "zed" 2022-04-11 18:15:41 -06:00
Keith Simmons
28da5b4afc Don't focus active editor when deploying project search and focus query editor on project search focus 2022-04-11 17:05:24 -07:00
Max Brunsfeld
ee3eb9658f Use the word 'keymap' more consistently
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-11 17:02:16 -07:00
Max Brunsfeld
be11f63f1e Watch ~/.zed/bindings.json file for custom key bindings
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-11 16:50:44 -07:00
Max Brunsfeld
92a5c30389 Merge branch 'main' into load-keymaps 2022-04-11 15:55:10 -07:00
Max Brunsfeld
c065f283aa Move assets to their own crate, load keymaps in vim tests
Also, move assets folder to the top-level.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-11 15:54:52 -07:00
Max Brunsfeld
e0096ec1eb Move keymap_file module into settings crate
Co-authored-by: Keith Simmons <keith@zed.dev
2022-04-11 15:22:18 -07:00
Keith Simmons
4b295f566a Handle editor cancel in pane in order to dismiss find toolbar 2022-04-11 15:11:23 -07:00
Keith Simmons
0ca4c9946a Add logging when atlas allocator fails to allocate 2022-04-11 10:31:38 -07:00
Antonio Scandurra
3844634765 Hold the state lock while responding to guest joining a project
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-11 19:30:52 +02:00
Keith Simmons
7abd3a98a8 Make atlas allocation fallable and skip rendering icons and paths when it fails 2022-04-11 10:15:49 -07:00
Keith Simmons
3c116e32cb Reraise editor events in Project Search and activate workspace item from them 2022-04-11 10:13:07 -07:00
Antonio Scandurra
9a8b0388fa Replace synchronous Store lock with an async lock
This also fixes some failures due to `broadcast` and `update_contacts_for_users`
being fallible. As part of this commit, these two functions don't return `Result`
anymore: the reason for this change is that we don't want a request to fail only
because a peer disconnected while we were trying to broadcast a message to them.
2022-04-11 17:56:30 +02:00
Antonio Scandurra
273ee0ae58 Acquire guest connection ids after save request has been forwarded
This fixes a bug that would cause the server to broadcast the save
message to guests that have potentially left the project.
2022-04-11 16:27:14 +02:00
Antonio Scandurra
c3927c541f Simulate random guest disconnection and reconnection 2022-04-11 16:27:11 +02:00
Antonio Scandurra
f99a1437cd Distribute operation workload evenly across peers in randomized test
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-11 14:43:30 +02:00
Antonio Scandurra
02f96c6def Simulate parallelism among peers correctly in randomized collab test
Previously they were all using the same foreground executor, which was
not properly simulating concurrency among tasks from different peers.
2022-04-11 13:42:30 +02:00
Antonio Scandurra
bb8dc6120b Allow taking an Arc<Deterministic> in [gpui::test]-decorated tests 2022-04-11 13:42:30 +02:00
Antonio Scandurra
28f44a3252 Merge pull request #787 from zed-industries/buffer-divergence
Fix divergence bug when peer reconnects reusing a prior replica id
2022-04-11 13:34:30 +02:00
Antonio Scandurra
f9e0899e58 Fix divergence bug when peer reconnects reusing a prior replica id
We forgot to observe the footprint of the reconnecting replica's prior
undos into the local clock. This could cause the replica to generate
edits with a version strictly smaller than what other peers may have
observed. As such, those peers would think they had already seen those
edits and skip them.
2022-04-11 13:17:47 +02:00
Max Brunsfeld
9a4b8e3d8c Load all keybindings from JSON file 2022-04-10 14:29:45 -07:00
Max Brunsfeld
b4babbeeaa Load modal key bindings from JSON file 2022-04-10 11:39:43 -07:00
Max Brunsfeld
1e2eeaa22a Load project and buffer search key bindings from JSON file 2022-04-10 11:30:08 -07:00
Max Brunsfeld
3636c9ec25 Load workspace and editor key bindings from a JSON file 2022-04-10 11:18:08 -07:00
Nathan Sobo
ab8204368c Rename zed-server to collab
Over time, I think we may end up having multiple services, so it seems like a good opportunity to name this one more specifically while the cost is low. It just seems like naming it "zed" and "zed-server" leaves it a bit open ended.
2022-04-09 08:30:42 -06:00
Nathan Sobo
af674e1c00 Merge pull request #770 from zed-industries/better-settings-schema
Improve Settings Completions
2022-04-09 08:23:58 -06:00
Nathan Sobo
56fcffb634 Remove unused imports 2022-04-09 07:55:23 -06:00
Nathan Sobo
17195e615e Merge pull request #781 from zed-industries/structured-logging
Introduce structured logging
2022-04-09 07:40:24 -06:00
Max Brunsfeld
fd4b81c8fc Allow actions to be deserialized from JSON
Introduce separate macro for implementing 'internal' actions which
are not intended to be loaded from keymaps.
2022-04-08 15:47:51 -07:00
Max Brunsfeld
1778622960 Merge pull request #773 from zed-industries/namespace-actions
Change how actions are declared so that they are always associated with a namespace
2022-04-08 11:57:13 -07:00
Max Brunsfeld
ed2b690b9e Merge branch 'main' into namespace-actions 2022-04-08 11:48:43 -07:00
Nathan Sobo
8a7d3ea82a Merge pull request #778 from zed-industries/test-random-disconnect
Introduce host disconnection in randomized collaboration test
2022-04-08 11:36:39 -06:00
Nathan Sobo
b507e21831 Enable JSON logging at the trace log level in K8s
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-08 10:08:52 -06:00
Nathan Sobo
7e5a3f9f6b Introduce structured logging
We're enabling the log crate feature everywhere, but only using it on the server for now.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-08 10:06:51 -06:00
Antonio Scandurra
53a7f9c43e Introduce a timeout when processing incoming messages
We have an hypothesis that the server gets stuck while processing
an incoming message, either because the buffer fills up or because
a handler never completes. This should mitigate that and, once we
add logging, give us some clue as to what is causing it exactly.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-08 16:21:39 +02:00
Antonio Scandurra
0b1fda3e13 Remove postage from zed-server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-08 16:14:54 +02:00
Antonio Scandurra
24cb44fb00 Remove postage from rpc
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-08 16:13:37 +02:00
Antonio Scandurra
32fd4eb3ac Insert project id in connection's project during project registration
...in contrast to doing so during worktree registration. This fixes a
randomized test failure which would panic because store invariants would be
violated. This would happen when a peer disconnected before it had a chance
to register a worktree because, when removing all the state associated with
that peer upon disconnection, we would notice the registered project without
however finding it in the peer's connection state.
2022-04-08 14:41:56 +02:00
Antonio Scandurra
222cd09838 Allow host to reconnect to the server in randomized test 2022-04-08 14:41:30 +02:00
Antonio Scandurra
c994263225 Don't insert an empty vector in Project::buffer_snapshots
Other code paths rely on at least a version always being there, so
we should enforce that invariant everywhere.
2022-04-08 14:14:45 +02:00
Antonio Scandurra
663beab1b9 Avoid panicking when receiving a request for a dropped buffer 2022-04-08 12:10:45 +02:00
Antonio Scandurra
3daaef02ca Replace postage::oneshot with futures::channel::oneshot
This fixes an error in the randomized test that would cause the future
returned from `Worktree::share` to never finish due to a bug in `postage`
that causes its waker to not be notified upon drop.
2022-04-08 12:03:09 +02:00
Antonio Scandurra
da976012a9 Allow simulate_guest and simulate_host to fail when host disconnects 2022-04-08 11:29:00 +02:00
Antonio Scandurra
fae9048a2a Remove non-determinism from Peer caused by using std's HashMap 2022-04-08 11:28:19 +02:00
Keith Simmons
3e40b5bead dynamically inject theme names and language properties into schema 2022-04-07 18:15:02 -07:00
Max Brunsfeld
c801a52492 Convert some actions to use named fields
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-07 16:44:37 -07:00
Max Brunsfeld
5242a3a6dc Restructure action macro to assign a namespace to every action
Also, allow arbitrary types to be used as Actions via the impl_actions macro

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-07 16:20:49 -07:00
Keith Simmons
035cd37aa8 Add explicit types for LanguageOverrides and Themes to SettingsFileContent in order to improve completions in zed settings file 2022-04-07 16:00:51 -07:00
Max Brunsfeld
206b0f0f8c 0.25.0 2022-04-07 12:03:43 -07:00
Nathan Sobo
717f53e3d2 WIP 2022-04-07 09:29:47 -06:00
Antonio Scandurra
0b8eed64ad Merge pull request #765 from zed-industries/yield-lsp
Don't starve UI thread when rapidly receiving LSP messages
2022-04-07 17:15:19 +02:00
Nathan Sobo
80d55fd3d8 Don't starve UI thread when rapidly receiving LSP messages
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-07 08:30:42 -06:00
Nathan Sobo
7a151ffc75 Merge pull request #764 from zed-industries/refine-event-handlers-behavior
Calculate hit-box based on visible bounds in `{Mouse}EventHandler`
2022-04-07 08:16:14 -06:00
Antonio Scandurra
b396909035 Calculate hitbox based on visible bounds in {Mouse}EventHandler
This is in contrast to not dispatching the event altogether in `Flex` when
the event is not contained in the flex element bounds. That approach was
problematic because it didn't give an opportunity to `MouseEventHandler`s
to handle mouse move events when they didn't intersect with the element bounds,
causing elements to never clear their hover state, cursor style, etc.
2022-04-07 15:12:09 +02:00
Antonio Scandurra
73f2fd6b09 Pass visible bounds to Element::dispatch_event 2022-04-07 15:10:09 +02:00
Antonio Scandurra
ae415ee49b Merge pull request #763 from zed-industries/inconsistent-diagnostic-state
Fix bad diagnostic state when restarting a language server w/ a running diagnostic task
2022-04-07 09:54:00 +02:00
Antonio Scandurra
7c21b61ad9 Merge pull request #748 from zed-industries/fix-outline-panic
Don't assume there are always matches in outline view
2022-04-07 09:49:13 +02:00
Antonio Scandurra
52251c3463 Merge pull request #745 from zed-industries/scroll-tabs
Allow pane tabs to be scrolled when they overflow
2022-04-07 09:48:54 +02:00
Max Brunsfeld
f73de202d0 Fix diagnostic updates after restarting an LSP w/ a pending diagnostic job 2022-04-06 22:02:27 -07:00
Max Brunsfeld
b354af7bda Use an unbounded channel in gpui test helper methods
The bounded channel could fill up when many events were emitted in one
effect cycle.
2022-04-06 22:02:04 -07:00
Max Brunsfeld
ce547010d8 Merge pull request #759 from zed-industries/breadcrumb-multibuffer-fix
Update breadcrumbs when multibuffers' excerpts change
2022-04-06 17:21:18 -07:00
Max Brunsfeld
ec837fa6d7 Update breadcrumbs when multibuffers' excerpts change 2022-04-06 17:12:36 -07:00
Max Brunsfeld
8f38ac8270 Tweak structure of Project::on_lsp_progress so it can be auto-formatted
Previously, rustfmt seems to have given up on formatting this method.
2022-04-06 16:35:58 -07:00
Max Brunsfeld
f9e1b4de96 Merge pull request #758 from zed-industries/open-excerpts-in-same-pane
Don't activate the next pane when opening excerpts
2022-04-06 15:56:22 -07:00
Max Brunsfeld
ea63df0519 Don't activate the next pane when opening excerpts 2022-04-06 15:46:11 -07:00
Max Brunsfeld
3d8e4adcde Merge pull request #757 from zed-industries/restructure-settings
Enable language specific tab sizes
2022-04-06 15:18:13 -07:00
Keith Simmons
67b15ee037 Use language specific tabsize in editor commands
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-04-06 15:10:29 -07:00
Keith Simmons
36f4d8f9e4 Fix typescript indent size 2022-04-06 10:35:29 -07:00
Keith Simmons
1812480cbb Tab size is pulled properly from settings instead of hardcoded 2022-04-06 10:23:37 -07:00
Max Brunsfeld
866ffdd4ae Move Settings to its own crate
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-06 10:23:33 -07:00
Max Brunsfeld
664f17f92b Avoid maintaining indent size as state on buffers
Indent size is still hard-coded, but it's now controlled by the
editor and not the buffer.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-06 10:22:29 -07:00
Nathan Sobo
0214bec7f4 Don't dispatch events to flex children outside of parent flex's bounds 2022-04-06 10:59:03 -06:00
Nathan Sobo
e21f90fec5 Merge pull request #747 from zed-industries/styles-in-typescript
Style the Zed app using Typescript styleTrees and Design Tokens
2022-04-06 10:39:10 -06:00
Nate Butler
b1eda1ac39 Add border to top of status bar 2022-04-06 12:25:15 -04:00
Nate Butler
e584e892f4 Update light theme 2022-04-06 12:25:02 -04:00
Nate Butler
d3cfd1c974 Use standard text sizes for signInPrompt 2022-04-06 12:14:05 -04:00
Nathan Sobo
ca64b081fe Don't assume there are always matches in outline view 2022-04-06 09:33:47 -06:00
Nathan Sobo
c289cdcac8 💄 2022-04-06 09:28:56 -06:00
Nathan Sobo
36fede7522 💄 token-building script and output destinations
Just some organization here.
2022-04-06 09:26:51 -06:00
Nate Butler
f29b8c795e Remove message.txt 2022-04-06 11:00:25 -04:00
Antonio Scandurra
d7342e2875 Use Pane::activate_item when navigating to remove duplicated logic 2022-04-06 09:31:54 +02:00
Antonio Scandurra
1453954ef4 Autoscroll to active tab when activating a new item 2022-04-06 09:08:44 +02:00
Nate Butler
e201826d00 Update Light & Dark themes 2022-04-06 01:46:10 -04:00
Nathan Sobo
eb99588368 Remove stray dbg! expressions 2022-04-05 20:02:45 -06:00
Nathan Sobo
ab3bbe1e17 Make the tabs scrollable when they overflow
This adds the ability to make a Flex element scrollable by passing a type tag and instance id, which we use to store the scroll position in an ElementStateHandle.

Still need to allow the element to auto-scroll.
2022-04-05 19:58:15 -06:00
Nathan Sobo
025d857be8 Make UniformListState an Rc<RefCell<>> instead of an Arc<Mutex<>>
We don't need to support multiple threads.
2022-04-05 18:40:25 -06:00
Nathan Sobo
0cbcc81ed9 Merge pull request #742 from zed-industries/better-atlas-panics
Report more information when we panic due to an atlas allocation failure
2022-04-05 17:08:04 -06:00
Nate Butler
2a2c4071f4 Update light syntax theme and highlights, player selections 2022-04-05 18:49:17 -04:00
Nate Butler
35f56708f5 Update light theme, change player 3 color
- Changed player 3 color to be less similar to player 1
2022-04-05 18:23:01 -04:00
Nathan Sobo
aeb0b42c7a Report more information when we panic due to an allocation failure 2022-04-05 13:53:13 -06:00
Nathan Sobo
133d9f947b Merge pull request #740 from zed-industries/prompt-only-on-last-dirty-item
Show unsaved/conflict prompt only when closing the last tab for an item
2022-04-05 13:12:08 -06:00
Nathan Sobo
4f4364d510 Ensure we drop the last pane item
Previously, we weren't updating the toolbar's active item when emptying out a pane. This enhances an integration test to ensure that we don't hold references to any editors or buffers once we close everything.
2022-04-05 13:05:14 -06:00
Nathan Sobo
41a27e6925 💄 2022-04-05 12:09:40 -06:00
Nathan Sobo
e2bf89b1e8 Don't require a path in TestAppContext::dispatch_action
Instead, derive it from the presenter. This makes tests easier to write and more reliable since we'll be accurately simulating the actual relationship between parent and child views.
2022-04-05 12:08:25 -06:00
Nathan Sobo
3da8f7f944 Fix dispatch path in test 2022-04-05 11:55:29 -06:00
Antonio Scandurra
c3b947ca26 Show unsaved/conflict prompt only when closing the last tab for an item
Also, ensure we show the correct prompt when files have conflicts.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-05 19:38:27 +02:00
Nate Butler
d21dea6112 Squashed commit of the following:
commit 66d4cbae2ca6d7dd660688d7eb702ae55bf3e0ca
Author: Nate Butler <iamnbutler@gmail.com>
Date:   Tue Apr 5 13:33:33 2022 -0400

    WIP: Improve legibility of contactsPanel and fix errors

    Co-Authored-By: Keith Simmons <keith@the-simmons.net>

commit 000319c583801c5ba4ed7884bbf3da2a591e3f26
Author: Nate Butler <iamnbutler@gmail.com>
Date:   Tue Apr 5 13:13:32 2022 -0400

    WIP
2022-04-05 13:34:06 -04:00
Antonio Scandurra
cac0dddb1b Restructure item closing to take the Workspace instead of the Pane 2022-04-05 19:12:17 +02:00
Antonio Scandurra
939def42e3 v0.24.1 2022-04-05 16:23:27 +02:00
Antonio Scandurra
3ee84449ff Merge pull request #737 from zed-industries/lsp-renames
Improve handling of renames with respect to language servers
2022-04-05 16:22:17 +02:00
Antonio Scandurra
cc45658b2d Clear diagnostics from buffer when unregistering it from language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-05 16:01:33 +02:00
Antonio Scandurra
7e3cc67e0a Don't reuse old syntax tree when resetting a buffer's language
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-05 16:01:05 +02:00
Antonio Scandurra
5c7f2bb029 Close and re-open buffer in language server when it gets renamed 2022-04-05 15:15:43 +02:00
Antonio Scandurra
9188f51993 Add unit test to illustrate how language server renames should work 2022-04-05 14:47:37 +02:00
Antonio Scandurra
e697ffbbf0 Merge pull request #736 from zed-industries/update-followers-when-navigating
Update followers when navigating back and forth
2022-04-05 10:57:57 +02:00
Antonio Scandurra
5ef484c9a1 Update followers when navigating back and forth 2022-04-05 10:42:35 +02:00
Antonio Scandurra
4a5c49eb6e Skip checking for updates when an update has already been installed 2022-04-05 10:18:37 +02:00
Antonio Scandurra
4adb245771 💄 2022-04-05 10:16:08 +02:00
Antonio Scandurra
493450f6a8 Massage styling of auto-update messages a bit 2022-04-05 10:15:26 +02:00
Antonio Scandurra
bd0b063bd1 Display Installing update… when the new app is being copied 2022-04-05 10:07:45 +02:00
Antonio Scandurra
61c479ebc8 Pass an NSString to objectForInfoDictionaryKey 2022-04-05 10:02:37 +02:00
Max Brunsfeld
e566a8335f Find path to running app using [NSBundle bundlePath] 2022-04-04 20:53:46 -07:00
Max Brunsfeld
fb2caf3c58 Add application menu item for checking for updates 2022-04-04 18:34:14 -07:00
Max Brunsfeld
9c469f2fdb Add remaining logic for downloading updates, add status bar indicator 2022-04-04 18:34:14 -07:00
Nathan Sobo
6daefc467a Merge pull request #734 from zed-industries/fix-prompt-panic
Drop borrow to window state before calling beginSheetModalForWindow
2022-04-04 17:50:09 -06:00
Nathan Sobo
66544d54f2 Drop borrow to window state before calling beginSheetModalForWindow
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-04-04 16:18:28 -06:00
Keith Simmons
05a05157fa Move style source files to src and build to dist
Co-authored-by: Nate Butler <nate@zed.dev>
2022-04-04 14:43:13 -07:00
Nathan Sobo
b060fb0f67 Merge pull request #732 from zed-industries/fix-impersonation-in-api
In API, wait to create access token until after we impersonate a user
2022-04-04 15:16:35 -06:00
Nathan Sobo
6a1be11aa6 Wait to create access token until we impersonate a user
We need to wait to create the token until we decide on whether we're impersonating a different user, otherwise we'll create the token for the original user and the impersonated user won't be able to authenticate.
2022-04-04 15:07:55 -06:00
Nate Butler
58dee75ff0 Merge branch 'styles-in-typescript' of https://github.com/zed-industries/zed into styles-in-typescript 2022-04-04 15:15:54 -04:00
Nate Butler
3dc99a8743 Update dark, light themes. 2022-04-04 12:14:00 -07:00
Nate Butler
a3fc719a52 Add a combined tokens.json for Figma Tokens
- Having individual json files for themes and core is useful for copy+pasting while exploring changes
- Figma github sync requires a single json file to pull down
2022-04-04 12:14:00 -07:00
Nate Butler
90df8a31e7 Fix incorrect ramp preset values in color.ts
- Regenerate themes and tokens as well
2022-04-04 12:14:00 -07:00
Nate Butler
37441bf342 Add basic support for exporting tokens to Figma Tokens. (#724)
* WIP on figma token export

* WIP Working export

* Tidy up the figma tokens script

* Correctly format theme json structure for Figma Tokens

* Finish up themeTokens imports
2022-04-04 12:14:00 -07:00
Nate Butler
e0e9a14590 Remove leftover console.log 2022-04-04 12:14:00 -07:00
Nate Butler
631d8d0344 Refined dark theme styles 2022-04-04 12:14:00 -07:00
Nate Butler
c374fd2f54 WIP 2022-04-04 12:14:00 -07:00
Nate Butler
bfde9dca4e Add greg to .zed.toml 2022-04-04 12:14:00 -07:00
Nate Butler
381d50bac6 WIP 2022-04-04 12:14:00 -07:00
Nate Butler
c812adde7f Add "npm run watch" command to live reload changes 2022-04-04 12:14:00 -07:00
Nathan Sobo
391aed3d66 Start loading new theme JSON format instead of TOML
Replaced remaining extends with javascript object extension.
Moved tokens/core.ts to tokens.ts and massaged the types to make it more
obvious when types don't match up.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-04-04 12:13:59 -07:00
Nathan Sobo
371ea7c552 Update style tree based on changes to _base.toml from main
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-04 12:13:59 -07:00
Nathan Sobo
d2a070c345 Write theme JSON files from buildThemes script
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-04 12:13:59 -07:00
Nathan Sobo
70a783c8d1 Fix TS compile error 2022-04-04 12:13:59 -07:00
Nate Butler
211c473d32 Update renamed/moved imports 2022-04-04 12:13:59 -07:00
Nate Butler
43a7cadf5b Type name 2022-04-04 12:13:59 -07:00
Keith Simmons
bfeb6abb4b Finish dark.ts initial port and restructure files to get ready for build script
Build script currently fails to type check. Not sure whats going on. Will fix in the morning.

Co-authored-by: Nate Butler <nate@zed.dev>
2022-04-04 12:13:59 -07:00
Keith Simmons
f11e0aeda9 wip 2022-04-04 12:13:59 -07:00
Keith Simmons
210eb2f6b1 wip 2022-04-04 12:13:59 -07:00
Nate Butler
083c1f7c0e WIP for keith 2022-04-04 12:13:59 -07:00
Nate Butler
ae8b610d85 WIP: Scaffold tokens in dark.ts, no real values yet. 2022-04-04 12:13:59 -07:00
Nate Butler
c008e65de6 Extract search from app
- Also update border to use borderColor( )
2022-04-04 12:13:59 -07:00
Nate Butler
d88e20477d Update app.ts, editor.ts 2022-04-04 12:13:59 -07:00
Nathan Sobo
70b15e4c90 Convert chat panel 2022-04-04 12:13:59 -07:00
Nathan Sobo
189db6311c Convert project panel styles 2022-04-04 12:13:59 -07:00
Nathan Sobo
cb3c111401 Convert editor styles to TypeScript 2022-04-04 12:13:59 -07:00
Nathan Sobo
8b33a58076 Express workspace in terms of new components
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-04 12:13:59 -07:00
Nate Butler
1f71e742c5 WIP: Color WIP 2022-04-04 12:13:59 -07:00
Nate Butler
bfce4a6104 WIP: Add rose color tokens to core.ts 2022-04-04 12:13:59 -07:00
Nathan Sobo
2aebb04a84 Start on TypeScript-based styling system
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-04 12:13:59 -07:00
Antonio Scandurra
38e902b241 WIP: Start on auto-update
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-04-04 18:59:57 +02:00
Antonio Scandurra
cbf6d827db v0.24.0 2022-04-04 15:09:31 +02:00
Antonio Scandurra
c62a3ea672 Merge pull request #687 from zed-industries/vim-word-and-line-movement
Add word and line movement in vim normal mode
2022-04-04 14:42:27 +02:00
Antonio Scandurra
328be473e5 Rename sub_mode to submode
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-04 14:14:21 +02:00
Nathan Sobo
9702ab0075 Merge pull request #719 from zed-industries/misc-breadcrumbs-bugs
Fix miscellaneous breadcrumbs bugs
2022-04-04 05:42:55 -06:00
Nathan Sobo
9ce19a2ea1 Merge pull request #723 from zed-industries/save-as-on-close
Prompt to save untitled buffers when closing them if they are dirty
2022-04-04 05:38:53 -06:00
Nathan Sobo
909b365ed8 Merge pull request #725 from zed-industries/fn-input
Avoid text insertion when holding down the `fn` key
2022-04-04 05:37:33 -06:00
Antonio Scandurra
dee416bdbe Avoid text insertion when holding down the fn key 2022-04-04 11:13:35 +02:00
Nate Butler
b6f85e4895 Update dark, light themes. 2022-04-03 21:15:14 -04:00
Nate Butler
2d51b103d2 Add a combined tokens.json for Figma Tokens
- Having individual json files for themes and core is useful for copy+pasting while exploring changes
- Figma github sync requires a single json file to pull down
2022-04-03 15:03:38 -04:00
Nate Butler
d029a5c376 Fix incorrect ramp preset values in color.ts
- Regenerate themes and tokens as well
2022-04-03 13:37:47 -04:00
Nate Butler
60295af00a Add basic support for exporting tokens to Figma Tokens. (#724)
* WIP on figma token export

* WIP Working export

* Tidy up the figma tokens script

* Correctly format theme json structure for Figma Tokens

* Finish up themeTokens imports
2022-04-03 13:30:59 -04:00
Nate Butler
433c095f51 Remove leftover console.log 2022-04-03 10:50:41 -04:00
Antonio Scandurra
089b0e8e0f Remove duplicate activation logic when removing items from pane 2022-04-03 13:00:39 +02:00
Antonio Scandurra
80b599c4ef Prompt to save untitled buffers when closing them while they are dirty 2022-04-03 12:43:33 +02:00
Nate Butler
6a7c8a6995 Refined dark theme styles 2022-04-03 01:04:34 -04:00
Antonio Scandurra
b0b54365c7 Re-render breadcrumbs when buffer has been reparsed 2022-04-02 16:33:24 +02:00
Antonio Scandurra
d0a17f8c2c Update toolbar and automatically unfollow when navigating back and forth 2022-04-02 16:32:50 +02:00
Antonio Scandurra
c39de1f9dc Show full path for file worktrees or when there is more than 1 worktree 2022-04-02 16:10:10 +02:00
Antonio Scandurra
9225629208 Re-render breadcrumbs on save or when the editor title changes 2022-04-02 15:51:59 +02:00
Nate Butler
2af313c8e2 WIP 2022-04-02 01:05:28 -04:00
Nate Butler
b721472991 Add greg to .zed.toml 2022-04-01 23:59:20 -04:00
Nate Butler
ffc271e100 WIP 2022-04-01 23:58:04 -04:00
Nate Butler
f633e98081 Add "npm run watch" command to live reload changes 2022-04-01 22:39:18 -04:00
Max Brunsfeld
fb2ae84719 Merge pull request #709 from zed-industries/prompt-on-close
Prompt user when closing items with unsaved changes or conflicts
2022-04-01 15:38:41 -07:00
Max Brunsfeld
fe27a27cb6 Merge branch 'main' into prompt-on-close 2022-04-01 15:29:23 -07:00
Max Brunsfeld
79bd8642e6 Merge pull request #702 from zed-industries/typescript
Add support for JS/Typescript/TSX, allow language servers to support multiple languages
2022-04-01 15:24:58 -07:00
Max Brunsfeld
c4d3bbf184 Bump protocol version 2022-04-01 15:17:30 -07:00
Max Brunsfeld
7ad862673d Add basic syntax highlight colors for typescript completions 2022-04-01 15:05:03 -07:00
Max Brunsfeld
5090e6f146 Fix common_prefix_at panic when needle contains multibyte chars
Also, make the prefix matching case-insensitive, since this is the
typical behavior with autocomplete.
2022-04-01 14:52:38 -07:00
Nathan Sobo
93c0c2af0a Start loading new theme JSON format instead of TOML
Replaced remaining extends with javascript object extension.
Moved tokens/core.ts to tokens.ts and massaged the types to make it more
obvious when types don't match up.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-04-01 13:34:39 -07:00
Max Brunsfeld
6f28033efe Add explanatory comments in unit test for code actions w/ commands 2022-04-01 13:00:06 -07:00
Max Brunsfeld
fe8e06e781 Fix clipping when using label-only completions 2022-04-01 12:07:41 -07:00
Max Brunsfeld
ba009724dd Handle LSP apply workspace edit request fully before responding 2022-04-01 11:59:21 -07:00
Max Brunsfeld
56523b5775 Allow applying code actions that use commands
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-01 10:16:26 -07:00
Nathan Sobo
9147a19522 Update style tree based on changes to _base.toml from main
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-01 09:56:50 -06:00
Nathan Sobo
b35fafc8e3 Merge branch 'main' into styles-in-typescript 2022-04-01 09:46:51 -06:00
Nathan Sobo
6734a0e69d Write theme JSON files from buildThemes script
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-04-01 09:45:11 -06:00
Nathan Sobo
99738db8a5 Fix TS compile error 2022-04-01 08:25:58 -06:00
Antonio Scandurra
be677a8a4b Don't assume the CloseActiveItem action is synchronous in test 2022-04-01 15:27:06 +02:00
Antonio Scandurra
e93ab4db14 Prompt before closing buffer with unsaved changes or conflicts 2022-04-01 14:33:07 +02:00
Antonio Scandurra
703f1c3be0 Introduce workspace::Item::reload to manually trigger a reload 2022-04-01 14:02:49 +02:00
Antonio Scandurra
65048760b2 Allow explicit reload of buffers via Project::reload_buffers 2022-04-01 14:01:56 +02:00
Antonio Scandurra
bdd95a82d7 Merge pull request #705 from zed-industries/breadcrumbs
Introduce breadcrumbs
2022-04-01 11:02:54 +02:00
Antonio Scandurra
cd5389b4d8 Let toolbar items specify flex when they have a primary location 2022-04-01 10:55:38 +02:00
Antonio Scandurra
6d4c748d82 Show "untitled" in breadcrumbs when the buffer has no path 2022-04-01 10:15:37 +02:00
Antonio Scandurra
7f9ff47089 Hide breadcrumbs when project search has no results 2022-04-01 10:00:21 +02:00
Antonio Scandurra
9f939bd007 Fix styling of project search bar 2022-04-01 09:59:36 +02:00
Max Brunsfeld
fed5d141bc Start work on applying code actions that use commands
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-31 22:03:52 -07:00
Max Brunsfeld
e987a8ba63 Let fake and real LanguageServer access AsyncAppContext in handler callbacks
Also, reimplement FakeLanguageServer by wrapping LanguageServer, instead of
duplicating its functionality differently.
2022-03-31 21:57:00 -07:00
Nate Butler
cea3ac6217 Update renamed/moved imports 2022-03-31 23:43:01 -04:00
Nate Butler
1d42cbcf42 Type name 2022-03-31 23:42:45 -04:00
Keith Simmons
e990b46b9d Finish dark.ts initial port and restructure files to get ready for build script
Build script currently fails to type check. Not sure whats going on. Will fix in the morning.

Co-authored-by: Nate Butler <nate@zed.dev>
2022-03-31 20:31:18 -07:00
Keith Simmons
ce8d5bc0db wip 2022-03-31 19:05:21 -07:00
Keith Simmons
afbddc1bcd Address panic when completions requested and returned to outdated buffer 2022-03-31 18:22:55 -07:00
Keith Simmons
e3366c490e wip 2022-03-31 17:51:25 -07:00
Nate Butler
b4087b115b WIP for keith 2022-03-31 20:32:47 -04:00
Nate Butler
0b690ac0b4 WIP: Scaffold tokens in dark.ts, no real values yet. 2022-03-31 19:10:44 -04:00
Keith Simmons
564225c401 Provide diagnostic context to codeAction
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-31 15:39:52 -07:00
Nathan Sobo
903810f22e Style search in buffer below breadcrumbs
We still have issues with project search styling.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-31 11:44:16 -06:00
Nathan Sobo
8bfac63e0d Render the search UI on a separate row from the breadcrumbs
- In project search, render it above the breadcrumbs
- In buffer search, render it below

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-31 10:36:39 -06:00
Nate Butler
fb41ad325c Extract search from app
- Also update border to use borderColor( )
2022-03-31 11:27:02 -04:00
Keith Simmons
9385690b98 Add test for common_prefix_at and rewrite it to be more readable and
pass the new test cases
2022-03-31 01:09:58 -07:00
Nate Butler
c6c6cc591a Update app.ts, editor.ts 2022-03-31 01:38:18 -04:00
Max Brunsfeld
263e3d8176 Start work on interpreting 'label/insertText' completions
These completions don't supply a range that should be overwritten, so
the client needs to infer it via substring matching.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-03-30 17:47:25 -07:00
Nathan Sobo
b8118ee50e Convert chat panel 2022-03-30 18:45:34 -06:00
Nathan Sobo
4a728bb3d3 Convert project panel styles 2022-03-30 18:26:47 -06:00
Max Brunsfeld
c280c85ce7 Hard-code LSP formatting options for now
This is needed for auto-formatting to work properly in TypeScript and JSON

Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-30 17:08:40 -07:00
Nathan Sobo
89eb34209f Convert editor styles to TypeScript 2022-03-30 17:59:35 -06:00
Max Brunsfeld
cf9efd7005 Improve installation of npm-based language servers
* Use --prefix flag to guarantee that they are installed in .zed
* Use the @latest tag when available
* Extract helper functions

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-03-30 16:48:59 -07:00
Max Brunsfeld
4805cfe48c Merge branch 'main' into typescript 2022-03-30 14:44:07 -07:00
Max Brunsfeld
cfa0269b1b Merge pull request #701 from zed-industries/restart-lsp
Add restart-lsp keybinding
2022-03-30 13:59:04 -07:00
Keith Simmons
0dce371b3e Add assert_set_eq macro to make test clearer
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-30 13:53:38 -07:00
Keith Simmons
32d2e5952c Test language server restart works as expected
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-30 13:08:36 -07:00
Antonio Scandurra
0453dd1101 Allow flex items to float to the end of the flex axis
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-30 16:46:14 +02:00
Antonio Scandurra
621e67bca7 Revert deletion of FindEditor in theme 2022-03-30 13:35:17 +02:00
Antonio Scandurra
94097a56a1 Fix buffer search unit tests 2022-03-30 13:18:31 +02:00
Max Brunsfeld
fb46615c9f Use a fancier angle bracket in the breadcrumbs 2022-03-29 21:16:12 -07:00
Max Brunsfeld
45ad5f343f Parse JS as TSX 2022-03-29 18:26:58 -07:00
Max Brunsfeld
3b4cab9094 Move all configuration of individual LSP servers to LspAdapter 2022-03-29 18:14:30 -07:00
Max Brunsfeld
ebc711f9f5 Restructure fake language server setup
Replace FakeLanguageServerConfig with FakeLanguageServerAdapter
2022-03-29 17:55:57 -07:00
Keith Simmons
ec57c1f4ac Properly dedup restarts of language servers 2022-03-29 17:46:39 -07:00
Keith Simmons
6d91fd078c Add restart-lsp keybinding 2022-03-29 17:24:23 -07:00
Max Brunsfeld
158d987965 Start work on allowing language servers to support multiple languages 2022-03-29 16:57:18 -07:00
Nathan Sobo
32b6c3d3d4 Express workspace in terms of new components
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-03-29 16:28:19 -06:00
Nate Butler
39f46f64a6 WIP: Color WIP 2022-03-29 17:10:46 -04:00
Keith Simmons
0e1d371a67 Add typescript language server
Currently not tested for tsx files

Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-29 13:42:21 -07:00
Nate Butler
9669f5a8f8 WIP: Add rose color tokens to core.ts 2022-03-29 15:33:03 -04:00
Nathan Sobo
1615c6150a Start on TypeScript-based styling system
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
2022-03-29 13:08:00 -06:00
Max Brunsfeld
d466768eed WIP 2022-03-29 11:06:08 -07:00
Max Brunsfeld
dd1c88afa5 Add basic TypeScript and TSX support
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-29 10:42:46 -07:00
Antonio Scandurra
a11665ecc7 Render project search query editor in toolbar 2022-03-29 17:04:39 +02:00
Antonio Scandurra
a6bdb6dc5d Embed match index inside of search query editor 2022-03-29 15:53:36 +02:00
Antonio Scandurra
13f42550c9 Show breadcrumbs in the toolbar 2022-03-29 15:08:37 +02:00
Antonio Scandurra
099250c691 Introduce MultiBuffer::symbols_containing 2022-03-29 15:08:37 +02:00
Antonio Scandurra
bfa5dd52dd Don't underflow when calling symbols_containing_offset(0) 2022-03-29 15:08:37 +02:00
Antonio Scandurra
d7a39a2116 Honor SearchBar being dismissed when changing the active item 2022-03-29 15:08:33 +02:00
Antonio Scandurra
42a7e573bc Add padding to toolbar 2022-03-29 12:17:37 +02:00
Antonio Scandurra
a86118cfe2 Avoid matching duplicate impl outline items in tests 2022-03-29 11:59:52 +02:00
Antonio Scandurra
9df2dacd85 Restructure Pane to have a single Toolbar with multiple items 2022-03-29 11:48:21 +02:00
Antonio Scandurra
d296bb21a8 Emit Event::PaneAdded in Workspace when a new pane is created 2022-03-29 10:24:42 +02:00
Antonio Scandurra
d7026c2228 Merge branch 'main' into breadcrumbs 2022-03-29 10:05:05 +02:00
Max Brunsfeld
a8600e76a3 Make language's language server config non-optional 2022-03-28 18:14:49 -07:00
Max Brunsfeld
4d456d3847 Remove duplication in build_language_registry 2022-03-28 18:01:29 -07:00
Antonio Scandurra
cc9843c90e Merge pull request #692 from zed-industries/selection-history
Allow undoing and redoing selections via `cmd-u` and `cmd-shift-u`
2022-03-28 17:55:09 +02:00
Antonio Scandurra
f274a6ab4f Avoid unnecessary clones when undoing/redoing selections 2022-03-28 17:47:14 +02:00
Antonio Scandurra
5ef6337b09 Merge branch 'main' into selection-history 2022-03-28 17:24:46 +02:00
Antonio Scandurra
aec82ef71e Test selection history
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-28 17:20:52 +02:00
Antonio Scandurra
45ecd8e0a6 Always use square brackets in marked_text_ranges
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-28 17:11:35 +02:00
Antonio Scandurra
686085dd60 Merge pull request #690 from zed-industries/indent-keybindings
Bind `Outdent` and `Indent` respectively to `cmd-[` and `cmd-]`
2022-03-28 16:50:23 +02:00
Antonio Scandurra
bbfb63ff89 Cap selection history to 1024 entries 2022-03-28 16:37:48 +02:00
Antonio Scandurra
2a1fed1387 Insert tabs instead of indenting only when all selections are empty
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-28 16:36:12 +02:00
Antonio Scandurra
0cd356ce06 Merge pull request #689 from zed-industries/format-timeout
Skip formatting during save if it takes too long
2022-03-28 16:17:56 +02:00
Antonio Scandurra
aa3e2ef4a4 Merge pull request #691 from zed-industries/snap-icons-to-pixel-grid
Snap icon sprites to pixel grid
2022-03-28 16:16:06 +02:00
Antonio Scandurra
73c2f52158 Implement cmd-u and cmd-shift-u to undo and redo selections 2022-03-28 16:05:44 +02:00
Antonio Scandurra
4ed0607e1e Extract SelectionHistory in preparation to store an undo/redo stack 2022-03-28 14:52:54 +02:00
Antonio Scandurra
3cfa2c65b3 Autoscroll to newest cursor on cmd-d instead of fitting all selections 2022-03-28 14:38:51 +02:00
Antonio Scandurra
f69bd0e327 Snap icon sprites to pixel grid
This should resolve some rendering artifacts potentially caused by
floating point errors when sampling the texture. It should also lead
to crisper images when icons are rendered midway through a pixel.
2022-03-28 11:52:13 +02:00
Antonio Scandurra
ac88003c19 Bind Outdent and Indent respectively to cmd-[ and cmd-] 2022-03-28 11:34:46 +02:00
Antonio Scandurra
a2c4205c5c Make indent and outdent explicit actions and unify tabbing logic 2022-03-28 11:34:38 +02:00
Antonio Scandurra
03752f913d Fix warnings 2022-03-28 11:05:55 +02:00
Antonio Scandurra
2c78c830eb Skip formatting during save if it takes too long 2022-03-28 11:02:20 +02:00
Antonio Scandurra
26aa138429 Fire fake timers waking up at the same time as the current clock 2022-03-28 10:57:52 +02:00
Antonio Scandurra
cbd266052d Allow returning futures in fake language server request handlers 2022-03-28 10:44:32 +02:00
Keith Simmons
a7a52ef3f7 Add word and line movement in vim normal mode
Add jump to start and end of the document
Move vim tests to relevant vim files
Rename VimTestAppContext to VimTestContext for brevity
Improve VimTestContext assertions to pretty print locations when selection position assertion panics
2022-03-27 17:58:28 -07:00
Nathan Sobo
3ae5fc74c9 Merge pull request #686 from zed-industries/disable-vim-on-start
Fully disable vim mode on start unless it's enabled
2022-03-26 19:23:46 -06:00
Nathan Sobo
c6ad667d49 Assign normal mode when re-enabling 2022-03-26 19:19:12 -06:00
Nathan Sobo
daf999c3be Fully disable vim mode on start unless it's enabled
Also: Make some structural adjustments to remove the need for defer. Instead of accessing the global in associated VimState functions, have a single method that allows us to call update instance methods.
2022-03-26 19:19:12 -06:00
Nathan Sobo
30e31f6561 Test that vim mode can be disabled on startup 2022-03-26 19:19:12 -06:00
Nathan Sobo
2837125098 0.23.0 2022-03-26 07:22:01 -06:00
Nathan Sobo
fe1f857e84 Merge pull request #684 from zed-industries/subword
Add bindings for subword movement and deletion
2022-03-26 07:18:29 -06:00
Nathan Sobo
d4436277ee Merge pull request #682 from zed-industries/vim-hjkl
Vim hjkl
2022-03-26 07:11:46 -06:00
Nathan Sobo
2dc76a2b58 Add bindings for subword movement and deletion 2022-03-26 07:10:16 -06:00
Keith Simmons
1a29180185 Fixed issue with enabling and disabling vim mode dynamically
Also added indoc and marked text utility to vim tests to improve readability
2022-03-25 20:10:52 -07:00
Keith Simmons
0aaf270650 Add clip_to_line_end to display_map/snapshot and set it to ensure vim positioning in normal mode
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-25 20:10:52 -07:00
Keith Simmons
bb9b36dccd Add initial vim mode mode switching
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-25 20:10:37 -07:00
Nathan Sobo
d74221829c Merge pull request #680 from zed-industries/unregister-on-disconnect
Properly clear out registration and sharing state when a host loses their connection
2022-03-25 11:52:25 -06:00
Nathan Sobo
62b4eb5efc Add integration test for dropping host connections while sharing
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-25 10:32:31 -06:00
Nathan Sobo
a3e9a3afbf Clear out project registration and sharing state on disconnect
Previously, we weren't fully clearing the state associated with projects and worktrees when losing connection. This caused us to not see guest avatars disappear and not be able to re-share upon reconnect.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-25 10:15:08 -06:00
Antonio Scandurra
3339739dbf Merge pull request #678 from zed-industries/disk-based-diagnostics-transformation
Preserve disk-based diagnostics whose ranges intersect with an edit since save
2022-03-25 17:04:07 +01:00
Antonio Scandurra
abf63b915b Merge pull request #673 from zed-industries/unfold-on-select-match
Unfold when selecting next match
2022-03-25 15:40:22 +01:00
Antonio Scandurra
865cd1960f Preserve disk-based diagnostics whose ranges intersect with an edit since save
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-25 15:35:31 +01:00
Antonio Scandurra
7a6fe73440 Rename Patch::transform_old to Patch::old_to_new
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-25 14:57:40 +01:00
Antonio Scandurra
eefaa86750 Introduce Patch::transform_old 2022-03-25 14:28:38 +01:00
Nathan Sobo
2c232d585a Merge branch 'main' into unfold-on-select-match 2022-03-24 14:13:27 -06:00
Nathan Sobo
ccc276da7a Merge pull request #672 from zed-industries/fix-unfollowing-on-edit
Automatically unfollow leader only for edits that originate from the follower editor
2022-03-24 13:26:28 -06:00
Keith Simmons
8f75520ade Merge pull request #676 from zed-industries/highlighted-text-fix
Highlighted text fix
2022-03-24 11:52:06 -07:00
Keith Simmons
92c7b5d6ef Remove result from anchor cmp functions
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-24 11:48:31 -07:00
Keith Simmons
ab631cf6c3 Change language::anchor::min() to a constant
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-24 10:41:33 -07:00
Keith Simmons
f6805eb802 Make rename highlights work across multibuffer excerpts
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-24 10:22:47 -07:00
Antonio Scandurra
1c25b3d150 Test the new inclusive parameter when unfolding 2022-03-24 17:20:28 +01:00
Antonio Scandurra
7fa7b7e507 Unfold range when selecting the next match
Selected matches are unfolded when in project search, buffer search and
when hitting `cmd-d` to select the next match.
2022-03-24 17:16:21 +01:00
Antonio Scandurra
78b52168fa Rename Editor::unfold to Editor::unfold_lines 2022-03-24 17:15:40 +01:00
Antonio Scandurra
4f50da759a Allow customizing whether FoldMap::unfold treats ranges as inclusive 2022-03-24 17:14:41 +01:00
Antonio Scandurra
9421ad04f7 Add a unit test for editor edit events 2022-03-24 09:17:56 +01:00
Antonio Scandurra
87981bb2ab Emit an Edited event when ending, undoing or redoing a transaction 2022-03-24 08:56:37 +01:00
Antonio Scandurra
a739c362d9 Rename editor::Event::Edited to editor::Event::BufferEdited
This is to distinguish it from a new event we're about to add which
represent edits originating from that specific editor.
2022-03-24 08:55:46 +01:00
Antonio Scandurra
864bede8a2 Use Editor::transact everywhere
This is in preparation of emitting an edit event every time a transaction ends
or it is undone/redone.
2022-03-24 08:48:06 +01:00
Max Brunsfeld
ff4bdb3114 Fix incorrect highlighting when an empty range is highlighted via the DisplayMap
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-23 18:20:55 -07:00
Max Brunsfeld
1c4090d791 Merge pull request #669 from zed-industries/extend-selection-fixes
Fix extending selections starting at ends of syntax nodes
2022-03-23 15:56:35 -07:00
Max Brunsfeld
22148a3639 Fix extending selections starting at ends of other nodes
Fixes #478
2022-03-23 15:38:23 -07:00
Max Brunsfeld
1dd553bc56 Merge pull request #657 from zed-industries/global-observations
Add global change observations
2022-03-23 14:11:33 -07:00
Max Brunsfeld
483a84a7f1 0.22 2022-03-23 12:09:07 -07:00
Max Brunsfeld
8f7966bf35 Merge pull request #668 from zed-industries/no-lsp-when-following
Avoid making LSP requests when moving cursor due to following
2022-03-23 11:54:45 -07:00
Max Brunsfeld
cbd4ef2ec5 Merge pull request #667 from zed-industries/fix-duplicate-nav-entries
Fix duplicate nav entries
2022-03-23 11:49:00 -07:00
Max Brunsfeld
eb4035630a Merge pull request #666 from zed-industries/keychain
Refine authentication and keychain interaction
2022-03-23 11:48:49 -07:00
Max Brunsfeld
f7e7d58f49 Avoid making LSP requests when moving cursor due to following 2022-03-23 11:41:20 -07:00
Keith Simmons
e36104f30d Add navigation deduping
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-03-23 11:32:25 -07:00
Nathan Sobo
4a42025c28 Authenticate on startup if ZED_IMPERSONATE is assigned
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-23 12:25:06 -06:00
Nathan Sobo
657b92b020 Don't prompt for keychain access when launching from a pty
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-23 12:18:17 -06:00
Nathan Sobo
ee9ed936e4 Don't try keychain after authentication fails
Previously, we were achieving this by deleting the keychain item, but this can sometimes fail which leads to an infinite loop. Now, we explicitly never try the keychain when reattempting authentication after authentication fails.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-23 12:15:36 -06:00
Antonio Scandurra
5cd94b5b92 WIP 2022-03-23 19:05:46 +01:00
Antonio Scandurra
255a8c5d14 Don't push a duplicate nav entry when changing selections via the mouse
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-23 18:45:45 +01:00
Max Brunsfeld
29892ce5d7 Merge pull request #663 from zed-industries/following-pending-selections
Fix error in follower when leader creates pending selections
2022-03-23 10:32:40 -07:00
Keith Simmons
0a8d543f66 Add global tests and wrap global update functions in update call to flush effects
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-03-23 10:27:27 -07:00
Max Brunsfeld
0b3a63b843 Fix error in follower when leader creates pending selections
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 10:24:26 -07:00
Keith Simmons
454f7a570c Add global change observations 2022-03-23 09:14:12 -07:00
Antonio Scandurra
10f176073d Merge pull request #662 from zed-industries/fix-refresh-selections-when-mouse-selecting
Account for pending selections when calling `Editor::refresh_selections`
2022-03-23 15:58:28 +01:00
Antonio Scandurra
b73f57d37a Don't destroy pending selection on Editor::refresh_selections
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 15:21:11 +01:00
Antonio Scandurra
004f98cc6d Merge pull request #661 from zed-industries/follow
Introduce basic following experience
2022-03-23 15:17:44 +01:00
Antonio Scandurra
60b6b0b317 Cycle through panes spatially rather than in the order in which they created
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 15:06:25 +01:00
Antonio Scandurra
5ac39aa7cd Don't show local cursors when editor is not focused
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 14:46:33 +01:00
Antonio Scandurra
4f27049305 Focus followed items when they become active if the pane is active
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 14:41:48 +01:00
Antonio Scandurra
edc038a1cf Activate previous pane and next pane via cmd-k cmd-left and cmd-k cmd-right
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-23 14:26:00 +01:00
Nathan Sobo
097bbe3e07 Update follow binding, remove unfollow binding
The previous binding to follow had ergonomics issues for the frequency that I think we'll want to use it. It would also conflict with the sub-word selection binding.

Now that moving the cursor etc unfollows, I don't think we need the follow binding.
2022-03-23 06:19:35 -06:00
Nathan Sobo
da15669e17 Merge pull request #656 from zed-industries/add-editor-lifetime-events
Add editor lifetime events
2022-03-23 05:59:22 -06:00
Antonio Scandurra
d24bd6f19a Account for pending selections when calling Editor::refresh_selections 2022-03-23 11:46:35 +01:00
Antonio Scandurra
3298529ed1 Fix global nested event test after turning subscriptions into effects 2022-03-23 09:14:33 +01:00
Keith Simmons
7acde40266 Merge pull request #655 from zed-industries/add-editor-selection-helpers
Add editor selection helpers
2022-03-22 22:44:56 -07:00
Max Brunsfeld
fa62fd968f Autoscroll when leader moves cursors
instead of copying their scroll top.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 18:02:54 -07:00
Max Brunsfeld
fad299eb3f Add unit test for editor's following methods
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 17:39:34 -07:00
Max Brunsfeld
8699dd9c56 Replicate fractional component of leader's scroll position
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 17:20:13 -07:00
Max Brunsfeld
880eaa268b Coalesce followed view updates only within one frame
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 17:03:24 -07:00
Max Brunsfeld
4435d9b106 Combine updates from multiple view events when updating followers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 16:22:42 -07:00
Keith Simmons
fba6f24ab7 Add editor lifetime events 2022-03-22 16:14:32 -07:00
Keith Simmons
6a1c197c1b Add editor selection utilities
Also improved test that was failing during above to use marker text approach as a drive by
2022-03-22 16:08:22 -07:00
Keith Simmons
308bfa3486 Merge pull request #654 from zed-industries/remove-movment-results
Remove results from movement functions
2022-03-22 16:07:39 -07:00
Max Brunsfeld
fc811e0856 Don't represent editor's scroll top anchor as an option
Use Anchor::min as the special value representing a scroll top of zero
2022-03-22 13:32:25 -07:00
Max Brunsfeld
0a3f013e00 Use env_logger when running the app in a terminal 2022-03-22 13:32:25 -07:00
Max Brunsfeld
c105802b2d Allow customizing the pane's following border width in the theme 2022-03-22 13:32:25 -07:00
Max Brunsfeld
4ed8f6fbb4 Make UpdateBuffer a foreground message 2022-03-22 13:32:25 -07:00
Keith Simmons
df751867a1 Remove results from movement function return values, and move editor test utilities to test file 2022-03-22 10:55:03 -07:00
Max Brunsfeld
ec7bada586 Merge pull request #651 from zed-industries/refine-word-movement
Add sub-word movement and helper functions for finding word boundaries
2022-03-22 09:09:03 -07:00
Antonio Scandurra
c78bcf7116 Ensure leader updates don't change the active pane of followers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 16:44:59 +01:00
Antonio Scandurra
9885c4f6ba Don't trigger observations with notifications emitted prior to observing
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 16:28:11 +01:00
Antonio Scandurra
5ecf945e28 Don't trigger global subscriptions with events emitted prior to subscribing
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 16:14:21 +01:00
Antonio Scandurra
73eae287a1 Don't trigger subscriptions with events emitted prior to subscribing
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-22 15:57:30 +01:00
Antonio Scandurra
284a446be7 WIP 2022-03-22 13:35:37 +01:00
Antonio Scandurra
381c82714b Bump protocol version 2022-03-22 13:19:07 +01:00
Antonio Scandurra
016fb01ef8 Merge branch 'main' into follow 2022-03-22 11:20:55 +01:00
Antonio Scandurra
e5a99cf8cd Stop following when leader disconnects 2022-03-22 11:16:04 +01:00
Antonio Scandurra
ffaf409a31 Forget last pane's leader when such pane is removed
This is just a memory optimization and doesn't cause any observable
change in behavior.
2022-03-22 11:06:52 +01:00
Antonio Scandurra
5dc36260e5 Reflect leader's view state when recycling existing local editors 2022-03-22 10:51:17 +01:00
Antonio Scandurra
34e5a1f6bb Always render local selections on top of remote ones 2022-03-22 10:31:28 +01:00
Antonio Scandurra
7d566ce455 Follow last collaborator or the next one via cmd-alt-shift-f 2022-03-22 10:16:58 +01:00
Antonio Scandurra
67dbc3117d Stop following when activating a different item on the follower pane 2022-03-22 09:42:37 +01:00
Antonio Scandurra
3117554568 Automatically unfollow when editing, scrolling or changing selections 2022-03-22 09:17:01 +01:00
Max Brunsfeld
c550fc3f01 WIP - Start work on unfollowing automatically 2022-03-21 21:52:28 -07:00
Max Brunsfeld
1728551282 Always mirror the leader's selections when following 2022-03-21 21:47:29 -07:00
Nathan Sobo
ee3e6049a3 Make boundary-finding methods wrap across newlines
This requires word and subword methods to explicitly acknowledge that they want to stop at newlines, which I think actually increases clarity. It makes the boundary finding method more general and useful for external callers such as the forthcoming vim crate.
2022-03-21 21:25:02 -06:00
Nathan Sobo
f70f4c7729 Improve DisplayPoint Debug impl 2022-03-21 21:07:56 -06:00
Nathan Sobo
e5a00d72f8 Implement next_subword_end 2022-03-21 20:02:08 -06:00
Nathan Sobo
c0d05c82b7 WIP: Start on previous_subword_start
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-21 19:53:01 -06:00
Max Brunsfeld
c8f36af823 Show borders around avatars and panes to indicate following state 2022-03-21 15:12:15 -07:00
Nathan Sobo
5b54874705 Extract logic for scanning over character boundaries 2022-03-21 16:01:22 -06:00
Nathan Sobo
0c89ad3ac0 Make multi-byte and surrounding_word tests more readable
Just merge multi-byte tests into the main word movement tests
2022-03-21 15:41:42 -06:00
Nathan Sobo
210fa4c443 Remove CharKind::Newline
This is just a character, and so it seems clearer to refer to it specifically when we want to know if a character is a newline. There was only one case where we relied on Newline being different from Whitespace, and we special-cased that instance. Changing this actually makes us match the behavior of VS Code when double-clicking runs of multiple newlines.

/cc @as-cii

Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-21 15:17:32 -06:00
Nathan Sobo
baeb7d27b8 Clarify word movement function names and improve test coverage
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-21 15:17:25 -06:00
Max Brunsfeld
06cd9ac664 Match the leader's last selection when unfollowing
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-21 14:04:55 -07:00
Max Brunsfeld
3e0bc979c3 Avoid infinite loop when collaborators follow each other
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-21 11:47:00 -07:00
Nathan Sobo
05ddd26d75 Merge pull request #648 from zed-industries/update-fonts-to-1-2-1
Update Zed fonts to 1.2.1
2022-03-21 12:19:33 -06:00
Antonio Scandurra
13a2dacc60 💄 2022-03-21 18:16:06 +01:00
Nate Butler
1c23a45d02 Update Zed fonts to 1.2.1 2022-03-21 12:11:31 -04:00
Antonio Scandurra
9575796f9e Allow unfollowing of leaders by clicking on their avatar 2022-03-21 17:10:23 +01:00
Antonio Scandurra
a154e4500b Implement Workspace::unfollow
This also changes the structure of the follow state back to be per-pane. This
is because we can't share the same view state across different panes for
a couple of reasons:

- Rendering the same view in N different panes is almost always not something
that we want due to global state such as focus.
- If we allowed it and a user followed the same person in two different panes,
there would be no way of unfollowing in one pane without also unfollowing in
the other.
2022-03-21 16:55:18 +01:00
Antonio Scandurra
a2dbebd9ba Hide cursor both locally and remotely when following 2022-03-21 15:16:56 +01:00
Nathan Sobo
c03eec019c Merge pull request #647 from zed-industries/fix-reopening-project-items
Pass project entry id to Pane when opening a project item
2022-03-20 11:01:23 -06:00
Nathan Sobo
7cb8935ff5 Pass project entry id to Pane when opening a project items
This fixes an oversight where we were failing to associate project items with their project entry ids, which broke the logic that prevented the same project entry from being opened twice in the same pane.
2022-03-20 08:54:20 -06:00
Antonio Scandurra
0e920ad5e9 Unset follower's scroll anchor when editor is scrolled all the way up 2022-03-19 10:50:23 +01:00
Max Brunsfeld
570c987455 Handle view updates when following
Basic following now works. Editors' scroll positions
are their only replicated view state.
2022-03-18 15:56:57 -07:00
Max Brunsfeld
e338da0271 Allow clicking a titlebar avatar to initiate following 2022-03-18 13:37:07 -07:00
Max Brunsfeld
d860ed25c1 Allow FollowableItem::to_state_message to return None
This way, we can avoid a panic if we don't handle certain cases,
like a non-singleton editor.
2022-03-18 13:36:05 -07:00
Max Brunsfeld
df0632011c 🎨 client
Forgot to push this yesterday night.
2022-03-18 13:03:43 -07:00
Max Brunsfeld
d02ab9bd06 Start work on updating editors's scroll positions when following
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-18 12:56:20 -07:00
Max Brunsfeld
2c53175566 Rename FollowedItem -> FollowableItem
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-18 10:12:51 -07:00
Antonio Scandurra
f4520d4184 WIP 2022-03-18 18:07:03 +01:00
Antonio Scandurra
7d7e10598a Broadcast active view to followers 2022-03-18 16:00:03 +01:00
Antonio Scandurra
3d81eb9ddf Allow accessing workspace after adding item to pane 2022-03-18 14:59:53 +01:00
Antonio Scandurra
10e6d82c3e WIP: Start on sending view updates to followers 2022-03-18 14:20:09 +01:00
Antonio Scandurra
f0b7bd6e17 Serialize initial follow state in leader and reflect it in follower 2022-03-18 10:22:13 +01:00
Max Brunsfeld
0fdaa1d715 WIP 2022-03-17 17:53:49 -07:00
Max Brunsfeld
eda06ee408 Add AnyWeakViewHandle 2022-03-17 17:53:38 -07:00
Max Brunsfeld
5702737de2 Start work on an integration test for following 2022-03-17 13:53:06 -07:00
Max Brunsfeld
845457e2c4 Always read project entry id from workspace::Item
We cannot store a workspace item's project entry id separately,
since buffers' entry ids can change (for example when doing
a *save as*).

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-17 10:58:20 -07:00
Max Brunsfeld
9716ff7964 Set up logic for starting following
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-17 10:46:54 -07:00
Antonio Scandurra
2b4738d82d Avoid passing a closure to workspace::register_project_item
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-17 17:39:25 +01:00
Antonio Scandurra
4bbfd0918e Start defining follow protocol
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 16:50:29 +01:00
Antonio Scandurra
c8a6226e03 Merge pull request #640 from zed-industries/item-view
Remove `workspace::Item` and rename `workspace::ItemView` to `workspace::Item`
2022-03-17 16:04:11 +01:00
Antonio Scandurra
5d14c9abdf Introduce workspace::register_project_item
This lets downstream crates like `editor` define how project items should be
opened.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 15:54:34 +01:00
Antonio Scandurra
bff414cfbc Remove Editor::find_or_create
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 15:13:47 +01:00
Antonio Scandurra
6f9c37851c Add Editor::for_multibuffer and repurpose Editor::for_buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 14:39:02 +01:00
Antonio Scandurra
44d997c00c Rename app_state to global in gpui
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 14:33:01 +01:00
Antonio Scandurra
84bacc556f Rename build_editor to build_item in Pane::open_item
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 14:31:05 +01:00
Antonio Scandurra
6446660c88 Rename open_buffer_for_path to open_buffer 2022-03-17 11:42:13 +01:00
Antonio Scandurra
e6755f4115 Search only in active pane when using Editor::find_or_create 2022-03-17 11:39:39 +01:00
Antonio Scandurra
a691c2fbdb Delete unused code 2022-03-17 11:33:58 +01:00
Antonio Scandurra
0efce8f70a Rename ItemView to Item 2022-03-17 11:32:46 +01:00
Antonio Scandurra
aced1e2315 Finish refactoring of how editors are opened 2022-03-17 11:29:46 +01:00
Nathan Sobo
728c708150 WIP: Massage opening of editors
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-16 17:40:09 -06:00
Nathan Sobo
1f9885ec42 Remove open_item_in_pane
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-16 16:08:13 -06:00
Nathan Sobo
0036e5c86c Replace ProjectEntry struct with ProjectEntryId
Previously, we tracked the worktree_id and entry_id separately, but now that entry ids are unique across all worktrees this is unnecessary.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-16 15:59:47 -06:00
Max Brunsfeld
a88320dc5f Remove workspace::Item trait
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2022-03-16 13:34:06 -07:00
Antonio Scandurra
e8efaed1b2 Merge pull request #633 from zed-industries/refresh-windows-panic
Fix edge cases when calling `refresh_windows`
2022-03-16 14:58:49 +01:00
Antonio Scandurra
b0afb64a6e Fix edge cases when calling refresh_windows
This commit ensures that new views are rendered for the first time. This fixes
a panic that could be reproduced by dropping the `ThemeSelector` and opening
the file finder during the same update.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-16 14:51:54 +01:00
Antonio Scandurra
17742a9fe8 Merge pull request #632 from zed-industries/underline-unused-warning
Restore underline for warnings about unused code
2022-03-16 09:52:11 +01:00
Max Brunsfeld
257601b3c1 Add buffer method for getting the symbols containing a position 2022-03-15 14:04:58 -07:00
Max Brunsfeld
76fc9c955e Restore underline for warnings about unused code 2022-03-15 13:13:33 -07:00
Antonio Scandurra
a0224cbe71 Merge pull request #630 from zed-industries/fix/go-to-line-panic
Fix go to line panic by replacing an unwrap with an and_then
2022-03-15 18:11:26 +01:00
Keith Simmons
72188456b2 fix go to line panic by replacing an unwrap with an and_then 2022-03-15 09:31:24 -07:00
Antonio Scandurra
f20aaf5c35 v0.21.0 2022-03-15 16:48:28 +01:00
Antonio Scandurra
22688c7c82 Merge pull request #627 from zed-industries/golden-line-height
Compute line-height as a multiple of font size
2022-03-15 16:45:38 +01:00
Antonio Scandurra
447f350123 Compute line-height as a multiple of font size
...instead of using the bounding box. This makes `PragmataPro` and other
fonts render more cleanly.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 16:35:06 +01:00
Antonio Scandurra
8122abeb64 Merge pull request #626 from zed-industries/inactive-code-diagnostics
De-emphasize unnecessary code diagnostics
2022-03-15 16:09:06 +01:00
Antonio Scandurra
c6c72a7249 Skip over unnecessary code diagnostics when hitting f8
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:55:39 +01:00
Antonio Scandurra
7155dabf5b Fade out unnecessary code
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:51:59 +01:00
Antonio Scandurra
41bd58e3ac Only show errors and warnings in project diagnostics
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:30:05 +01:00
Antonio Scandurra
182b2b175d Merge pull request #625 from zed-industries/go-to-prev-diagnostic
Go to previous diagnostic via `shift-f8`
2022-03-15 15:22:53 +01:00
Antonio Scandurra
021699e51c Implement shift-f8 to go to previous diagnostic
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:13:23 +01:00
Antonio Scandurra
a6d0caf557 Don't seek FilterCursor upon creation
This lets us use `next` or `prev` to decide whether to park the cursor
at the first or last filtered item.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:13:23 +01:00
Antonio Scandurra
f10fd6c419 Randomize test FilterCursor::prev
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:13:23 +01:00
Antonio Scandurra
45ce503afd Start on implementing filtering support for Cursor::prev 2022-03-15 15:13:23 +01:00
Nathan Sobo
7c6fe56347 Merge pull request #624 from zed-industries/fix-broken-syntax-highlighting
Make all `HighlightStyle` properties optional
2022-03-15 06:05:35 -06:00
Antonio Scandurra
fbf7cdf4f2 Make all HighlightStyle properties optional
Previously, some of those properties such the font weight, style and color
would be mandatory: when the theme didn't specify them, Zed would use a default
value during deserialization. This meant that those default properties would
unconditionally override the base text style, causing a rendering bug when
combining syntax highlights with diagnostic styles.

This commit fixes that by making `HighlightStyle`s more additive: each property
can be set independently and only the properties that theme specifies get
overridden in the base text style.
2022-03-15 10:39:43 +01:00
Max Brunsfeld
72692f1700 Merge pull request #622 from zed-industries/guest-settings-file
Open settings file in new window if current window isn't local
2022-03-14 17:19:11 -07:00
Max Brunsfeld
3a439f141d Open settings file in new window if current window isn't local
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-14 17:12:07 -07:00
Max Brunsfeld
d193c9a358 v0.20 2022-03-14 15:59:52 -07:00
Max Brunsfeld
38dcd522de Bump protocol version number 2022-03-14 15:57:39 -07:00
Max Brunsfeld
e7835caac4 Merge pull request #621 from zed-industries/autoclose-before-punctuation
Autoclose brackets before a language-specific set of characters
2022-03-14 15:33:47 -07:00
Max Brunsfeld
325e6c31ae Autoclose brackets before a language-specific set of characters
Fixes #588
2022-03-14 15:17:40 -07:00
Max Brunsfeld
2c25e619b4 Respect theme's background color when rendering field editors 2022-03-14 14:24:51 -07:00
Max Brunsfeld
7bdb91f4ec Merge pull request #619 from zed-industries/project-entry-ids
Ensure that worktree entry ids are unique across the project
2022-03-14 12:43:58 -07:00
Max Brunsfeld
5822b47b74 Ensure that worktrees' entry ids are unique across the project
Fixes #512
2022-03-14 12:36:56 -07:00
Max Brunsfeld
91b33e4432 Merge pull request #618 from zed-industries/fix-block-layout-panic
Fix layout panic on empty editors with blocks
2022-03-14 12:25:05 -07:00
Max Brunsfeld
e392368d89 Fix layout panic on empty editors with blocks
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-14 12:03:26 -07:00
Antonio Scandurra
40a4c18ee4 Merge pull request #604 from zed-industries/set-selections-assertion
Ensure there's at least one selection in `Editor::set_selections`
2022-03-14 17:00:12 +01:00
Antonio Scandurra
21eebede37 Add more assertions to investigate #503 in the future 2022-03-14 16:53:39 +01:00
Antonio Scandurra
a3ea6a34d9 Ensure there's at least one selection in Editor::set_selections
This commit introduces an assertion that will cause Zed to panic as
soon as the invariant gets violated. This will be useful to investigate
issue #503.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-14 16:17:14 +01:00
Antonio Scandurra
be3bfb2699 Merge pull request #603 from zed-industries/fix-presenter-panic
Re-render workspace when removing an inactive pane
2022-03-14 16:16:52 +01:00
Antonio Scandurra
5d5f89231b Hold strong handle in ChildView
This eliminates a whole class of errors where the `ChildView` could
be referring to a view that doesn't exist anymore. That probably still
indicates that there's an underlying bug, but at least we won't panic.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-14 15:49:11 +01:00
Antonio Scandurra
bae44d8132 Re-render workspace when removing an inactive pane
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-14 15:49:08 +01:00
Antonio Scandurra
e62781a57b Merge pull request #602 from zed-industries/fix-atlas-panic
Don't draw scene elements if their size is zero
2022-03-14 15:38:42 +01:00
Antonio Scandurra
47b40e3839 Don't draw scene elements if their size is zero
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-14 15:29:18 +01:00
Max Brunsfeld
e7d0bf1c36 Merge pull request #574 from zed-industries/settings-file
Read settings from a JSON file
2022-03-13 10:52:47 -07:00
Max Brunsfeld
b33a049958 Merge branch 'main' into settings-file 2022-03-13 10:43:23 -07:00
Antonio Scandurra
1e9b6b050d Merge pull request #596 from zed-industries/fix/dropped-subscription-in-callback
Fix Dropped Subscription in Handler Bug
2022-03-12 19:14:38 +01:00
Antonio Scandurra
2cb4d0a35e Merge pull request #597 from zed-industries/select-on-rename
When renaming, select new name and ghost old names
2022-03-12 19:12:09 +01:00
Nathan Sobo
992fc07133 Hide selections in original editor when renaming
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-12 10:45:11 -07:00
Nathan Sobo
308cead8a8 🙊
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-12 10:44:11 -07:00
Nathan Sobo
9f629fa307 Improve selection handling when pending rename is taken
- Set selection to the intuitive cursor position when moving up rather than restoring the full selection of the rename editor.
- When cancelling, restore the original selection.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-12 10:30:57 -07:00
Nathan Sobo
33bcd6d904 Merge remote-tracking branch 'origin/main' into select-on-rename 2022-03-12 10:10:23 -07:00
Nathan Sobo
4f086b8d7a Refresh document highlight after rename, but not during
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-12 10:10:06 -07:00
Antonio Scandurra
965f82ec31 Merge pull request #589 from zed-industries/fold-map-test-failures
Avoid re-using excerpt IDs in `MultiBuffer`
2022-03-12 17:59:48 +01:00
Antonio Scandurra
dd1711d53f Account for all excerpts ever inserted when determining new excerpt ID 2022-03-12 17:50:09 +01:00
Antonio Scandurra
cd4a9f3178 Fix bug in selection position maintenance while renaming symbol
We were resolving the selection with the wrong buffer, which now
causes a panic because we don't check the anchor's `buffer_id` anymore.
2022-03-12 13:03:45 +01:00
Max Brunsfeld
20fed599b2 Start work on relaying settings to language servers 2022-03-11 17:36:27 -08:00
Max Brunsfeld
48848de82c Store settings as a global via a gpui app_state 2022-03-11 15:58:58 -08:00
Keith Simmons
c50be72214 Format including missing formatting changes from previous PR 2022-03-11 15:38:01 -08:00
Keith Simmons
16afb3d5b1 Add some tests for global events and fix potential bug in subscriptions when subscription is dropped inside of it's own callback
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-11 15:34:04 -08:00
Nathan Sobo
c35a96c425 On rename, replace background highlights with transparent text highlights 2022-03-11 15:54:17 -07:00
Nathan Sobo
951fd1ab36 Merge branch 'main' into select-on-rename 2022-03-11 15:30:07 -07:00
Max Brunsfeld
2103eec463 Allow registering handlers for typed LSP requests 2022-03-11 13:19:10 -08:00
Max Brunsfeld
a137abe2de Add a snippet unit test with an escaped curly brace 2022-03-11 13:02:20 -08:00
Keith Simmons
87b1cfe34f Merge pull request #576 from zed-industries/cursor-shape
Add support for rendering the cursor as a Block and Underscore

Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-11 11:51:24 -08:00
Max Brunsfeld
7a68b2d371 Provide JSON language server with settings schema 2022-03-11 11:46:22 -08:00
Max Brunsfeld
862ec01e7d Add API for handling custom requests from the language server 2022-03-11 11:44:02 -08:00
Keith Simmons
17ac240511 Merge pull request #586 from zed-industries/global-events
Global Events

Co-authored-by: Max Brunsfeld <nathan@zed.dev>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-11 11:42:25 -08:00
Keith Simmons
144591d639 Minor renames for clarity 2022-03-11 11:25:36 -08:00
Max Brunsfeld
6091caee8e Merge branch 'main' into settings-file 2022-03-11 10:04:17 -08:00
Max Brunsfeld
022bb28a59 Handle escaped characters in snippets 2022-03-11 09:57:43 -08:00
Nathan Sobo
fd36b25db1 Merge pull request #587 from zed-industries/lsp-progress
Show language server progress in the status bar
2022-03-11 10:57:24 -07:00
Antonio Scandurra
71aa5e5360 💄 2022-03-11 17:13:28 +01:00
Antonio Scandurra
a74b602f18 Assume the anchor is valid if we can find an excerpt that contains it 2022-03-11 17:08:12 +01:00
Nathan Sobo
5407f25c94 Don't reuse excerpt ids in MultiBuffer
This prevents anchors from swapping their ordering, which was causing issues in FoldMap.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-11 08:50:50 -07:00
Nathan Sobo
134496ce8f Remove dead code
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-11 08:24:42 -07:00
Antonio Scandurra
c67cfd7fe1 Respect excerpt's range when comparing two anchors both belonging to it 2022-03-11 12:42:22 +01:00
Antonio Scandurra
18b1e9d35f Don't starve main thread when lots of messages/events arrive at once 2022-03-11 10:09:13 +01:00
Antonio Scandurra
7a454003fe Show the last in-progress task from language servers 2022-03-11 09:59:13 +01:00
Antonio Scandurra
a067150b5a Merge pull request #585 from zed-industries/fix/backspace-panic
Fix panic when pressing backspace at start of line
2022-03-11 08:36:52 +01:00
Keith Simmons
5f62f69907 Add unwrap check if buffer_line not available 2022-03-10 20:04:16 -08:00
Keith Simmons
81fc812221 Add global events to MutableAppContext and raise global event when new workspace is created 2022-03-10 20:03:01 -08:00
Keith Simmons
b62daebde1 Merge pull request #563 from zed-industries/mouse-history-navigation
Add missing mouse button events and mouse history navigation
2022-03-10 17:39:36 -08:00
Max Brunsfeld
bdb39f6247 Create the settings file if needed when opening it via command 2022-03-10 17:27:46 -08:00
Max Brunsfeld
9a6819b899 For single-file worktrees start LSP with parent dir as CWD 2022-03-10 16:06:12 -08:00
Max Brunsfeld
44a68b723c Add cmd-, as a keybinding for opening settings 2022-03-10 15:51:57 -08:00
Nathan Sobo
94bf3366f6 Focus in-progress rename editor when editor is focused 2022-03-10 16:42:20 -07:00
Nathan Sobo
a498cd32c8 When renaming, match the color of the renamed token in the rename editor 2022-03-10 16:38:45 -07:00
Max Brunsfeld
f32107eb8e Always refresh the windows when the settings change 2022-03-10 15:34:04 -08:00
Max Brunsfeld
00056fbe88 Load the settings file on a background thread during startup 2022-03-10 15:25:22 -08:00
Nathan Sobo
69ce021f32 Remove unused variable 2022-03-10 15:27:29 -07:00
Nathan Sobo
3968b37e26 When renaming, fade out the old name and select all 2022-03-10 14:55:31 -07:00
Keith Simmons
5502c00d9a swap default cursor shape back to bar 2022-03-10 13:28:13 -08:00
Keith Simmons
5b35c68d2e Fix failing gpui test from missing cursor shape 2022-03-10 13:20:45 -08:00
Keith Simmons
eddb089f27 render character under block cursor 2022-03-10 13:16:31 -08:00
Nathan Sobo
e6b1fea117 WIP 2022-03-10 11:32:14 -07:00
Antonio Scandurra
5157b42896 Extract a LanguageServerStatus struct 2022-03-10 18:43:56 +01:00
Antonio Scandurra
45fb470f4d Display language server name in status bar 2022-03-10 16:48:43 +01:00
Antonio Scandurra
4243f0c339 Render pending language server work in status bar 2022-03-10 16:09:47 +01:00
Antonio Scandurra
4bbf5ed0b9 Listen to all LSP progress notifications and broadcast them to peers 2022-03-10 12:00:33 +01:00
Antonio Scandurra
3394cf4941 Merge pull request #577 from zed-industries/backspace-indent
Delete till previous tabstop when backspacing within indent column
2022-03-10 10:37:34 +01:00
Antonio Scandurra
ee6d7fc6d5 Delete till previous tabstop when backspacing within indent column 2022-03-10 10:28:24 +01:00
Keith Simmons
0d42c85195 fix formatting 2022-03-10 01:09:25 -08:00
Keith Simmons
178442a4a8 Add support for rendering cursors as a block and underscore 2022-03-10 01:09:02 -08:00
Antonio Scandurra
9076345a8f Merge pull request #575 from zed-industries/delete-to-fold-point-trait
Eliminate ToFoldPoint trait
2022-03-10 09:03:33 +01:00
Nathan Sobo
ac1eb19f83 Start on text highlight support 2022-03-09 20:51:35 -07:00
Nathan Sobo
49e38e6e00 Eliminate ToFoldPoint trait
Just make it a method on FoldMap
2022-03-09 20:49:18 -07:00
Max Brunsfeld
a971306381 Reload the app settings whenever ~/.zed/settings.json changes 2022-03-09 18:00:09 -08:00
Max Brunsfeld
83f98dde52 Start work on loading settings from a file
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-09 17:59:29 -08:00
Keith Simmons
6ee0cceb14 Switch to using mouse navigation events instead of other in order to get rid of opaque button id 2022-03-09 15:04:04 -08:00
Max Brunsfeld
90c2de7342 Merge pull request #572 from zed-industries/receive-timeout-tweaks
Reset receive timeout only on reads from the websocket connection, not writes
2022-03-09 11:49:08 -08:00
Max Brunsfeld
3dc100adfb Reset receive timeout only on reads from websocket connection, not writes
Also, increase the receive timeout to 30 seconds. We'll still respond immediately
to explicit disconnection, but when there are temporary network blips that
delay pings, we think we should err on the side of keeping the connection
alive. This is in response to a false positive 'host disconnected' state
that we observed when pairing today, while the host (Keith) still clearly
had a working internet connection, because we were screen sharing.

Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-09 11:27:47 -08:00
Keith Simmons
508c4df79b Merge pull request #565 from zed-industries/eager-theme-selector
Make theme selector eagerly display the selected theme
2022-03-09 11:00:28 -08:00
Keith Simmons
5aad1ff788 formatting fixes 2022-03-09 10:42:27 -08:00
Keith Simmons
853acccbc2 Make theme selector match other selector styling 2022-03-09 10:40:30 -08:00
Keith Simmons
99e34db0ec ensure that we set original theme when dismissing theme selector and fix some minor edge cases 2022-03-09 10:34:52 -08:00
Antonio Scandurra
f15e3177d3 Merge pull request #569 from zed-industries/refine-autoclose
Refine bracket auto-closing behavior
2022-03-09 16:28:35 +01:00
Antonio Scandurra
74614177fa Merge pull request #568 from zed-industries/delegation
Notify all language servers when a buffer gets saved
2022-03-09 16:24:46 +01:00
Antonio Scandurra
97da93c9ec 💄 2022-03-09 15:44:58 +01:00
Antonio Scandurra
d9b3f04436 Surround selections with brackets when they are non-empty 2022-03-09 15:41:54 +01:00
Antonio Scandurra
f54ce8a19c Autoclose bracket only if next char is whitespace or the end of a pair 2022-03-09 15:38:17 +01:00
Antonio Scandurra
7546ede288 Split language server initialization from construction
This gives clients a chance to register to notifications.
2022-03-09 12:31:21 +01:00
Antonio Scandurra
ef1ec88523 Remove delegate support from GPUI
We added this because we thought it would save some allocations when
sending operations given that we could move them to the delegate upon
notifying it, but the reality is that we serialize operations and that
only requires a reference.
2022-03-09 10:48:52 +01:00
Antonio Scandurra
0a9595b5fa Notify all language servers only when a buffer is saved
Other notifications such as opening, closing or changing a document
are still tied to the buffer's language.
2022-03-09 10:44:03 +01:00
Keith Simmons
b440a51675 Make theme selector eagerly display the selected theme 2022-03-08 18:42:31 -08:00
Max Brunsfeld
4cb4b99c56 Assign buffer's completion triggers from LSP capabilities
Also, make LanguageServer::new() async. The future resolves
once the server is initialized.
2022-03-08 17:41:52 -08:00
Keith Simmons
fc36c706d3 Add missing mouse button events and mouse history navigation
Co-Authored-By: Max Brunsfeld
Co-Authored-By: Nathan Sobo
2022-03-08 15:45:36 -08:00
Antonio Scandurra
317a1bb07b Remove language servers from buffers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-08 15:16:07 -08:00
Antonio Scandurra
6662ba62a3 Move DidSaveTextDocument notification from Buffer to Project 2022-03-08 11:35:54 +01:00
Antonio Scandurra
51d5ed48f0 Remove unused CloseBuffer message 2022-03-08 11:17:20 +01:00
Antonio Scandurra
d6c8fdb3c4 Send buffer operations via the Project instead of Worktree 2022-03-08 11:11:25 +01:00
Antonio Scandurra
b49951ac57 Implement {ModelHandle,ViewHandle}::become_delegate 2022-03-08 09:30:32 +01:00
Nathan Sobo
f2848a092b WIP: Start on a delegation... like events, but single consumer that takes ownership of event 2022-03-08 09:01:57 +01:00
Antonio Scandurra
03aa906068 v0.19.0 2022-03-08 08:18:51 +01:00
Nathan Sobo
479c0dd391 Merge pull request #560 from zed-industries/login-shell-env
Populate environment from shell
2022-03-07 18:04:11 -07:00
Max Brunsfeld
5cc5fa2f93 Populate environment from shell
Co-Authored-By: Keith Simmons <keith@zed.dev>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-07 16:39:50 -08:00
Max Brunsfeld
bb6ab837cf Merge pull request #542 from zed-industries/guest-disconnections
Send heartbeats in both directions so the server can detect when clients disconnect
2022-03-07 15:52:35 -08:00
Max Brunsfeld
1f5eab39a9 Reset peer's receive timeout when a message is received
* Make advance_clock more realistic by waking timers in order,
  instead of all at once.
* Don't advance the clock when simulating random delays.

Co-Authored-By: Keith Simmons <keith@zed.dev>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-07 15:33:43 -08:00
Max Brunsfeld
120f7bbc3d Add Keith to zed.toml 2022-03-07 15:20:16 -08:00
Antonio Scandurra
e579da64c3 WIP: Introduce a read timeout
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-07 17:08:12 +01:00
Nathan Sobo
00ba5dffa5 Merge pull request #545 from zed-industries/halt-global-actions
Halt keystroke dispatch when a global action is dispatched
2022-03-06 09:57:48 -07:00
Nathan Sobo
40c0b9e7a5 Halt keystroke dispatch when a global action is dispatched 2022-03-06 09:46:33 -07:00
Antonio Scandurra
34bbc05cec Merge pull request #543 from zed-industries/fix-closing-items
Ensure `active_item_index` doesn't go off the end when closing items
2022-03-05 15:03:05 +01:00
Antonio Scandurra
711de5edcb Ensure active_item_index doesn't go off the end when closing items
This fixes a bug introduced in #538, where closing the current tab would hide
all the other tabs, if the current tab was the last one.

Also, this commit manually sets the active item index instead of calling
`Pane::activate_item`: even though this introduces a little bit of duplication,
it prevents us from mistakenly calling `deactivate` on the wrong item. This would
happen because `activate_item` looks at `self.active_item_index` to determine
which item to deactivate before setting the new one. However, that index is
potentially invalid because `::close_items` manipulates the `item_views` vector,
so `activate_item` could end up calling `deactivate` on an item view that was
not active in the first place.
2022-03-05 10:52:55 +01:00
Antonio Scandurra
c7ddb66795 Merge pull request #538 from zed-industries/close-inactive-items
Implement close inactive items
2022-03-05 10:35:22 +01:00
Max Brunsfeld
4124308d94 Fix errors from conditional compilation in timer functions 2022-03-04 17:16:17 -08:00
Max Brunsfeld
fab115e549 Adjust test connection to treat the half-open state more realistically
When a network connection is lost without being explicitly closed by the
other end, writes to that connection will error, but reads will just wait
indefinitely.

This allows the tests to exercise our heartbeat logic.
2022-03-04 16:47:55 -08:00
Max Brunsfeld
9017a1363b Send websocket pings from both the client and the server
Remove the client-only logic for sending protobuf pings.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-04 15:21:18 -08:00
Max Brunsfeld
c61a1bd659 Make timer method available on both foreground and background executors
Also, make it return a static future.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 13:54:07 -08:00
Max Brunsfeld
1982a8c27d Put vector clock serialization logic alongside other serialization logic
This way, the `clock` crate doesn't depend on the `rpc` crate.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 13:54:07 -08:00
Max Brunsfeld
28bacabc4e Move Network test helper from util crate into text crate
This way, `util` does not depend on `clock`.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 13:54:07 -08:00
Nathan Sobo
9b8c782609 Merge pull request #537 from zed-industries/disconnected-status
Render overlay after remote project becomes read-only
2022-03-04 10:39:43 -07:00
Nathan Sobo
8b9f41175b Use the macOS standard binding instead of VS Code's
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-04 10:39:11 -07:00
Nathan Sobo
3057b38fad Implement close inactive items action
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-04 10:36:51 -07:00
Nathan Sobo
a72d58a28c Merge branch 'main' into disconnected-status 2022-03-04 10:07:26 -07:00
Nathan Sobo
d59451fb08 Fix tests after font update
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-04 10:06:21 -07:00
Antonio Scandurra
c38de3243d 🎨
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 17:54:48 +01:00
Antonio Scandurra
38313abc48 Disable events when project becomes read-only
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 17:37:37 +01:00
Antonio Scandurra
77e913b5a4 Blur focused view when project becomes read-only
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 17:37:26 +01:00
Antonio Scandurra
b21d91db22 Render overlay after remote project becomes read-only
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 17:28:18 +01:00
Nate Butler
47532642e5 Merge pull request #535 from zed-industries/update-zed-fonts
Update zed fonts to 1.2.0
2022-03-04 11:18:18 -05:00
Nate Butler
38e32f368d Update zed fonts to 1.2.0 2022-03-04 11:05:34 -05:00
Antonio Scandurra
6ee5e96d7b Merge pull request #534 from zed-industries/create-buffers-via-project
Open untitled buffers via the `Project`
2022-03-04 16:18:02 +01:00
Antonio Scandurra
82e4544846 Merge pull request #533 from zed-industries/range-formatting
Use LSP range formatting when document formatting is not available
2022-03-04 16:12:59 +01:00
Antonio Scandurra
29cad65ce0 Open untitled buffers via the Project
This allows the registration of such buffers in the project, which is necessary
to correctly support `::save_buffer_as` and opens the door to sharing untitled
buffers with guests in the future.

Note that, for now, this disallows guests to create untitled buffers in the
current window and will create a new window instead. This is because we don't
yet have a global way of allocating a buffer's remote id (nor a way of saving
such buffers in the host's worktree) and we instead rely on the local model ID,
which could clash with the host's buffer IDs.

I think we should revisit this once guests can share their untitled buffers
with the host and other remote peers, as well as once we start keying
operations by entry id.
2022-03-04 15:25:39 +01:00
Antonio Scandurra
d8ef3a5d61 Support formatting in fake LSP capabilities 2022-03-04 11:24:18 +01:00
Antonio Scandurra
46da80d726 Use LSP range formatting when document formatting is not available 2022-03-04 10:13:17 +01:00
Antonio Scandurra
dc5a09b3f7 Merge pull request #525 from zed-industries/preserve-worktrees
Grow worktrees monotonically when sharing and move most messages to the background
2022-03-04 09:48:18 +01:00
Antonio Scandurra
7c420050c7 Observe selection set lamport timestamps when deserializing buffer 2022-03-04 09:34:30 +01:00
Antonio Scandurra
bcd5c28833 Allow receiving diagnostic updates out of order 2022-03-04 09:27:49 +01:00
Max Brunsfeld
e78661c8bc Merge pull request #532 from zed-industries/handle-language-server-failure
Avoid infinite loop when a language server fails to start
2022-03-03 20:58:35 -08:00
Max Brunsfeld
19658139b1 Avoid infinite loop when a language server fails to start 2022-03-03 18:13:38 -08:00
Max Brunsfeld
05df1dfae9 Disable doctests for all libraries
We don't use them, and they add a lot of noise to the test output
when running all tests in the workspace.
2022-03-03 16:15:56 -08:00
Max Brunsfeld
15312d0ac3 Merge pull request #526 from zed-industries/json
Add basic JSON support
2022-03-03 16:07:04 -08:00
Max Brunsfeld
3c242a43d2 Wait for LSP capabilities to be initialized before checking them 2022-03-03 15:59:03 -08:00
Max Brunsfeld
78d96a05fc Make fake language servers have full capabilities 2022-03-03 15:42:29 -08:00
Max Brunsfeld
9999862016 Enable formatting feature of JSON language server
The feature doesn't work yet because the JSON language server
only supports *range* formatting, not document formatting.
We need to adjust our code to inspect the server's capabilities
and send range formatting requests instead when needed.

We're going to hold off on doing this right now, because it
will create merge conflicts with the `preserve-worktrees`
branch (#525)

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-03 14:16:58 -08:00
Max Brunsfeld
81627a0f14 Avoid sending unhandled LSP requests to JSON language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-03 13:39:40 -08:00
Max Brunsfeld
0582c557e3 Add JSON language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-03 13:29:25 -08:00
Max Brunsfeld
bf1153cedd Add syntax highlighting/auto-indent/outlines for JSON files
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-03 12:12:18 -08:00
Antonio Scandurra
556d9cc53f Correctly defer undo operations when messages arrive out of order
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-03 18:07:59 +01:00
Antonio Scandurra
410ee124af Maintain remote worktrees correctly when building updates
This accidentally regressed in 53327e2.
2022-03-03 16:13:17 +01:00
Antonio Scandurra
c613b22619 Ignore diagnostics received for invisible worktrees 2022-03-03 13:58:55 +01:00
Antonio Scandurra
d0d6916167 Move code action and completion edit messages to the background 2022-03-03 13:54:26 +01:00
Antonio Scandurra
14d26eeedc Move several buffer-related messages to the background 2022-03-03 12:18:19 +01:00
Antonio Scandurra
1c14168f38 Ensure no two worktrees can point to the same root path
This could happen because there was a pause between creating the worktree
and adding it to the list of tracked local worktrees, and so we might end
up adding the same worktree twice when calling `create_local_worktree` in
rapid succession.
2022-03-03 10:54:52 +01:00
Antonio Scandurra
d171d8ccc4 Change the definition of check_invariants
- On the host, ensure that only one worktree can exist for a given absolute
path. Asserting about buffers was cool but I think should be tackled in the
context of leaning more on entry ids for collaboration (vs. buffer ids).
- On the guest, ensure that all the opened buffers don't contain deferred
operations.
2022-03-03 10:51:37 +01:00
Antonio Scandurra
53327e2bf0 Ensure worktree is registered/shared synchronously 2022-03-03 10:10:53 +01:00
Max Brunsfeld
530f15b46b Tweak log format in random collab test 2022-03-02 14:38:16 -08:00
Max Brunsfeld
d4ae38fcee Check projects' buffers have unique absolute paths in random collab test 2022-03-02 14:38:16 -08:00
Max Brunsfeld
ca920e1552 Rename strong_worktrees -> visible_worktrees 2022-03-02 14:38:16 -08:00
Antonio Scandurra
68cfce1fb8 Rename weak to visible
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-02 14:38:16 -08:00
Antonio Scandurra
a3c8892252 Move SearchProject to the background
Co-Authored-By: Max Brunsfeld <max@zed.dev>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-02 14:38:16 -08:00
Antonio Scandurra
07120d47f9 Convert weak worktree handles into strong handles when sharing
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-02 14:38:16 -08:00
Max Brunsfeld
4b0300daea 0.18.1 2022-03-02 14:23:19 -08:00
Max Brunsfeld
9e519b9b10 Merge pull request #523 from zed-industries/no-cmd-ctrl-input
Don't insert input into editors when control or command keys are held
2022-03-02 14:19:54 -08:00
Max Brunsfeld
5c1aff1143 Don't insert input into editors when control or command keys are held
This is a follow-up to #475
2022-03-02 14:09:46 -08:00
Antonio Scandurra
a9cc8b46e4 Merge pull request #517 from zed-industries/activate-pane-when-activating-item
Make pane active when activating one of its items
2022-03-02 17:33:12 +01:00
Antonio Scandurra
07c780bd72 Make pane active when activating one of its items 2022-03-02 16:52:35 +01:00
Antonio Scandurra
9d18f4a18a Create vendor/bin if it doesn't exist 2022-03-02 15:23:06 +01:00
Antonio Scandurra
a184583a89 Bump protocol version 2022-03-02 15:08:33 +01:00
Antonio Scandurra
85a010bfcc v0.18.0 2022-03-02 15:05:49 +01:00
Antonio Scandurra
6d59083997 Merge branch 'leaks' 2022-03-02 15:05:01 +01:00
Antonio Scandurra
0581246690 Use Node 16 on CI 2022-03-02 15:00:01 +01:00
Antonio Scandurra
c97983d25a Install node as part of ci.yml when bundling the app 2022-03-02 14:58:24 +01:00
Antonio Scandurra
65f53db6e7 WIP: investigate why npm is not there 2022-03-02 14:41:59 +01:00
Antonio Scandurra
432fef6316 💄 2022-03-02 14:41:40 +01:00
Antonio Scandurra
9ff1af3adb Always run tests and bundle creation in separate runners
This is better for caching and, thus, yields faster CI runs.
2022-03-02 14:30:52 +01:00
Antonio Scandurra
141e0559a5 Fix warnings 2022-03-02 12:45:49 +01:00
Antonio Scandurra
3ec76b63d3 Make dhat optional 2022-03-02 11:02:10 +01:00
Antonio Scandurra
b771667bf2 Merge pull request #499 from zed-industries/project-find
Project-wide search
2022-03-02 10:58:50 +01:00
Antonio Scandurra
51345cf1e1 Advance clock when simulating random delay 2022-03-02 10:39:46 +01:00
Antonio Scandurra
be7a4770fb Delete timer state when the future that's awaiting it gets dropped 2022-03-02 10:08:38 +01:00
Max Brunsfeld
8b7a9367fa Avoid storing type name string on AnyViewHandle
It won't be needed for leak error messages, because the typed
view handle will typically be created first. And this avoids
increasing the size of the handle used in production.
2022-03-01 18:22:09 -08:00
Max Brunsfeld
ae93cfed50 Tear down client's connection states when dropping test clients 2022-03-01 18:17:41 -08:00
Max Brunsfeld
3cf5329450 Flush effects when dropping test clients in random collaboration test 2022-03-01 18:17:25 -08:00
Max Brunsfeld
acf7ef3d61 Avoid retaining executor when using Connection::in_memory 2022-03-01 18:02:12 -08:00
Max Brunsfeld
95b2f4fb16 Fix remaining language server hangs on shutdown
* Use fork of async-pipe library that handles closed pipes correctly.
* Clear response handlers map when terminating output task, so as
  to wake any pending request futures.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 15:54:59 -08:00
Max Brunsfeld
917543cc32 Handle Peer responses using a futures::oneshot instead of postage::mpsc 2022-03-01 13:37:33 -08:00
Max Brunsfeld
f2f1a52c7e Prevent hangs in lsp requests made while server is shutting down
* Avoid postage::oneshot, since receiver is not woken when sender is dropped.
* Clear the response channels when an IO task exits.
2022-03-01 13:36:49 -08:00
Max Brunsfeld
74469a46ba Clean up tasks properly when dropping a FakeLanguageServer
* Make sure the fake's IO tasks are stopped
* Ensure that the fake's stdout is closed, so that the corresponding language
  server's IO tasks are woken up and halted.
2022-03-01 13:26:59 -08:00
Max Brunsfeld
0e6686916c Remove stray printing in db tests 2022-03-01 12:10:35 -08:00
Max Brunsfeld
43f856c568 Make integration tests depend only on a few core crates, not all of zed 2022-03-01 12:09:51 -08:00
Max Brunsfeld
2b64e8d4a2 Fix failure in test_unshare_project due to dropping handle outside of an update block
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 10:50:58 -08:00
Antonio Scandurra
efe7f61128 Use simulate_random_delay when polling snapshot only in tests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-01 19:17:38 +01:00
Antonio Scandurra
a25f21df39 Remove debug_elements_callbacks from App
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-01 19:16:58 +01:00
Antonio Scandurra
bc9c034baa Fix Presenter leak when removing windows 2022-03-01 18:50:05 +01:00
Antonio Scandurra
c661ff251d Revert "Use async_broadcast to emit fake FS events"
This reverts commit 4cfd345f9d, because
having a bounded broadcast introduces the possibility of waiting forever
when there isn't yet a receiver processing those events.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:14:40 +01:00
Antonio Scandurra
992328a6ee Forbid parking in project_panel::tests::test_visible_list
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:14:18 +01:00
Antonio Scandurra
0bb7189842 Use a weak handle to poll local worktree snapshot
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:08:10 +01:00
Antonio Scandurra
83a3402235 Make TestAppContext and its dependencies available only in tests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:01:52 +01:00
Antonio Scandurra
0d6f6bf5bb Detect when view handles are leaked
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 16:11:12 +01:00
Antonio Scandurra
aa03ebce0e Enable leak backtraces by setting LEAK_BACKTRACE=1
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 16:00:40 +01:00
Antonio Scandurra
4cfd345f9d Use async_broadcast to emit fake FS events
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 15:48:15 +01:00
Antonio Scandurra
3e9dbe10d6 Capture a weak reference to the Project in fake LSP 2022-03-01 13:34:03 +01:00
Antonio Scandurra
8d078ed4e2 Don't block when emitting fs events
Blocking could happen while processing events, which would cause the
background scanner to never make any further progress.
2022-03-01 13:08:50 +01:00
Antonio Scandurra
ce59e57e6d Remove project from host connection when unregistering it 2022-03-01 12:18:55 +01:00
Antonio Scandurra
466db69780 Pass a reference to TestAppContext in tests
This allows us to drop the context *after* we ran all futures to
completion and that's crucial otherwise we'll never drop entities
and/or flush effects.
2022-03-01 12:01:02 +01:00
Antonio Scandurra
8390f04e7d Allow capturing references in the future passed to Deterministic::run 2022-03-01 11:59:58 +01:00
Antonio Scandurra
7ce6f23ed4 Remove all windows on dropping TestAppContext
This allows us to remove the dropped entities and flush effects as
necessary.
2022-03-01 10:55:12 +01:00
Antonio Scandurra
10a872a370 Avoid reference cycle between Client and its models 2022-03-01 10:55:05 +01:00
Max Brunsfeld
471ecae82c WIP - include dhat for memory profiling tests 2022-02-28 22:52:21 -08:00
Max Brunsfeld
3b7cfad718 Try clearing Client's state at the ends of integration tests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-28 22:52:21 -08:00
Max Brunsfeld
02ae2d8a4f Hold client weakly in UserStore
This avoids a reference cycle that is causing some tests
to fail due to leaked handles at the moment. There may be
a better way to fix this though.
2022-02-28 22:47:50 -08:00
Max Brunsfeld
1faaa91e52 Avoid retaining executor in the FakeFs
This probably isn't the *root* cause of why an executor is leaked,
but by cutting off this cyclic references, it may make it a bit easier
to track down leaks of an executor.
2022-02-28 22:40:04 -08:00
Max Brunsfeld
3788efeadf Clean up guest connection states correctly when a collaborator disconnects
This bug was caught by running the executor until parked after tests.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-28 22:21:32 -08:00
Max Brunsfeld
c09921e790 Clear the executor at the end of a test by running until it is parked 2022-02-28 22:20:03 -08:00
Max Brunsfeld
426e0e3d4f Flush effects when dropping a TestAppContext
This way, at the end of a test, dropped entities will be removed, and will drop
the handles that they hold.
2022-02-28 22:17:20 -08:00
Max Brunsfeld
7d53e37672 Start work on detecting leaked handles in tests
For now, just track models. Tests fail because we don't
yet clear the app contexts at the right time.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-28 22:02:43 -08:00
Max Brunsfeld
d1d324e42b Never close buffers when sharing
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-28 11:36:43 -08:00
Antonio Scandurra
2111ec04c8 Make SearchProject a Foreground message
However, the randomized integration test is still failing:

```
ITERATIONS=100000 SEED=3027 OPERATIONS=200 cargo test --release test_random --package=zed-server -- --nocapture
```

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-28 16:19:34 +01:00
Antonio Scandurra
400a2fce58 Don't use a bounded channel for signaling that buffers have been opened
Blocking the sender could halt deserialization for no reason if nobody
is consuming the notifications.
2022-02-28 15:26:10 +01:00
Antonio Scandurra
1313ca8415 Don't delete buffer state when calling get_open_buffer
...as we might be in the process of completing a request that could
open a buffer. This was causing a failure in the randomized integration
test.
2022-02-28 14:27:31 +01:00
Antonio Scandurra
5f7a759870 Add project-wide search to randomized integration test 2022-02-28 14:22:31 +01:00
Antonio Scandurra
abdfdcdabf Include buffer's deferred ops when computing has_buffered_operations 2022-02-28 14:22:24 +01:00
Antonio Scandurra
720056d0db Add unit test for project search 2022-02-28 11:10:22 +01:00
Antonio Scandurra
ed89475cf6 Extract a common match_index_for_direction and active_match_index 2022-02-28 10:34:11 +01:00
Nathan Sobo
8eba96424e Fix warning 2022-02-27 18:17:15 -07:00
Nathan Sobo
cb230ad574 Re-activate the most recently-activated project search on cmd-shift-F
This commits adds the beginnings of an application state facility as a non-static place to store the most recently-activated search for each project.

I also store workspace items by descending order of their entity id so that we always fetch the newest item of a given type when calling `Workspace::item_of_type`.
2022-02-27 18:07:46 -07:00
Nathan Sobo
1ddae2adfd Focus the project find results editor on a tab in the query editor 2022-02-27 16:15:06 -07:00
Nathan Sobo
71241b1fb8 Add capture phase for action dispatch
Just like the DOM, we now bubble events down the tree during a capture phase before bubbling them back up.
2022-02-27 16:14:40 -07:00
Nathan Sobo
7d119dcd54 Select first match when results are ready 2022-02-27 14:24:06 -07:00
Nathan Sobo
7831979be0 Fix warning 2022-02-27 14:21:28 -07:00
Nathan Sobo
64d22925c2 Implement navigation between project search matches 2022-02-27 14:18:04 -07:00
Nathan Sobo
7ef98fb935 Make versions oldest_selection and newest_selection that don't require snapshots
I thought I needed this but actually didn't, but I still kinda think it's a good change for the public interface of Editor.
2022-02-27 13:02:09 -07:00
Nathan Sobo
19b5de2181 Introduce ProjectSearchView constructor
We had some duplication when cloning on split, so this is to unify that before we add any more complexity to construction.
2022-02-27 09:49:16 -07:00
Nathan Sobo
dabb17a2ef Clone editor's searchable state on split 2022-02-27 09:48:46 -07:00
Nathan Sobo
136699e7bd Add log dependency in search crate 2022-02-27 09:25:40 -07:00
Nathan Sobo
c7338ebe88 💄 2022-02-27 09:25:27 -07:00
Nathan Sobo
039765b698 Limit project search tab label to 24 characters
I'd love to fade the text out, but for now I just append an ellipsis.
2022-02-27 08:27:02 -07:00
Nathan Sobo
ec317159d7 Rename "find" to "search"
Search is both a verb and a noun, which makes it more natural to use in situations where we need to name a thing rather than a process.
2022-02-27 08:15:38 -07:00
Nathan Sobo
dd6f8d20a3 Remove carriage returns 2022-02-27 07:47:46 -07:00
Nathan Sobo
28b71cbc03 Select query when focusing query editor
Also: Clear the selection when we focus the results editor because we continue to render the selection even when the editor isn't focused and it looks awkward. Another approach we could take is to not render selections for non-focused editors, either always or with an option. But considering that we select all anyways next time we return focus to the query editor, I think this is ok for now.
2022-02-26 14:12:31 -07:00
Nathan Sobo
e96d0a9355 Activate the *newest* existing project find view on cmd-shift-F 2022-02-26 14:03:14 -07:00
Nathan Sobo
2f427769df Allow a new search to be created with cmd-enter
This replaces the `cmd-alt-shift-F` binding to open a new search. Instead, you can preserve the existing search results by entering a query and then hitting `cmd-enter` instead of `enter`. This opens a new project find view and restores the previous view to whatever query it was previously displaying. It's a bit strange, but I don't want to rely on splitting as the only way of creating multiple sets of search results.
2022-02-26 13:23:05 -07:00
Nathan Sobo
ae1a46a4e4 Render a magnifier icon and the query in project search tab
Also: Wire up events so the modified status updates correctly.
2022-02-26 08:21:38 -07:00
Antonio Scandurra
a78fe4ef6a Don't focus results editor on cmd-shift-f when there are no results 2022-02-26 14:43:02 +01:00
Antonio Scandurra
afea5a3d5e 🎨 2022-02-26 14:31:36 +01:00
Nathan Sobo
f6b7cbd5cf Always open a new project find on alt-cmd-shift-F 2022-02-25 19:48:43 -07:00
Nathan Sobo
60710fa5d5 Only store one nav history entry when opening excerpts
Also: Introduce the ability to disable and enable the nav history directly. This allows us to explicitly push an entry when opening excerpts and then disable all pushes as we open individual buffers.
2022-02-25 19:26:15 -07:00
Nathan Sobo
721258911c Open excerpts on alt-enter
Also: Remove special handling for alt-shift-D binding in diagnostics view that opens excerpts. Rely on alt-enter in all multi-buffers instead.
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 16:49:28 -07:00
Nathan Sobo
dea40c5d1a Don't show buffer search UI on ProjectSearchView
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 16:14:45 -07:00
Nathan Sobo
ed6c8b1836 Allow actions to be propagated from nested ViewContexts
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 16:14:16 -07:00
Nathan Sobo
d5cc3fea3d Implement Debug for keymap::MatchResult
Helpful when debugging issues with keystroke dispatch.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 16:13:53 -07:00
Nathan Sobo
92f411f01e Extract generic forward_project_request function on server
All these methods did the same thing with different message types.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 15:20:42 -07:00
Nathan Sobo
e822c6a64e Handle project-wide search on guests
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 15:09:47 -07:00
Max Brunsfeld
1278f5484f Add project search RPC messages 2022-02-25 12:38:31 -08:00
Max Brunsfeld
8dce91be23 Upgrade time crates to silence warning on Rust 1.59 2022-02-25 10:39:44 -08:00
Max Brunsfeld
9a97588f79 Eliminate RwLock around LanguageServer's outbound message channel
We observed a deadlock when quitting zed. The main thread was attempting
to acquire a write lock to this outbound message sender. We weren't able
to understand exactly how this occurred, but we removed the use of a
lock there, so this shouldn't happen anymore.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-25 10:04:57 -08:00
Antonio Scandurra
368301fcec Reuse a previous project find whenever possible
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-25 18:30:28 +01:00
Antonio Scandurra
e278c423d3 Don't assume that cloning on split will reuse the same underlying model
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-25 18:30:04 +01:00
Antonio Scandurra
7123407f42 Don't share query editor state after project find has been split
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-25 18:10:48 +01:00
Antonio Scandurra
1e04411066 Don't focus query editor if there are matches on tab switch 2022-02-25 17:23:03 +01:00
Antonio Scandurra
b506db7c93 Use the new split pane's navigation history when cloning an item 2022-02-25 17:22:30 +01:00
Antonio Scandurra
88bfe5acb0 Allow splitting project find and maintain the searches in sync 2022-02-25 16:20:02 +01:00
Antonio Scandurra
29e035a70d Don't report a buffer when it doesn't contain any matches 2022-02-25 15:40:19 +01:00
Antonio Scandurra
2611b5449f Always sync before clearing or removing excerpts from MultiBuffer
We don't have any test that proves this is needed but seems good nonetheless.
2022-02-25 15:36:43 +01:00
Antonio Scandurra
ff0fa0e0bd Gracefully handle passing an empty set of ranges to push_excerpts 2022-02-25 15:36:16 +01:00
Antonio Scandurra
f649074d36 Refine project find's UX
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-25 15:27:34 +01:00
Nathan Sobo
51c645f6b4 Toggle focus between query editor and results on cmd-shift-F 2022-02-25 05:04:45 -07:00
Antonio Scandurra
2147db9b41 Open searched buffers in parallel 2022-02-25 12:29:50 +01:00
Antonio Scandurra
5be93044f6 Focus results editor when project find matches are updated 2022-02-25 12:17:25 +01:00
Antonio Scandurra
561123d6de Avoid extra smol::channel when iterating through snapshot paths 2022-02-25 11:49:33 +01:00
Antonio Scandurra
6a0cca7178 Add a fast path for when the search query is empty 2022-02-25 10:58:45 +01:00
Antonio Scandurra
a077210873 Focus query editor when deploying project-find 2022-02-25 10:58:32 +01:00
Antonio Scandurra
7aacb63762 Respect field editor background, color and selection styling 2022-02-25 10:48:22 +01:00
Antonio Scandurra
0bf944e038 Use Project::search in ProjectFind and show search results 2022-02-25 10:32:45 +01:00
Max Brunsfeld
5644336df3 Merge branch 'main' into project-find 2022-02-24 17:22:09 -08:00
Max Brunsfeld
fb1103e26d Merge pull request #482 from zed-industries/c-support
Add C support with clangd
2022-02-24 17:16:55 -08:00
Max Brunsfeld
826a458162 Merge pull request #492 from zed-industries/editor-settings
Provide editor styling information separately from editor settings
2022-02-24 17:16:38 -08:00
Max Brunsfeld
47b654063e Provide editor styling information separately from editor settings
* Since regular editors' font sizes and families are controlled by
  the settings and not the theme, don't store a dummy text style in
  the theme. Instead, only store a font color, and synthesize
  the text style for regular editors using both the theme and the
  settings.
* Style single-line and auto-height editors (now called "field
  editors") using a single function that takes the entire theme and
  selects a relevant sub-object.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-24 16:42:00 -08:00
Antonio Scandurra
6d9b003634 WIP: Start sketching in ProjectFindView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-24 19:07:00 +01:00
Antonio Scandurra
e83d1fc9fc Start on a regex implementation of SearchQuery 2022-02-24 16:33:31 +01:00
Antonio Scandurra
76cc9b347e Extract a search module 2022-02-24 15:55:13 +01:00
Antonio Scandurra
6a323ce2dd Implement a basic project-wide search using Aho-Corasick 2022-02-24 15:33:56 +01:00
Antonio Scandurra
26f7f4f5b2 WIP: Remove ripgrep and start matching query for paths ourselves 2022-02-24 12:33:28 +01:00
Antonio Scandurra
119bfaa99f WIP 2022-02-24 11:57:53 +01:00
Antonio Scandurra
fed6f708c0 Start on project-wide find 2022-02-24 11:57:53 +01:00
Antonio Scandurra
39ebaebd83 Merge pull request #486 from zed-industries/background-highlights
Move `GetDocumentHighlights` to the background and fix collaboration race conditions
2022-02-24 10:17:28 +01:00
Antonio Scandurra
d929819c33 Fix warning 2022-02-24 09:52:25 +01:00
Antonio Scandurra
8fa23c702c Store ops if buffer handle can't be upgraded and buffer requests are in-flight 2022-02-24 09:32:31 +01:00
Max Brunsfeld
a6613d5345 Store operations for unknown buffers when there are outstanding buffer RPC requests 2022-02-23 20:35:05 -08:00
Max Brunsfeld
f1921c8df5 Open buffers from definitions request in random collab test
Don't try to open buffers from the weak worktrees directly, as this is
expected to fail if the host drops the buffer for that worktree.
2022-02-23 20:35:05 -08:00
Max Brunsfeld
51e2e9e68d Make client log message format more consistent 2022-02-23 18:18:52 -08:00
Max Brunsfeld
6060077444 Remove unused pending_updates field from RemoteWorktree 2022-02-23 16:59:39 -08:00
Max Brunsfeld
e9009d4edf Tweak logging in random collaboration test 2022-02-23 16:27:34 -08:00
Max Brunsfeld
e714b00c26 Improve logging around handling RPC requests on client 2022-02-23 15:37:51 -08:00
Max Brunsfeld
170487a528 Fix race conditions with LSP requests that return buffers
* Avoid panic when registering a buffer that was previously open,
  and whose weak handle was still present in the open_buffers map.
* Avoid releasing any buffers while a request is outstanding which
  could return a reference to a buffer.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-23 15:26:01 -08:00
Nathan Sobo
17c9aa1819 Remove ShareWorktree message
Instead, create an empty worktree on guests when a worktree is first *registered*, then update it via an initial UpdateWorktree message.

This prevents the host from referencing a worktree in definition RPC responses that hasn't yet been observed by the guest. We could have waited until the entire worktree was shared, but this could take a long time, so instead we create an empty one on guests and proceed from there.

We still have randomized test failures as of this commit:

SEED=9519 MAX_PEERS=2 ITERATIONS=10000 OPERATIONS=7 ct -p zed-server test_random_collaboration

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-23 11:56:09 -07:00
Antonio Scandurra
d1b4384f80 WIP 2022-02-23 19:04:22 +01:00
Antonio Scandurra
8440644dc9 Remove update_id from worktree update messages
We don't need this anymore because worktree updates are foreground
messages.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-23 18:35:25 +01:00
Antonio Scandurra
f3c6320eeb Move document highlights RPC message to the background 2022-02-23 16:16:02 +01:00
Antonio Scandurra
9e173564e9 Pass an AsyncAppContext to fake language server request handlers 2022-02-23 16:14:36 +01:00
Nathan Sobo
73fcebb8b2 Bump protocol version 2022-02-23 06:33:31 -07:00
Nathan Sobo
9841abf402 v0.17.0 2022-02-23 06:26:45 -07:00
Antonio Scandurra
6f77ede38e Merge pull request #483 from zed-industries/document-highlights
Show document highlights from the language server when moving the cursor
2022-02-23 10:38:15 +01:00
Max Brunsfeld
a14d0582ca Add C support with clangd 2022-02-22 17:21:21 -08:00
Max Brunsfeld
e140f70e3c Show document highlights from the language server when moving the cursor 2022-02-22 17:16:31 -08:00
Max Brunsfeld
0aeb23519f Merge pull request #481 from zed-industries/find-usages
Find-all-references
2022-02-22 15:10:47 -08:00
Max Brunsfeld
25d45378e4 Implement find-all-references
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 14:27:16 -08:00
Max Brunsfeld
a925df8696 Merge pull request #479 from zed-industries/project-symbols
Project symbols
2022-02-22 14:25:46 -08:00
Max Brunsfeld
6be4b1ef6a Don't select entire item when jumping to a project symbol
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:56:43 -08:00
Max Brunsfeld
5d2201c4ca Add integration test for project symbols
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:44:17 -08:00
Max Brunsfeld
669fe775df Normalize paths passed to the FakeFs
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:43:56 -08:00
Max Brunsfeld
dbe9c54857 Request definitions as guests in random collaboration integration test
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:03:45 -08:00
Max Brunsfeld
64098247cb Allow languages to be registered at any time
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-22 10:35:20 -08:00
Antonio Scandurra
d7db3791d5 Show worktree root name for symbol when there are multiple worktrees
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-22 18:57:41 +01:00
Antonio Scandurra
0e4bd4b418 Sign symbols so that we can trust opening buffers for them from guests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-22 18:43:16 +01:00
Antonio Scandurra
fad335b2ba Don't serialize the full LSP symbol when collaborating
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 18:08:43 +01:00
Antonio Scandurra
72ad3c2897 Render paths in ProjectSymbolsView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 17:48:14 +01:00
Antonio Scandurra
f0195ac3a3 Allow opening of buffers associated with a project symbol 2022-02-22 16:26:01 +01:00
Antonio Scandurra
2a6d486d14 Retrieve project symbols over RPC 2022-02-22 14:50:06 +01:00
Antonio Scandurra
ab73343323 WIP: Start on getting project symbols over RPC 2022-02-22 12:15:38 +01:00
Antonio Scandurra
326f1f43fe Syntax-highlight symbols based on their kind 2022-02-22 12:00:16 +01:00
Antonio Scandurra
d59ebb554b Update symbol matches as the query changes 2022-02-22 10:54:25 +01:00
Antonio Scandurra
8a8ae0fbcd Rename CompletionLabel to CodeLabel and add Project::symbols
This only works locally for now and we haven't implemented the
`RustLsp::label_for_symbol` method yet.
2022-02-22 10:01:08 +01:00
Antonio Scandurra
8f375a5026 Start on a new project_symbols crate 2022-02-22 08:42:12 +01:00
Nathan Sobo
882756d467 Merge pull request #475 from zed-industries/filter-input
Don't insert input in editor when control keys are pressed
2022-02-21 18:32:53 -08:00
Nathan Sobo
618f0a127a Don't insert input in editor when control keys are pressed 2022-02-21 18:21:27 -07:00
531 changed files with 79284 additions and 32617 deletions

View File

@@ -18,7 +18,9 @@ env:
jobs:
tests:
name: Run tests
runs-on: self-hosted
runs-on:
- self-hosted
- test
env:
RUSTFLAGS: -D warnings
steps:
@@ -29,6 +31,11 @@ jobs:
target: x86_64-apple-darwin
profile: minimal
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Checkout repo
uses: actions/checkout@v2
with:
@@ -36,10 +43,15 @@ jobs:
- name: Run tests
run: cargo test --workspace --no-fail-fast
- name: Build collab binaries
run: cargo build --bins --all-features
bundle:
name: Bundle app
runs-on: self-hosted
runs-on:
- self-hosted
- bundle
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
@@ -60,6 +72,11 @@ jobs:
target: aarch64-apple-darwin
profile: minimal
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Checkout repo
uses: actions/checkout@v2
with:

6
.gitignore vendored
View File

@@ -2,6 +2,8 @@
/zed.xcworkspace
.DS_Store
/script/node_modules
/crates/server/.env.toml
/crates/server/static/styles.css
/styles/node_modules
/crates/collab/.env.toml
/crates/collab/static/styles.css
/vendor/bin
/assets/themes/*.json

View File

@@ -1 +0,0 @@
collaborators = ["nathansobo", "as-cii", "maxbrunsfeld", "iamnbutler"]

4414
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,11 +6,11 @@ resolver = "2"
[patch.crates-io]
async-task = { git = "https://github.com/zed-industries/async-task", rev = "341b57d6de98cdfd7b418567b8de2022ca993a6e" }
# TODO - Remove when a version is released with this PR: https://github.com/servo/core-foundation-rs/pull/457
cocoa = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }
cocoa-foundation = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }
core-foundation = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }
core-foundation-sys = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }
core-graphics = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }
cocoa = { git = "https://github.com/servo/core-foundation-rs", rev = "079665882507dd5e2ff77db3de5070c1f6c0fb85" }
cocoa-foundation = { git = "https://github.com/servo/core-foundation-rs", rev = "079665882507dd5e2ff77db3de5070c1f6c0fb85" }
core-foundation = { git = "https://github.com/servo/core-foundation-rs", rev = "079665882507dd5e2ff77db3de5070c1f6c0fb85" }
core-foundation-sys = { git = "https://github.com/servo/core-foundation-rs", rev = "079665882507dd5e2ff77db3de5070c1f6c0fb85" }
core-graphics = { git = "https://github.com/servo/core-foundation-rs", rev = "079665882507dd5e2ff77db3de5070c1f6c0fb85" }
[profile.dev]
split-debuginfo = "unpacked"

View File

@@ -2,32 +2,22 @@
FROM rust:1.58-bullseye as builder
WORKDIR app
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs
COPY . .
# Install script dependencies
RUN --mount=type=cache,target=./script/node_modules \
cd ./script && npm install --quiet
# Build CSS
RUN --mount=type=cache,target=./script/node_modules \
script/build-css --release
# Compile server
# Compile collab server
RUN --mount=type=cache,target=./script/node_modules \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=./target \
cargo build --release --package zed-server --bin zed-server
cargo build --release --package collab --bin collab
# Copy server binary out of cached directory
# Copy collab server binary out of cached directory
RUN --mount=type=cache,target=./target \
cp /app/target/release/zed-server /app/zed-server
cp /app/target/release/collab /app/collab
# Copy server binary to the runtime image
# Copy collab server binary to the runtime image
FROM debian:bullseye-slim as runtime
RUN apt-get update; \
apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates
WORKDIR app
COPY --from=builder /app/zed-server /app
ENTRYPOINT ["/app/zed-server"]
COPY --from=builder /app/collab /app
ENTRYPOINT ["/app/collab"]

View File

@@ -11,5 +11,5 @@ RUN apt-get update; \
apt-get install -y --no-install-recommends libssl1.1
WORKDIR app
COPY --from=builder /app/bin/sqlx /app
COPY ./server/migrations /app/migrations
COPY ./crates/collab/migrations /app/migrations
ENTRYPOINT ["/app/sqlx", "migrate", "run"]

View File

@@ -1,2 +1,2 @@
web: cd ../zed.dev && PORT=3000 npx next dev
collab: cd crates/server && cargo run
collab: cd crates/collab && cargo run

View File

@@ -23,7 +23,7 @@ script/sqlx migrate run
script/seed-db
```
Run `zed.dev` and the collaboration server.
Run the web frontend and the collaboration server.
```
brew install foreman

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
assets/icons/accept.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.25 1L3.25 5L1 2.75" stroke="white" stroke-width="1.33333"/>
</svg>

After

Width:  |  Height:  |  Size: 171 B

View File

@@ -0,0 +1,3 @@
<svg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.2 5.0002C5.52563 5.0002 6.6 3.92563 6.6 2.6002C6.6 1.27476 5.52563 0.200195 4.2 0.200195C2.87438 0.200195 1.8 1.27476 1.8 2.6002C1.8 3.92563 2.87438 5.0002 4.2 5.0002ZM5.15063 5.9002H3.24938C1.45519 5.9002 0 7.3552 0 9.14957C0 9.50957 0.291 9.8002 0.649875 9.8002H7.7505C8.10938 9.8002 8.4 9.50957 8.4 9.14957C8.4 7.3552 6.945 5.9002 5.15063 5.9002ZM11.55 3.9502H10.65V3.0502C10.65 2.8027 10.4494 2.6002 10.2 2.6002C9.95063 2.6002 9.75 2.80176 9.75 3.0502V3.9502H8.85C8.6025 3.9502 8.4 4.1527 8.4 4.4002C8.4 4.6477 8.60156 4.8502 8.85 4.8502H9.75V5.7502C9.75 5.99957 9.9525 6.2002 10.2 6.2002C10.4475 6.2002 10.65 5.99863 10.65 5.7502V4.8502H11.55C11.7994 4.8502 12 4.64957 12 4.4002C12 4.15082 11.7994 3.9502 11.55 3.9502Z" fill="#9C9C9C"/>
</svg>

After

Width:  |  Height:  |  Size: 857 B

View File

Before

Width:  |  Height:  |  Size: 979 B

After

Width:  |  Height:  |  Size: 979 B

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.2 7C6.52563 7 7.6 5.92544 7.6 4.6C7.6 3.27456 6.52563 2.2 5.2 2.2C3.87438 2.2 2.8 3.27456 2.8 4.6C2.8 5.92544 3.87438 7 5.2 7ZM6.15063 7.9H4.24938C2.45444 7.9 1 9.355 1 11.1494C1 11.5094 1.291 11.8 1.64988 11.8H8.74938C9.10938 11.8 9.4 11.5094 9.4 11.1494C9.4 9.355 7.945 7.9 6.15063 7.9ZM9.98313 8.2H8.59844C9.46 8.90688 10 9.96438 10 11.1494C10 11.3894 9.92875 11.6106 9.8125 11.8H12.4C12.7319 11.8 13 11.53 13 11.1831C13 9.5425 11.6575 8.2 9.98313 8.2ZM9.1 7C10.2606 7 11.2 6.06063 11.2 4.9C11.2 3.73938 10.2606 2.8 9.1 2.8C8.62919 2.8 8.19925 2.96041 7.849 3.22206C8.065 3.63681 8.2 4.10125 8.2 4.6C8.2 5.266 7.97631 5.87763 7.60769 6.37581C7.98813 6.76 8.515 7 9.1 7Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 804 B

3
assets/icons/decline.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 7L4 4M7 1L4 4M4 4L1 1M4 4L7 7" stroke="#9C9C9C" stroke-width="1.33333"/>
</svg>

After

Width:  |  Height:  |  Size: 184 B

View File

Before

Width:  |  Height:  |  Size: 464 B

After

Width:  |  Height:  |  Size: 464 B

View File

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

View File

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 317 B

View File

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 284 B

View File

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 512 B

View File

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 516 B

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 10C3.58579 10 3.25 10.3358 3.25 10.75C3.25 11.1642 3.58579 11.5 4 11.5V10ZM10 11.5C10.4142 11.5 10.75 11.1642 10.75 10.75C10.75 10.3358 10.4142 10 10 10V11.5ZM7.75 3.5C7.75 3.08579 7.41421 2.75 7 2.75C6.58579 2.75 6.25 3.08579 6.25 3.5H7.75ZM7 8L6.51191 8.56944C6.79277 8.81019 7.20723 8.81019 7.48809 8.56944L7 8ZM9.23809 7.06944C9.55259 6.79988 9.58901 6.3264 9.31944 6.01191C9.04988 5.69741 8.5764 5.66099 8.26191 5.93056L9.23809 7.06944ZM5.73809 5.93056C5.4236 5.66099 4.95012 5.69741 4.68056 6.01191C4.41099 6.3264 4.44741 6.79988 4.76191 7.06944L5.73809 5.93056ZM4 11.5H10V10H4V11.5ZM6.25 3.5V8H7.75V3.5H6.25ZM7.48809 8.56944L9.23809 7.06944L8.26191 5.93056L6.51191 7.43056L7.48809 8.56944ZM7.48809 7.43056L5.73809 5.93056L4.76191 7.06944L6.51191 8.56944L7.48809 7.43056Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 909 B

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 11.5C9.48528 11.5 11.5 9.48528 11.5 7C11.5 4.51472 9.48528 2.5 7 2.5C4.51472 2.5 2.5 4.51472 2.5 7C2.5 9.48528 4.51472 11.5 7 11.5ZM4.91475 5.71025L6.2045 7L4.91475 8.28975L5.71025 9.08525L7 7.79549L8.28975 9.08525L9.08525 8.28975L7.79549 7L9.08525 5.71025L8.28975 4.91475L7 6.2045L5.71025 4.91475L4.91475 5.71025Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 486 B

View File

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.3333 2.33333H10L9.33333 1.66666H7.66667C7.29958 1.66666 7 1.96625 7 2.33333V5.66666C7 6.03375 7.29958 6.33333 7.66667 6.33333H12.3333C12.7004 6.33333 13 6.03375 13 5.66666V3C13 2.63291 12.7 2.33333 12.3333 2.33333ZM12.3333 8.33333H10L9.33333 7.66666H7.66667C7.29958 7.66666 7 7.96625 7 8.33333V11.6667C7 12.0337 7.29958 12.3333 7.66667 12.3333H12.3333C12.7004 12.3333 13 12.0337 13 11.6667V9C13 8.63333 12.7 8.33333 12.3333 8.33333ZM2.33333 2C2.33333 1.8151 2.185 1.66666 2 1.66666H1.33333C1.14844 1.66666 1 1.815 1 2V10.3333C1 10.7004 1.29958 11 1.66667 11H6.33333V9.66666H2.33333V5H6.33333V3.66666H2.33333V2Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 743 B

3
assets/icons/jump.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.5 1.02501V6.27499C7.5 6.56484 7.26484 6.79999 6.975 6.79999C6.68516 6.79999 6.45 6.56484 6.45 6.27499V2.29157L1.3969 7.34468C1.29365 7.44968 1.15934 7.49999 1.02503 7.49999C0.890713 7.49999 0.756401 7.44871 0.653808 7.34619C0.448731 7.14111 0.448731 6.80894 0.653808 6.60375L5.70844 1.55001H1.72502C1.43518 1.55001 1.20002 1.31595 1.20002 1.02501C1.20002 0.734077 1.43518 0.500015 1.72502 0.500015H6.975C7.26594 0.500015 7.5 0.736264 7.5 1.02501Z" fill="white" fill-opacity="0.6"/>
</svg>

After

Width:  |  Height:  |  Size: 593 B

3
assets/icons/lock-8.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.75 3V2.25C1.75 1.00734 2.75781 0 4 0C5.24219 0 6.25 1.00734 6.25 2.25V3H6.5C7.05156 3 7.5 3.44844 7.5 4V7C7.5 7.55156 7.05156 8 6.5 8H1.5C0.947656 8 0.5 7.55156 0.5 7V4C0.5 3.44844 0.947656 3 1.5 3H1.75ZM2.75 3H5.25V2.25C5.25 1.55969 4.69063 1 4 1C3.30938 1 2.75 1.55969 2.75 2.25V3Z" fill="#8B8792"/>
</svg>

After

Width:  |  Height:  |  Size: 413 B

View File

@@ -0,0 +1,3 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.0893 10.4092L8.34129 7.66113C8.93602 6.93311 9.26414 6.01641 9.26414 5.01562C9.26414 2.65928 7.35425 0.75 4.99851 0.75C2.64278 0.75 0.751343 2.65989 0.751343 5.01562C0.751343 7.37136 2.66103 9.28125 4.99851 9.28125C5.99909 9.28125 6.91702 8.93446 7.64402 8.35758L10.3921 11.1056C10.5069 11.2028 10.6341 11.25 10.7592 11.25C10.8843 11.25 11.011 11.2019 11.1072 11.1058C11.2985 10.9137 11.2985 10.602 11.0893 10.4092ZM1.73572 5.01562C1.73572 3.20643 3.20777 1.73438 5.01697 1.73438C6.82617 1.73438 8.29822 3.20643 8.29822 5.01562C8.29822 6.82482 6.82617 8.29688 5.01697 8.29688C3.20777 8.29688 1.73572 6.82441 1.73572 5.01562Z" fill="white" fill-opacity="0.5"/>
</svg>

After

Width:  |  Height:  |  Size: 776 B

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 11.5C9.48528 11.5 11.5 9.48528 11.5 7C11.5 4.51472 9.48528 2.5 7 2.5C4.51472 2.5 2.5 4.51472 2.5 7C2.5 9.48528 4.51472 11.5 7 11.5ZM9.64775 5.71025L8.85225 4.91475L6.15625 7.61076L5.14775 6.60225L4.35225 7.39775L6.15625 9.20174L9.64775 5.71025Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

3
assets/icons/share.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg width="12" height="14" viewBox="0 0 12 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.0002 0.333344C2.77885 0.333344 0.16687 2.94532 0.16687 6.16668C0.16687 8.56824 1.61921 10.6302 3.69291 11.5234C3.60229 10.9831 3.53223 10.4404 3.51062 10.0091C2.25203 9.19011 1.41661 7.77605 1.41661 6.16668C1.41661 3.63933 3.4726 1.58334 5.99994 1.58334C8.52729 1.58334 10.5833 3.63933 10.5833 6.16668C10.5833 7.77579 9.74786 9.19011 8.48979 10.0104C8.46791 10.4401 8.39734 10.9836 8.30645 11.5253C10.38 10.6302 11.8331 8.56772 11.8331 6.16668C11.8331 2.94532 9.22117 0.333344 5.99981 0.333344H6.0002ZM6.0002 8.45834C5.14395 8.45834 4.33354 8.68295 4.33354 9.59767C4.33354 10.4604 4.66895 12.3138 4.87052 13.056C5.00541 13.5521 5.50802 13.6667 6.0002 13.6667C6.49239 13.6667 6.9963 13.5527 7.12989 13.0578C7.33093 12.3099 7.66687 10.4583 7.66687 9.59897C7.66687 8.6823 6.85697 8.45834 6.0002 8.45834ZM6.0002 7.62501C6.80619 7.62501 7.45854 6.97267 7.45854 6.16668C7.45854 5.36069 6.78406 4.70834 6.0002 4.70834C5.21635 4.70834 4.54187 5.35939 4.54187 6.16668C4.54187 6.97397 5.19291 7.62501 6.0002 7.62501ZM9.7502 6.16668C9.7502 4.09558 8.0713 2.41668 6.0002 2.41668C3.92911 2.41668 2.2502 4.09636 2.2502 6.16668C2.2502 7.33413 2.79499 8.36407 3.63145 9.05209C3.75776 8.72267 3.99942 8.37814 4.46609 8.13959C4.46635 8.13803 4.47416 8.13803 4.47937 8.13803C3.88822 7.6797 3.5002 6.97136 3.5002 6.16668C3.5002 4.78595 4.61947 3.66668 6.0002 3.66668C7.38093 3.66668 8.5002 4.78595 8.5002 6.16668C8.5002 6.97189 8.11296 7.68048 7.52182 8.13751C7.5252 8.13803 7.53484 8.13855 7.53406 8.13933C8.00098 8.37788 8.24213 8.72215 8.36869 9.05183C9.20567 8.36433 9.74994 7.33308 9.74994 6.16642L9.7502 6.16668Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5 11.5H2.5V9.7L6.4375 2.5H7.5625L11.5 9.7V11.5ZM6.4375 4.9H7.5625V7.9H6.4375V4.9ZM6.4375 9.1H7.5625V10.3H6.4375V9.1Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 289 B

View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 322 B

356
assets/keymaps/default.json Normal file
View File

@@ -0,0 +1,356 @@
[
// Standard macOS bindings
{
"bindings": {
"up": "menu::SelectPrev",
"ctrl-p": "menu::SelectPrev",
"down": "menu::SelectNext",
"ctrl-n": "menu::SelectNext",
"cmd-up": "menu::SelectFirst",
"cmd-down": "menu::SelectLast",
"enter": "menu::Confirm",
"escape": "menu::Cancel",
"ctrl-c": "menu::Cancel",
"shift-cmd-{": "pane::ActivatePrevItem",
"shift-cmd-}": "pane::ActivateNextItem",
"cmd-w": "pane::CloseActiveItem",
"cmd-shift-W": "workspace::CloseWindow",
"alt-cmd-t": "pane::CloseInactiveItems",
"cmd-s": "workspace::Save",
"cmd-shift-S": "workspace::SaveAs",
"cmd-=": "zed::IncreaseBufferFontSize",
"cmd--": "zed::DecreaseBufferFontSize",
"cmd-0": "zed::ResetBufferFontSize",
"cmd-,": "zed::OpenSettings",
"cmd-q": "zed::Quit",
"cmd-n": "workspace::NewFile",
"cmd-shift-N": "workspace::NewWindow",
"cmd-o": "workspace::Open"
}
},
{
"context": "Editor",
"bindings": {
"escape": "editor::Cancel",
"backspace": "editor::Backspace",
"shift-backspace": "editor::Backspace",
"ctrl-h": "editor::Backspace",
"delete": "editor::Delete",
"ctrl-d": "editor::Delete",
"tab": "editor::Tab",
"shift-tab": "editor::TabPrev",
"ctrl-k": "editor::CutToEndOfLine",
"ctrl-t": "editor::Transpose",
"cmd-backspace": "editor::DeleteToBeginningOfLine",
"cmd-delete": "editor::DeleteToEndOfLine",
"alt-backspace": "editor::DeleteToPreviousWordStart",
"alt-delete": "editor::DeleteToNextWordEnd",
"alt-h": "editor::DeleteToPreviousWordStart",
"alt-d": "editor::DeleteToNextWordEnd",
"cmd-x": "editor::Cut",
"cmd-c": "editor::Copy",
"cmd-v": "editor::Paste",
"cmd-z": "editor::Undo",
"cmd-shift-Z": "editor::Redo",
"up": "editor::MoveUp",
"down": "editor::MoveDown",
"left": "editor::MoveLeft",
"right": "editor::MoveRight",
"ctrl-p": "editor::MoveUp",
"ctrl-n": "editor::MoveDown",
"ctrl-b": "editor::MoveLeft",
"ctrl-f": "editor::MoveRight",
"alt-left": "editor::MoveToPreviousWordStart",
"alt-b": "editor::MoveToPreviousWordStart",
"alt-right": "editor::MoveToNextWordEnd",
"alt-f": "editor::MoveToNextWordEnd",
"cmd-left": "editor::MoveToBeginningOfLine",
"ctrl-a": "editor::MoveToBeginningOfLine",
"cmd-right": "editor::MoveToEndOfLine",
"ctrl-e": "editor::MoveToEndOfLine",
"cmd-up": "editor::MoveToBeginning",
"cmd-down": "editor::MoveToEnd",
"shift-up": "editor::SelectUp",
"ctrl-shift-P": "editor::SelectUp",
"shift-down": "editor::SelectDown",
"ctrl-shift-N": "editor::SelectDown",
"shift-left": "editor::SelectLeft",
"ctrl-shift-B": "editor::SelectLeft",
"shift-right": "editor::SelectRight",
"ctrl-shift-F": "editor::SelectRight",
"alt-shift-left": "editor::SelectToPreviousWordStart",
"alt-shift-B": "editor::SelectToPreviousWordStart",
"alt-shift-right": "editor::SelectToNextWordEnd",
"alt-shift-F": "editor::SelectToNextWordEnd",
"cmd-shift-up": "editor::SelectToBeginning",
"cmd-shift-down": "editor::SelectToEnd",
"cmd-a": "editor::SelectAll",
"cmd-l": "editor::SelectLine",
"cmd-shift-left": [
"editor::SelectToBeginningOfLine",
{
"stop_at_soft_wraps": true
}
],
"ctrl-shift-A": [
"editor::SelectToBeginningOfLine",
{
"stop_at_soft_wraps": true
}
],
"cmd-shift-right": [
"editor::SelectToEndOfLine",
{
"stop_at_soft_wraps": true
}
],
"ctrl-shift-E": [
"editor::SelectToEndOfLine",
{
"stop_at_soft_wraps": true
}
],
"pageup": "editor::PageUp",
"pagedown": "editor::PageDown"
}
},
{
"context": "Editor && mode == full",
"bindings": {
"enter": "editor::Newline",
"cmd-f": [
"buffer_search::Deploy",
{
"focus": true
}
],
"cmd-e": [
"buffer_search::Deploy",
{
"focus": false
}
]
}
},
{
"context": "Editor && mode == auto_height",
"bindings": {
"alt-enter": [
"editor::Input",
"\n"
]
}
},
{
"context": "BufferSearchBar",
"bindings": {
"escape": "buffer_search::Dismiss",
"cmd-f": "buffer_search::FocusEditor",
"enter": "search::SelectNextMatch",
"shift-enter": "search::SelectPrevMatch"
}
},
{
"context": "Pane",
"bindings": {
"cmd-f": "project_search::ToggleFocus",
"cmd-g": "search::SelectNextMatch",
"cmd-shift-G": "search::SelectPrevMatch",
"alt-cmd-c": "search::ToggleCaseSensitive",
"alt-cmd-w": "search::ToggleWholeWord",
"alt-cmd-r": "search::ToggleRegex"
}
},
// Bindings from VS Code
{
"context": "Editor",
"bindings": {
"cmd-[": "editor::Outdent",
"cmd-]": "editor::Indent",
"cmd-alt-up": "editor::AddSelectionAbove",
"cmd-ctrl-p": "editor::AddSelectionAbove",
"cmd-alt-down": "editor::AddSelectionBelow",
"cmd-ctrl-n": "editor::AddSelectionBelow",
"cmd-d": [
"editor::SelectNext",
{
"replace_newest": false
}
],
"cmd-k cmd-d": [
"editor::SelectNext",
{
"replace_newest": true
}
],
"cmd-/": "editor::ToggleComments",
"alt-up": "editor::SelectLargerSyntaxNode",
"alt-down": "editor::SelectSmallerSyntaxNode",
"cmd-u": "editor::UndoSelection",
"cmd-shift-U": "editor::RedoSelection",
"f8": "editor::GoToNextDiagnostic",
"shift-f8": "editor::GoToPrevDiagnostic",
"f2": "editor::Rename",
"f12": "editor::GoToDefinition",
"alt-shift-f12": "editor::FindAllReferences",
"ctrl-m": "editor::MoveToEnclosingBracket",
"alt-cmd-[": "editor::Fold",
"alt-cmd-]": "editor::UnfoldLines",
"ctrl-space": "editor::ShowCompletions",
"cmd-.": "editor::ToggleCodeActions"
}
},
{
"context": "Editor && mode == full",
"bindings": {
"cmd-shift-O": "outline::Toggle",
"ctrl-g": "go_to_line::Toggle"
}
},
{
"context": "Pane",
"bindings": {
"ctrl--": "pane::GoBack",
"shift-ctrl-_": "pane::GoForward",
"cmd-shift-T": "pane::ReopenClosedItem",
"cmd-shift-F": "project_search::ToggleFocus"
}
},
{
"context": "Workspace",
"bindings": {
"cmd-shift-F": "project_search::Deploy",
"cmd-k cmd-t": "theme_selector::Toggle",
"cmd-k cmd-s": "zed::OpenKeymap",
"cmd-t": "project_symbols::Toggle",
"cmd-p": "file_finder::Toggle",
"cmd-shift-P": "command_palette::Toggle",
"cmd-shift-M": "diagnostics::Deploy",
"cmd-alt-s": "workspace::SaveAll"
}
},
// Bindings from Sublime Text
{
"context": "Editor",
"bindings": {
"ctrl-shift-K": "editor::DeleteLine",
"cmd-shift-D": "editor::DuplicateLine",
"cmd-shift-L": "editor::SplitSelectionIntoLines",
"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",
"ctrl-alt-d": "editor::DeleteToNextSubwordEnd",
"ctrl-alt-left": "editor::MoveToPreviousSubwordStart",
"ctrl-alt-b": "editor::MoveToPreviousSubwordStart",
"ctrl-alt-right": "editor::MoveToNextSubwordEnd",
"ctrl-alt-f": "editor::MoveToNextSubwordEnd",
"ctrl-alt-shift-left": "editor::SelectToPreviousSubwordStart",
"ctrl-alt-shift-B": "editor::SelectToPreviousSubwordStart",
"ctrl-alt-shift-right": "editor::SelectToNextSubwordEnd",
"ctrl-alt-shift-F": "editor::SelectToNextSubwordEnd"
}
},
{
"bindings": {
"cmd-k cmd-left": "workspace::ActivatePreviousPane",
"cmd-k cmd-right": "workspace::ActivateNextPane"
}
},
// Bindings from Atom
{
"context": "Pane",
"bindings": {
"cmd-k up": "pane::SplitUp",
"cmd-k down": "pane::SplitDown",
"cmd-k left": "pane::SplitLeft",
"cmd-k right": "pane::SplitRight"
}
},
// Bindings that should be unified with bindings for more general actions
{
"context": "Editor && renaming",
"bindings": {
"enter": "editor::ConfirmRename"
}
},
{
"context": "Editor && showing_completions",
"bindings": {
"enter": "editor::ConfirmCompletion",
"tab": "editor::ConfirmCompletion"
}
},
{
"context": "Editor && showing_code_actions",
"bindings": {
"enter": "editor::ConfirmCodeAction"
}
},
// Custom bindings
{
"bindings": {
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
"cmd-alt-i": "zed::DebugElements"
}
},
{
"context": "Editor",
"bindings": {
"alt-enter": "editor::OpenExcerpts"
}
},
{
"context": "ProjectSearchBar",
"bindings": {
"cmd-enter": "project_search::SearchInNew"
}
},
{
"context": "Workspace",
"bindings": {
"cmd-1": [
"workspace::ToggleSidebarItemFocus",
{
"side": "Left",
"item_index": 0
}
],
"cmd-shift-!": [
"workspace::ToggleSidebarItem",
{
"side": "Left",
"item_index": 0
}
],
"cmd-9": [
"workspace::ToggleSidebarItemFocus",
{
"side": "Right",
"item_index": 0
}
],
"cmd-shift-(": [
"workspace::ToggleSidebarItem",
{
"side": "Right",
"item_index": 0
}
]
}
},
{
"context": "ProjectPanel",
"bindings": {
"left": "project_panel::CollapseSelectedEntry",
"right": "project_panel::ExpandSelectedEntry",
"cmd-x": "project_panel::Cut",
"cmd-c": "project_panel::Copy",
"cmd-v": "project_panel::Paste",
"cmd-alt-c": "project_panel::CopyPath",
"f2": "project_panel::Rename",
"backspace": "project_panel::Delete"
}
}
]

156
assets/keymaps/vim.json Normal file
View File

@@ -0,0 +1,156 @@
[
{
"context": "Editor && VimControl",
"bindings": {
"g": [
"vim::PushOperator",
{
"Namespace": "G"
}
],
"h": "vim::Left",
"backspace": "vim::Left",
"j": "vim::Down",
"k": "vim::Up",
"l": "vim::Right",
"0": "vim::StartOfLine",
"shift-$": "vim::EndOfLine",
"shift-G": "vim::EndOfDocument",
"w": "vim::NextWordStart",
"shift-W": [
"vim::NextWordStart",
{
"ignorePunctuation": true
}
],
"e": "vim::NextWordEnd",
"shift-E": [
"vim::NextWordEnd",
{
"ignorePunctuation": true
}
],
"b": "vim::PreviousWordStart",
"shift-B": [
"vim::PreviousWordStart",
{
"ignorePunctuation": true
}
],
"escape": [
"vim::SwitchMode",
"Normal"
]
}
},
{
"context": "Editor && vim_mode == normal",
"bindings": {
"escape": "editor::Cancel",
"c": [
"vim::PushOperator",
"Change"
],
"shift-C": "vim::ChangeToEndOfLine",
"d": [
"vim::PushOperator",
"Delete"
],
"shift-D": "vim::DeleteToEndOfLine",
"y": [
"vim::PushOperator",
"Yank"
],
"i": [
"vim::SwitchMode",
"Insert"
],
"shift-I": "vim::InsertFirstNonWhitespace",
"a": "vim::InsertAfter",
"shift-A": "vim::InsertEndOfLine",
"x": "vim::DeleteRight",
"shift-X": "vim::DeleteLeft",
"shift-^": "vim::FirstNonWhitespace",
"o": "vim::InsertLineBelow",
"shift-O": "vim::InsertLineAbove",
"v": [
"vim::SwitchMode",
{
"Visual": {
"line": false
}
}
],
"shift-V": [
"vim::SwitchMode",
{
"Visual": {
"line": true
}
}
],
"p": "vim::Paste",
"u": "editor::Undo",
"ctrl-r": "editor::Redo",
"ctrl-o": "pane::GoBack"
}
},
{
"context": "Editor && vim_operator == g",
"bindings": {
"g": "vim::StartOfDocument",
"h": "editor::Hover",
"escape": [
"vim::SwitchMode",
"Normal"
]
}
},
{
"context": "Editor && vim_operator == c",
"bindings": {
"w": "vim::ChangeWord",
"shift-W": [
"vim::ChangeWord",
{
"ignorePunctuation": true
}
],
"c": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_operator == d",
"bindings": {
"d": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_operator == y",
"bindings": {
"y": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_mode == visual",
"bindings": {
"c": "vim::VisualChange",
"d": "vim::VisualDelete",
"x": "vim::VisualDelete",
"y": "vim::VisualYank"
}
},
{
"context": "Editor && vim_mode == insert",
"bindings": {
"escape": "vim::NormalBefore",
"ctrl-c": "vim::NormalBefore"
}
},
{
"context": "Editor && mode == singleline",
"bindings": {
"escape": "editor::Cancel"
}
}
]

0
assets/themes/.gitkeep Normal file
View File

14
crates/assets/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "assets"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/assets.rs"
doctest = false
[dependencies]
gpui = { path = "../gpui" }
anyhow = "1.0.38"
rust-embed = { version = "6.3", features = ["include-exclude"] }

View File

@@ -3,7 +3,7 @@ use gpui::AssetSource;
use rust_embed::RustEmbed;
#[derive(RustEmbed)]
#[folder = "assets"]
#[folder = "../../assets"]
#[exclude = "*.DS_Store"]
pub struct Assets;

View File

@@ -0,0 +1,26 @@
[package]
name = "auto_update"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/auto_update.rs"
doctest = false
[dependencies]
client = { path = "../client" }
gpui = { path = "../gpui" }
menu = { path = "../menu" }
project = { path = "../project" }
settings = { path = "../settings" }
theme = { path = "../theme" }
workspace = { path = "../workspace" }
util = { path = "../util" }
anyhow = "1.0.38"
isahc = "1.7"
lazy_static = "1.4"
log = "0.4"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
smol = "1.2.5"
tempdir = "0.3.7"

View File

@@ -0,0 +1,377 @@
mod update_notification;
use anyhow::{anyhow, Context, Result};
use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN};
use gpui::{
actions,
elements::{Empty, MouseEventHandler, Text},
platform::AppVersion,
AppContext, AsyncAppContext, Element, Entity, ModelContext, ModelHandle, MutableAppContext,
Task, View, ViewContext, WeakViewHandle,
};
use lazy_static::lazy_static;
use serde::Deserialize;
use settings::Settings;
use smol::{fs::File, io::AsyncReadExt, process::Command};
use std::{env, ffi::OsString, path::PathBuf, sync::Arc, time::Duration};
use update_notification::UpdateNotification;
use workspace::{ItemHandle, StatusItemView, Workspace};
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &'static str =
"auto-updater-should-show-updated-notification";
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
lazy_static! {
pub static ref ZED_APP_VERSION: Option<AppVersion> = env::var("ZED_APP_VERSION")
.ok()
.and_then(|v| v.parse().ok());
pub static ref ZED_APP_PATH: Option<PathBuf> = env::var("ZED_APP_PATH").ok().map(PathBuf::from);
}
actions!(auto_update, [Check, DismissErrorMessage, ViewReleaseNotes]);
#[derive(Clone, PartialEq, Eq)]
pub enum AutoUpdateStatus {
Idle,
Checking,
Downloading,
Installing,
Updated,
Errored,
}
pub struct AutoUpdater {
status: AutoUpdateStatus,
current_version: AppVersion,
http_client: Arc<dyn HttpClient>,
pending_poll: Option<Task<()>>,
db: Arc<project::Db>,
server_url: String,
}
pub struct AutoUpdateIndicator {
updater: Option<ModelHandle<AutoUpdater>>,
}
#[derive(Deserialize)]
struct JsonRelease {
version: String,
url: String,
}
impl Entity for AutoUpdater {
type Event = ();
}
pub fn init(
db: Arc<project::Db>,
http_client: Arc<dyn HttpClient>,
server_url: String,
cx: &mut MutableAppContext,
) {
if let Some(version) = ZED_APP_VERSION.clone().or(cx.platform().app_version().ok()) {
let auto_updater = cx.add_model(|cx| {
let updater = AutoUpdater::new(version, db.clone(), http_client, server_url.clone());
updater.start_polling(cx).detach();
updater
});
cx.set_global(Some(auto_updater));
cx.add_global_action(|_: &Check, cx| {
if let Some(updater) = AutoUpdater::get(cx) {
updater.update(cx, |updater, cx| updater.poll(cx));
}
});
cx.add_global_action(move |_: &ViewReleaseNotes, cx| {
cx.platform().open_url(&format!("{server_url}/releases"));
});
cx.add_action(AutoUpdateIndicator::dismiss_error_message);
cx.add_action(UpdateNotification::dismiss);
}
}
pub fn notify_of_any_new_update(
workspace: WeakViewHandle<Workspace>,
cx: &mut MutableAppContext,
) -> Option<()> {
let updater = AutoUpdater::get(cx)?;
let version = updater.read(cx).current_version;
let should_show_notification = updater.read(cx).should_show_update_notification(cx);
cx.spawn(|mut cx| async move {
let should_show_notification = should_show_notification.await?;
if should_show_notification {
if let Some(workspace) = workspace.upgrade(&cx) {
workspace.update(&mut cx, |workspace, cx| {
workspace.show_notification(0, cx, |cx| {
cx.add_view(|_| UpdateNotification::new(version))
});
updater
.read(cx)
.set_should_show_update_notification(false, cx)
.detach_and_log_err(cx);
});
}
}
anyhow::Ok(())
})
.detach();
None
}
impl AutoUpdater {
fn get(cx: &mut MutableAppContext) -> Option<ModelHandle<Self>> {
cx.default_global::<Option<ModelHandle<Self>>>().clone()
}
fn new(
current_version: AppVersion,
db: Arc<project::Db>,
http_client: Arc<dyn HttpClient>,
server_url: String,
) -> Self {
Self {
status: AutoUpdateStatus::Idle,
current_version,
db,
http_client,
server_url,
pending_poll: None,
}
}
pub fn start_polling(&self, cx: &mut ModelContext<Self>) -> Task<()> {
cx.spawn(|this, mut cx| async move {
loop {
this.update(&mut cx, |this, cx| this.poll(cx));
cx.background().timer(POLL_INTERVAL).await;
}
})
}
pub fn poll(&mut self, cx: &mut ModelContext<Self>) {
if self.pending_poll.is_some() || self.status == AutoUpdateStatus::Updated {
return;
}
self.status = AutoUpdateStatus::Checking;
cx.notify();
self.pending_poll = Some(cx.spawn(|this, mut cx| async move {
let result = Self::update(this.clone(), cx.clone()).await;
this.update(&mut cx, |this, cx| {
this.pending_poll = None;
if let Err(error) = result {
log::error!("auto-update failed: error:{:?}", error);
this.status = AutoUpdateStatus::Errored;
cx.notify();
}
});
}));
}
async fn update(this: ModelHandle<Self>, mut cx: AsyncAppContext) -> Result<()> {
let (client, server_url, current_version) = this.read_with(&cx, |this, _| {
(
this.http_client.clone(),
this.server_url.clone(),
this.current_version,
)
});
let mut response = client
.get(
&format!("{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg"),
Default::default(),
true,
)
.await?;
let mut body = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.context("error reading release")?;
let release: JsonRelease =
serde_json::from_slice(body.as_slice()).context("error deserializing release")?;
let latest_version = release.version.parse::<AppVersion>()?;
if latest_version <= current_version {
this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Idle;
cx.notify();
});
return Ok(());
}
this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Downloading;
cx.notify();
});
let temp_dir = tempdir::TempDir::new("zed-auto-update")?;
let dmg_path = temp_dir.path().join("Zed.dmg");
let mount_path = temp_dir.path().join("Zed");
let mut mounted_app_path: OsString = mount_path.join("Zed.app").into();
mounted_app_path.push("/");
let running_app_path = ZED_APP_PATH
.clone()
.map_or_else(|| cx.platform().app_path(), Ok)?;
let mut dmg_file = File::create(&dmg_path).await?;
let mut response = client.get(&release.url, Default::default(), true).await?;
smol::io::copy(response.body_mut(), &mut dmg_file).await?;
log::info!("downloaded update. path:{:?}", dmg_path);
this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Installing;
cx.notify();
});
let output = Command::new("hdiutil")
.args(&["attach", "-nobrowse"])
.arg(&dmg_path)
.arg("-mountroot")
.arg(&temp_dir.path())
.output()
.await?;
if !output.status.success() {
Err(anyhow!(
"failed to mount: {:?}",
String::from_utf8_lossy(&output.stderr)
))?;
}
let output = Command::new("rsync")
.args(&["-av", "--delete"])
.arg(&mounted_app_path)
.arg(&running_app_path)
.output()
.await?;
if !output.status.success() {
Err(anyhow!(
"failed to copy app: {:?}",
String::from_utf8_lossy(&output.stderr)
))?;
}
let output = Command::new("hdiutil")
.args(&["detach"])
.arg(&mount_path)
.output()
.await?;
if !output.status.success() {
Err(anyhow!(
"failed to unmount: {:?}",
String::from_utf8_lossy(&output.stderr)
))?;
}
this.update(&mut cx, |this, cx| {
this.set_should_show_update_notification(true, cx)
.detach_and_log_err(cx);
this.status = AutoUpdateStatus::Updated;
cx.notify();
});
Ok(())
}
fn set_should_show_update_notification(
&self,
should_show: bool,
cx: &AppContext,
) -> Task<Result<()>> {
let db = self.db.clone();
cx.background().spawn(async move {
if should_show {
db.write([(SHOULD_SHOW_UPDATE_NOTIFICATION_KEY, "")])?;
} else {
db.delete([(SHOULD_SHOW_UPDATE_NOTIFICATION_KEY)])?;
}
Ok(())
})
}
fn should_show_update_notification(&self, cx: &AppContext) -> Task<Result<bool>> {
let db = self.db.clone();
cx.background().spawn(async move {
Ok(db.read([(SHOULD_SHOW_UPDATE_NOTIFICATION_KEY)])?[0].is_some())
})
}
}
impl Entity for AutoUpdateIndicator {
type Event = ();
}
impl View for AutoUpdateIndicator {
fn ui_name() -> &'static str {
"AutoUpdateIndicator"
}
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
if let Some(updater) = &self.updater {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
match &updater.read(cx).status {
AutoUpdateStatus::Checking => Text::new(
"Checking for updates…".to_string(),
theme.auto_update_progress_message.clone(),
)
.boxed(),
AutoUpdateStatus::Downloading => Text::new(
"Downloading update…".to_string(),
theme.auto_update_progress_message.clone(),
)
.boxed(),
AutoUpdateStatus::Installing => Text::new(
"Installing update…".to_string(),
theme.auto_update_progress_message.clone(),
)
.boxed(),
AutoUpdateStatus::Updated => Text::new(
"Restart to update Zed".to_string(),
theme.auto_update_done_message.clone(),
)
.boxed(),
AutoUpdateStatus::Errored => {
MouseEventHandler::new::<Self, _, _>(0, cx, |_, cx| {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
Text::new(
"Auto update failed".to_string(),
theme.auto_update_done_message.clone(),
)
.boxed()
})
.on_click(|_, _, cx| cx.dispatch_action(DismissErrorMessage))
.boxed()
}
AutoUpdateStatus::Idle => Empty::new().boxed(),
}
} else {
Empty::new().boxed()
}
}
}
impl StatusItemView for AutoUpdateIndicator {
fn set_active_pane_item(&mut self, _: Option<&dyn ItemHandle>, _: &mut ViewContext<Self>) {}
}
impl AutoUpdateIndicator {
pub fn new(cx: &mut ViewContext<Self>) -> Self {
let updater = AutoUpdater::get(cx);
if let Some(updater) = &updater {
cx.observe(updater, |_, _, cx| cx.notify()).detach();
}
Self { updater }
}
fn dismiss_error_message(&mut self, _: &DismissErrorMessage, cx: &mut ViewContext<Self>) {
if let Some(updater) = &self.updater {
updater.update(cx, |updater, cx| {
updater.status = AutoUpdateStatus::Idle;
cx.notify();
});
}
}
}

View File

@@ -0,0 +1,106 @@
use crate::ViewReleaseNotes;
use gpui::{
elements::{Flex, MouseEventHandler, Padding, ParentElement, Svg, Text},
platform::{AppVersion, CursorStyle},
Element, Entity, View, ViewContext,
};
use menu::Cancel;
use settings::Settings;
use workspace::Notification;
pub struct UpdateNotification {
version: AppVersion,
}
pub enum Event {
Dismiss,
}
impl Entity for UpdateNotification {
type Event = Event;
}
impl View for UpdateNotification {
fn ui_name() -> &'static str {
"UpdateNotification"
}
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
let theme = cx.global::<Settings>().theme.clone();
let theme = &theme.update_notification;
MouseEventHandler::new::<ViewReleaseNotes, _, _>(0, cx, |state, cx| {
Flex::column()
.with_child(
Flex::row()
.with_child(
Text::new(
format!("Updated to Zed {}", self.version),
theme.message.text.clone(),
)
.contained()
.with_style(theme.message.container)
.aligned()
.top()
.left()
.flex(1., true)
.boxed(),
)
.with_child(
MouseEventHandler::new::<Cancel, _, _>(0, cx, |state, _| {
let style = theme.dismiss_button.style_for(state, false);
Svg::new("icons/decline.svg")
.with_color(style.color)
.constrained()
.with_width(style.icon_width)
.aligned()
.contained()
.with_style(style.container)
.constrained()
.with_width(style.button_width)
.with_height(style.button_width)
.boxed()
})
.with_padding(Padding::uniform(5.))
.on_click(move |_, _, cx| cx.dispatch_action(Cancel))
.aligned()
.constrained()
.with_height(cx.font_cache().line_height(theme.message.text.font_size))
.aligned()
.top()
.flex_float()
.boxed(),
)
.boxed(),
)
.with_child({
let style = theme.action_message.style_for(state, false);
Text::new("View the release notes".to_string(), style.text.clone())
.contained()
.with_style(style.container)
.boxed()
})
.contained()
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(|_, _, cx| cx.dispatch_action(ViewReleaseNotes))
.boxed()
}
}
impl Notification for UpdateNotification {
fn should_dismiss_notification_on_event(&self, event: &<Self as Entity>::Event) -> bool {
matches!(event, Event::Dismiss)
}
}
impl UpdateNotification {
pub fn new(version: AppVersion) -> Self {
Self { version }
}
pub fn dismiss(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
cx.emit(Event::Dismiss);
}
}

View File

@@ -1,25 +1,24 @@
[package]
name = "find"
name = "breadcrumbs"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/find.rs"
path = "src/breadcrumbs.rs"
doctest = false
[dependencies]
collections = { path = "../collections" }
editor = { path = "../editor" }
gpui = { path = "../gpui" }
language = { path = "../language" }
project = { path = "../project" }
search = { path = "../search" }
settings = { path = "../settings" }
theme = { path = "../theme" }
workspace = { path = "../workspace" }
aho-corasick = "0.7"
anyhow = "1.0"
postage = { version = "0.4.1", features = ["futures-traits"] }
regex = "1.5"
smol = { version = "1.2" }
[dev-dependencies]
editor = { path = "../editor", features = ["test-support"] }
gpui = { path = "../gpui", features = ["test-support"] }
workspace = { path = "../workspace", features = ["test-support"] }
unindent = "0.1"

View File

@@ -0,0 +1,157 @@
use editor::{Anchor, Editor};
use gpui::{
elements::*, AppContext, Entity, ModelHandle, RenderContext, Subscription, View, ViewContext,
ViewHandle,
};
use language::{Buffer, OutlineItem};
use project::Project;
use search::ProjectSearchView;
use settings::Settings;
use theme::SyntaxTheme;
use workspace::{ItemHandle, ToolbarItemLocation, ToolbarItemView};
pub enum Event {
UpdateLocation,
}
pub struct Breadcrumbs {
project: ModelHandle<Project>,
editor: Option<ViewHandle<Editor>>,
project_search: Option<ViewHandle<ProjectSearchView>>,
subscriptions: Vec<Subscription>,
}
impl Breadcrumbs {
pub fn new(project: ModelHandle<Project>) -> Self {
Self {
project,
editor: Default::default(),
subscriptions: Default::default(),
project_search: Default::default(),
}
}
fn active_symbols(
&self,
theme: &SyntaxTheme,
cx: &AppContext,
) -> Option<(ModelHandle<Buffer>, Vec<OutlineItem<Anchor>>)> {
let editor = self.editor.as_ref()?.read(cx);
let cursor = editor.selections.newest_anchor().head();
let multibuffer = &editor.buffer().read(cx);
let (buffer_id, symbols) = multibuffer.symbols_containing(cursor, Some(theme), cx)?;
let buffer = multibuffer.buffer(buffer_id)?;
Some((buffer, symbols))
}
}
impl Entity for Breadcrumbs {
type Event = Event;
}
impl View for Breadcrumbs {
fn ui_name() -> &'static str {
"Breadcrumbs"
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = cx.global::<Settings>().theme.clone();
let (buffer, symbols) =
if let Some((buffer, symbols)) = self.active_symbols(&theme.editor.syntax, cx) {
(buffer, symbols)
} else {
return Empty::new().boxed();
};
let buffer = buffer.read(cx);
let filename = if let Some(file) = buffer.file() {
if file.path().file_name().is_none()
|| self.project.read(cx).visible_worktrees(cx).count() > 1
{
file.full_path(cx).to_string_lossy().to_string()
} else {
file.path().to_string_lossy().to_string()
}
} else {
"untitled".to_string()
};
Flex::row()
.with_child(Label::new(filename, theme.breadcrumbs.text.clone()).boxed())
.with_children(symbols.into_iter().flat_map(|symbol| {
[
Label::new("".to_string(), theme.breadcrumbs.text.clone()).boxed(),
Text::new(symbol.text, theme.breadcrumbs.text.clone())
.with_highlights(symbol.highlight_ranges)
.boxed(),
]
}))
.contained()
.with_style(theme.breadcrumbs.container)
.aligned()
.left()
.boxed()
}
}
impl ToolbarItemView for Breadcrumbs {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn ItemHandle>,
cx: &mut ViewContext<Self>,
) -> ToolbarItemLocation {
cx.notify();
self.subscriptions.clear();
self.editor = None;
self.project_search = None;
if let Some(item) = active_pane_item {
if let Some(editor) = item.act_as::<Editor>(cx) {
self.subscriptions
.push(cx.subscribe(&editor, |_, _, event, cx| match event {
editor::Event::BufferEdited
| editor::Event::TitleChanged
| editor::Event::Saved
| editor::Event::Reparsed => cx.notify(),
editor::Event::SelectionsChanged { local } if *local => cx.notify(),
_ => {}
}));
self.editor = Some(editor);
if let Some(project_search) = item.downcast::<ProjectSearchView>() {
self.subscriptions
.push(cx.subscribe(&project_search, |_, _, _, cx| {
cx.emit(Event::UpdateLocation);
}));
self.project_search = Some(project_search.clone());
if project_search.read(cx).has_matches() {
ToolbarItemLocation::Secondary
} else {
ToolbarItemLocation::Hidden
}
} else {
ToolbarItemLocation::PrimaryLeft { flex: None }
}
} else {
ToolbarItemLocation::Hidden
}
} else {
ToolbarItemLocation::Hidden
}
}
fn location_for_event(
&self,
_: &Event,
current_location: ToolbarItemLocation,
cx: &AppContext,
) -> ToolbarItemLocation {
if let Some(project_search) = self.project_search.as_ref() {
if project_search.read(cx).has_matches() {
ToolbarItemLocation::Secondary
} else {
ToolbarItemLocation::Hidden
}
} else {
current_location
}
}
}

View File

@@ -5,13 +5,16 @@ edition = "2021"
[lib]
path = "src/chat_panel.rs"
doctest = false
[dependencies]
client = { path = "../client" }
editor = { path = "../editor" }
gpui = { path = "../gpui" }
menu = { path = "../menu" }
settings = { path = "../settings" }
theme = { path = "../theme" }
util = { path = "../util" }
workspace = { path = "../workspace" }
postage = { version = "0.4.1", features = ["futures-traits"] }
time = "0.3"
time = { version = "0.3", features = ["serde", "serde-well-known"] }

View File

@@ -2,21 +2,21 @@ use client::{
channel::{Channel, ChannelEvent, ChannelList, ChannelMessage},
Client,
};
use editor::{Editor, EditorSettings};
use editor::Editor;
use gpui::{
action,
actions,
elements::*,
keymap::Binding,
platform::CursorStyle,
views::{ItemType, Select, SelectStyle},
AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle,
};
use postage::{prelude::Stream, watch};
use menu::Confirm;
use postage::prelude::Stream;
use settings::{Settings, SoftWrap};
use std::sync::Arc;
use time::{OffsetDateTime, UtcOffset};
use util::{ResultExt, TryFutureExt};
use workspace::Settings;
const MESSAGE_LOADING_THRESHOLD: usize = 50;
@@ -27,80 +27,60 @@ pub struct ChatPanel {
message_list: ListState,
input_editor: ViewHandle<Editor>,
channel_select: ViewHandle<Select>,
settings: watch::Receiver<Settings>,
local_timezone: UtcOffset,
_observe_status: Task<()>,
}
pub enum Event {}
action!(Send);
action!(LoadMoreMessages);
actions!(chat_panel, [LoadMoreMessages]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(ChatPanel::send);
cx.add_action(ChatPanel::load_more_messages);
cx.add_bindings(vec![Binding::new("enter", Send, Some("ChatPanel"))]);
}
impl ChatPanel {
pub fn new(
rpc: Arc<Client>,
channel_list: ModelHandle<ChannelList>,
settings: watch::Receiver<Settings>,
cx: &mut ViewContext<Self>,
) -> Self {
let input_editor = cx.add_view(|cx| {
Editor::auto_height(
4,
{
let settings = settings.clone();
Arc::new(move |_| {
let settings = settings.borrow();
EditorSettings {
tab_size: settings.tab_size,
style: settings.theme.chat_panel.input_editor.as_editor(),
soft_wrap: editor::SoftWrap::EditorWidth,
}
})
},
cx,
)
let mut editor =
Editor::auto_height(4, Some(|theme| theme.chat_panel.input_editor.clone()), cx);
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor
});
let channel_select = cx.add_view(|cx| {
let channel_list = channel_list.clone();
Select::new(0, cx, {
let settings = settings.clone();
move |ix, item_type, is_hovered, cx| {
Self::render_channel_name(
&channel_list,
ix,
item_type,
is_hovered,
&settings.borrow().theme.chat_panel.channel_select,
&cx.global::<Settings>().theme.chat_panel.channel_select,
cx,
)
}
})
.with_style({
let settings = settings.clone();
move |_| {
let theme = &settings.borrow().theme.chat_panel.channel_select;
SelectStyle {
header: theme.header.container.clone(),
menu: theme.menu.clone(),
}
.with_style(move |cx| {
let theme = &cx.global::<Settings>().theme.chat_panel.channel_select;
SelectStyle {
header: theme.header.container,
menu: theme.menu.clone(),
}
})
});
let mut message_list = ListState::new(0, Orientation::Bottom, 1000., {
let mut message_list = ListState::new(0, Orientation::Bottom, 1000., cx, {
let this = cx.weak_handle();
move |ix, cx| {
move |_, ix, cx| {
let this = this.upgrade(cx).unwrap().read(cx);
let message = this.active_channel.as_ref().unwrap().0.read(cx).message(ix);
this.render_message(message)
this.render_message(message, cx)
}
});
message_list.set_scroll_handler(|visible_range, cx| {
@@ -108,11 +88,15 @@ impl ChatPanel {
cx.dispatch_action(LoadMoreMessages);
}
});
let _observe_status = cx.spawn(|this, mut cx| {
let _observe_status = cx.spawn_weak(|this, mut cx| {
let mut status = rpc.status();
async move {
while let Some(_) = status.recv().await {
this.update(&mut cx, |_, cx| cx.notify());
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |_, cx| cx.notify());
} else {
break;
}
}
}
});
@@ -124,7 +108,6 @@ impl ChatPanel {
message_list,
input_editor,
channel_select,
settings,
local_timezone: cx.platform().local_timezone(),
_observe_status,
};
@@ -213,8 +196,8 @@ impl ChatPanel {
cx.notify();
}
fn render_channel(&self) -> ElementBox {
let theme = &self.settings.borrow().theme;
fn render_channel(&self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = &cx.global::<Settings>().theme;
Flex::column()
.with_child(
Container::new(ChildView::new(&self.channel_select).boxed())
@@ -222,7 +205,7 @@ impl ChatPanel {
.boxed(),
)
.with_child(self.render_active_channel_messages())
.with_child(self.render_input_box())
.with_child(self.render_input_box(cx))
.boxed()
}
@@ -233,12 +216,12 @@ impl ChatPanel {
Empty::new().boxed()
};
Flexible::new(1., true, messages).boxed()
FlexItem::new(messages).flex(1., true).boxed()
}
fn render_message(&self, message: &ChannelMessage) -> ElementBox {
fn render_message(&self, message: &ChannelMessage, cx: &AppContext) -> ElementBox {
let now = OffsetDateTime::now_utc();
let settings = self.settings.borrow();
let settings = cx.global::<Settings>();
let theme = if message.is_pending() {
&settings.theme.chat_panel.pending_message
} else {
@@ -280,8 +263,8 @@ impl ChatPanel {
.boxed()
}
fn render_input_box(&self) -> ElementBox {
let theme = &self.settings.borrow().theme;
fn render_input_box(&self, cx: &AppContext) -> ElementBox {
let theme = &cx.global::<Settings>().theme;
Container::new(ChildView::new(&self.input_editor).boxed())
.with_style(theme.chat_panel.input_editor.container)
.boxed()
@@ -318,7 +301,7 @@ impl ChatPanel {
}
fn render_sign_in_prompt(&self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = &self.settings.borrow().theme;
let theme = cx.global::<Settings>().theme.clone();
let rpc = self.rpc.clone();
let this = cx.handle();
@@ -337,11 +320,16 @@ impl ChatPanel {
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(move |cx| {
.on_click(move |_, _, cx| {
let rpc = rpc.clone();
let this = this.clone();
cx.spawn(|mut cx| async move {
if rpc.authenticate_and_connect(&cx).log_err().await.is_some() {
if rpc
.authenticate_and_connect(true, &cx)
.log_err()
.await
.is_some()
{
cx.update(|cx| {
if let Some(this) = this.upgrade(cx) {
if this.is_focused(cx) {
@@ -358,7 +346,7 @@ impl ChatPanel {
.boxed()
}
fn send(&mut self, _: &Send, cx: &mut ViewContext<Self>) {
fn send(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
if let Some((channel, _)) = self.active_channel.as_ref() {
let body = self.input_editor.update(cx, |editor, cx| {
let body = editor.text(cx);
@@ -394,12 +382,12 @@ impl View for ChatPanel {
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
let theme = &self.settings.borrow().theme;
let element = if self.rpc.user_id().is_some() {
self.render_channel()
self.render_channel(cx)
} else {
self.render_sign_in_prompt(cx)
};
let theme = &cx.global::<Settings>().theme;
ConstrainedBox::new(
Container::new(element)
.with_style(theme.chat_panel.container)

24
crates/cli/Cargo.toml Normal file
View File

@@ -0,0 +1,24 @@
[package]
name = "cli"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/cli.rs"
doctest = false
[[bin]]
name = "cli"
path = "src/main.rs"
[dependencies]
anyhow = "1.0"
clap = { version = "3.1", features = ["derive"] }
dirs = "3.0"
ipc-channel = "0.16"
serde = { version = "1.0", features = ["derive", "rc"] }
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.9"
core-services = "0.2"
plist = "1.3"

22
crates/cli/src/cli.rs Normal file
View File

@@ -0,0 +1,22 @@
pub use ipc_channel::ipc;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Serialize, Deserialize)]
pub struct IpcHandshake {
pub requests: ipc::IpcSender<CliRequest>,
pub responses: ipc::IpcReceiver<CliResponse>,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum CliRequest {
Open { paths: Vec<PathBuf>, wait: bool },
}
#[derive(Debug, Serialize, Deserialize)]
pub enum CliResponse {
Ping,
Stdout { message: String },
Stderr { message: String },
Exit { status: i32 },
}

124
crates/cli/src/main.rs Normal file
View File

@@ -0,0 +1,124 @@
use anyhow::{anyhow, Result};
use clap::Parser;
use cli::{CliRequest, CliResponse, IpcHandshake};
use core_foundation::{
array::{CFArray, CFIndex},
string::kCFStringEncodingUTF8,
url::{CFURLCreateWithBytes, CFURL},
};
use core_services::{kLSLaunchDefaults, LSLaunchURLSpec, LSOpenFromURLSpec, TCFType};
use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender};
use serde::Deserialize;
use std::{ffi::OsStr, fs, path::PathBuf, ptr};
#[derive(Parser)]
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
struct Args {
/// Wait for all of the given paths to be closed before exiting.
#[clap(short, long)]
wait: bool,
/// A sequence of space-separated paths that you want to open.
#[clap()]
paths: Vec<PathBuf>,
/// Print Zed's version and the app path.
#[clap(short, long)]
version: bool,
/// Custom Zed.app path
#[clap(short, long)]
bundle_path: Option<PathBuf>,
}
#[derive(Debug, Deserialize)]
struct InfoPlist {
#[serde(rename = "CFBundleShortVersionString")]
bundle_short_version_string: String,
}
fn main() -> Result<()> {
let args = Args::parse();
let bundle_path = if let Some(bundle_path) = args.bundle_path {
bundle_path.canonicalize()?
} else {
locate_bundle()?
};
if args.version {
let plist_path = bundle_path.join("Contents/Info.plist");
let plist = plist::from_file::<_, InfoPlist>(plist_path)?;
println!(
"Zed {} {}",
plist.bundle_short_version_string,
bundle_path.to_string_lossy()
);
return Ok(());
}
let (tx, rx) = launch_app(bundle_path)?;
tx.send(CliRequest::Open {
paths: args
.paths
.into_iter()
.map(|path| fs::canonicalize(path).map_err(|error| anyhow!(error)))
.collect::<Result<Vec<PathBuf>>>()?,
wait: args.wait,
})?;
while let Ok(response) = rx.recv() {
match response {
CliResponse::Ping => {}
CliResponse::Stdout { message } => println!("{message}"),
CliResponse::Stderr { message } => eprintln!("{message}"),
CliResponse::Exit { status } => std::process::exit(status),
}
}
Ok(())
}
fn locate_bundle() -> Result<PathBuf> {
let cli_path = std::env::current_exe()?.canonicalize()?;
let mut app_path = cli_path.clone();
while app_path.extension() != Some(OsStr::new("app")) {
if !app_path.pop() {
return Err(anyhow!("cannot find app bundle containing {:?}", cli_path));
}
}
Ok(app_path)
}
fn launch_app(app_path: PathBuf) -> Result<(IpcSender<CliRequest>, IpcReceiver<CliResponse>)> {
let (server, server_name) = IpcOneShotServer::<IpcHandshake>::new()?;
let url = format!("zed-cli://{server_name}");
let status = unsafe {
let app_url =
CFURL::from_path(&app_path, true).ok_or_else(|| anyhow!("invalid app path"))?;
let url_to_open = CFURL::wrap_under_create_rule(CFURLCreateWithBytes(
ptr::null(),
url.as_ptr(),
url.len() as CFIndex,
kCFStringEncodingUTF8,
ptr::null(),
));
let urls_to_open = CFArray::from_copyable(&[url_to_open.as_concrete_TypeRef()]);
LSOpenFromURLSpec(
&LSLaunchURLSpec {
appURL: app_url.as_concrete_TypeRef(),
itemURLs: urls_to_open.as_concrete_TypeRef(),
passThruParams: ptr::null(),
launchFlags: kLSLaunchDefaults,
asyncRefCon: ptr::null_mut(),
},
ptr::null_mut(),
)
};
if status == 0 {
let (_, handshake) = server.accept()?;
Ok((handshake.requests, handshake.responses))
} else {
Err(anyhow!("cannot start {:?}", app_path))
}
}

View File

@@ -5,11 +5,13 @@ edition = "2021"
[lib]
path = "src/client.rs"
doctest = false
[features]
test-support = ["gpui/test-support", "rpc/test-support"]
test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]
[dependencies]
collections = { path = "../collections" }
gpui = { path = "../gpui" }
util = { path = "../util" }
rpc = { path = "../rpc" }
@@ -19,17 +21,19 @@ async-recursion = "0.3"
async-tungstenite = { version = "0.16", features = ["async-tls"] }
futures = "0.3"
image = "0.23"
isahc = "1.7"
lazy_static = "1.4.0"
log = "0.4"
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
parking_lot = "0.11.1"
postage = { version = "0.4.1", features = ["futures-traits"] }
rand = "0.8.3"
smol = "1.2.5"
surf = "2.2"
thiserror = "1.0.29"
time = "0.3"
time = { version = "0.3", features = ["serde", "serde-well-known"] }
tiny_http = "0.8"
url = "2.2"
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
gpui = { path = "../gpui", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] }

View File

@@ -181,7 +181,7 @@ impl Entity for Channel {
impl Channel {
pub fn init(rpc: &Arc<Client>) {
rpc.add_entity_message_handler(Self::handle_message_sent);
rpc.add_model_message_handler(Self::handle_message_sent);
}
pub fn new(
@@ -500,7 +500,7 @@ async fn messages_from_proto(
.collect();
user_store
.update(cx, |user_store, cx| {
user_store.load_users(unique_user_ids, cx)
user_store.get_users(unique_user_ids, cx)
})
.await?;
@@ -594,14 +594,13 @@ mod tests {
use super::*;
use crate::test::{FakeHttpClient, FakeServer};
use gpui::TestAppContext;
use surf::http::Response;
#[gpui::test]
async fn test_channel_messages(mut cx: TestAppContext) {
async fn test_channel_messages(cx: &mut TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
let http_client = FakeHttpClient::new(|_| async move { Ok(Response::new(404)) });
let http_client = FakeHttpClient::with_404_response();
let mut client = Client::new(http_client.clone());
let server = FakeServer::for_client(user_id, &mut client, &cx).await;
@@ -609,7 +608,7 @@ mod tests {
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let channel_list = cx.add_model(|cx| ChannelList::new(user_store, client.clone(), cx));
channel_list.read_with(&cx, |list, _| assert_eq!(list.available_channels(), None));
channel_list.read_with(cx, |list, _| assert_eq!(list.available_channels(), None));
// Get the available channels.
let get_channels = server.receive::<proto::GetChannels>().await.unwrap();
@@ -625,7 +624,7 @@ mod tests {
)
.await;
channel_list.next_notification(&cx).await;
channel_list.read_with(&cx, |list, _| {
channel_list.read_with(cx, |list, _| {
assert_eq!(
list.available_channels().unwrap(),
&[ChannelDetails {
@@ -640,7 +639,7 @@ mod tests {
server
.respond(
get_users.receipt(),
proto::GetUsersResponse {
proto::UsersResponse {
users: vec![proto::User {
id: 5,
github_login: "nathansobo".into(),
@@ -652,12 +651,12 @@ mod tests {
// Join a channel and populate its existing messages.
let channel = channel_list
.update(&mut cx, |list, cx| {
.update(cx, |list, cx| {
let channel_id = list.available_channels().unwrap()[0].id;
list.get_channel(channel_id, cx)
})
.unwrap();
channel.read_with(&cx, |channel, _| assert!(channel.messages().is_empty()));
channel.read_with(cx, |channel, _| assert!(channel.messages().is_empty()));
let join_channel = server.receive::<proto::JoinChannel>().await.unwrap();
server
.respond(
@@ -691,7 +690,7 @@ mod tests {
server
.respond(
get_users.receipt(),
proto::GetUsersResponse {
proto::UsersResponse {
users: vec![proto::User {
id: 6,
github_login: "maxbrunsfeld".into(),
@@ -708,7 +707,7 @@ mod tests {
new_count: 2,
}
);
channel.read_with(&cx, |channel, _| {
channel.read_with(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(0..2)
@@ -723,7 +722,7 @@ mod tests {
// Receive a new message.
server.send(proto::ChannelMessageSent {
channel_id: channel.read_with(&cx, |channel, _| channel.details.id),
channel_id: channel.read_with(cx, |channel, _| channel.details.id),
message: Some(proto::ChannelMessage {
id: 12,
body: "c".into(),
@@ -739,7 +738,7 @@ mod tests {
server
.respond(
get_users.receipt(),
proto::GetUsersResponse {
proto::UsersResponse {
users: vec![proto::User {
id: 7,
github_login: "as-cii".into(),
@@ -756,7 +755,7 @@ mod tests {
new_count: 1,
}
);
channel.read_with(&cx, |channel, _| {
channel.read_with(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(2..3)
@@ -767,7 +766,7 @@ mod tests {
});
// Scroll up to view older messages.
channel.update(&mut cx, |channel, cx| {
channel.update(cx, |channel, cx| {
assert!(channel.load_more_messages(cx));
});
let get_messages = server.receive::<proto::GetChannelMessages>().await.unwrap();
@@ -805,7 +804,7 @@ mod tests {
new_count: 2,
}
);
channel.read_with(&cx, |channel, _| {
channel.read_with(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(0..2)

View File

@@ -11,10 +11,10 @@ use async_tungstenite::tungstenite::{
error::Error as WebsocketError,
http::{Request, StatusCode},
};
use futures::{future::LocalBoxFuture, FutureExt, StreamExt};
use futures::{future::LocalBoxFuture, FutureExt, SinkExt, StreamExt, TryStreamExt};
use gpui::{
action, AnyModelHandle, AnyWeakModelHandle, AsyncAppContext, Entity, ModelContext, ModelHandle,
MutableAppContext, Task,
actions, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AsyncAppContext,
Entity, ModelContext, ModelHandle, MutableAppContext, Task, View, ViewContext, ViewHandle,
};
use http::HttpClient;
use lazy_static::lazy_static;
@@ -34,8 +34,8 @@ use std::{
},
time::{Duration, Instant},
};
use surf::{http::Method, Url};
use thiserror::Error;
use url::Url;
use util::{ResultExt, TryFutureExt};
pub use channel::*;
@@ -43,19 +43,21 @@ pub use rpc::*;
pub use user::*;
lazy_static! {
static ref ZED_SERVER_URL: String =
pub static ref ZED_SERVER_URL: String =
std::env::var("ZED_SERVER_URL").unwrap_or("https://zed.dev".to_string());
static ref IMPERSONATE_LOGIN: Option<String> = std::env::var("ZED_IMPERSONATE")
pub static ref IMPERSONATE_LOGIN: Option<String> = std::env::var("ZED_IMPERSONATE")
.ok()
.and_then(|s| if s.is_empty() { None } else { Some(s) });
}
action!(Authenticate);
pub const ZED_SECRET_CLIENT_TOKEN: &'static str = "618033988749894";
actions!(client, [Authenticate]);
pub fn init(rpc: Arc<Client>, cx: &mut MutableAppContext) {
cx.add_global_action(move |_: &Authenticate, cx| {
let rpc = rpc.clone();
cx.spawn(|cx| async move { rpc.authenticate_and_connect(&cx).log_err().await })
cx.spawn(|cx| async move { rpc.authenticate_and_connect(true, &cx).log_err().await })
.detach();
});
}
@@ -65,17 +67,23 @@ pub struct Client {
peer: Arc<Peer>,
http: Arc<dyn HttpClient>,
state: RwLock<ClientState>,
authenticate:
#[cfg(any(test, feature = "test-support"))]
authenticate: RwLock<
Option<Box<dyn 'static + Send + Sync + Fn(&AsyncAppContext) -> Task<Result<Credentials>>>>,
establish_connection: Option<
Box<
dyn 'static
+ Send
+ Sync
+ Fn(
&Credentials,
&AsyncAppContext,
) -> Task<Result<Connection, EstablishConnectionError>>,
>,
#[cfg(any(test, feature = "test-support"))]
establish_connection: RwLock<
Option<
Box<
dyn 'static
+ Send
+ Sync
+ Fn(
&Credentials,
&AsyncAppContext,
) -> Task<Result<Connection, EstablishConnectionError>>,
>,
>,
>,
}
@@ -89,9 +97,11 @@ pub enum EstablishConnectionError {
#[error("{0}")]
Other(#[from] anyhow::Error),
#[error("{0}")]
Http(#[from] http::Error),
#[error("{0}")]
Io(#[from] std::io::Error),
#[error("{0}")]
Http(#[from] async_tungstenite::tungstenite::http::Error),
Websocket(#[from] async_tungstenite::tungstenite::http::Error),
}
impl From<WebsocketError> for EstablishConnectionError {
@@ -113,7 +123,7 @@ impl EstablishConnectionError {
}
}
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Status {
SignedOut,
UpgradeRequired,
@@ -127,30 +137,46 @@ pub enum Status {
ReconnectionError { next_reconnection: Instant },
}
impl Status {
pub fn is_connected(&self) -> bool {
matches!(self, Self::Connected { .. })
}
}
struct ClientState {
credentials: Option<Credentials>,
status: (watch::Sender<Status>, watch::Receiver<Status>),
entity_id_extractors: HashMap<TypeId, Box<dyn Send + Sync + Fn(&dyn AnyTypedEnvelope) -> u64>>,
_maintain_connection: Option<Task<()>>,
heartbeat_interval: Duration,
models_by_entity_type_and_remote_id: HashMap<(TypeId, u64), AnyWeakModelHandle>,
models_by_message_type: HashMap<TypeId, AnyModelHandle>,
model_types_by_message_type: HashMap<TypeId, TypeId>,
entity_id_extractors: HashMap<TypeId, fn(&dyn AnyTypedEnvelope) -> u64>,
_reconnect_task: Option<Task<()>>,
reconnect_interval: Duration,
entities_by_type_and_remote_id: HashMap<(TypeId, u64), AnyWeakEntityHandle>,
models_by_message_type: HashMap<TypeId, AnyWeakModelHandle>,
entity_types_by_message_type: HashMap<TypeId, TypeId>,
message_handlers: HashMap<
TypeId,
Arc<
dyn Send
+ Sync
+ Fn(
AnyModelHandle,
AnyEntityHandle,
Box<dyn AnyTypedEnvelope>,
&Arc<Client>,
AsyncAppContext,
) -> LocalBoxFuture<'static, Result<()>>,
>,
>,
}
enum AnyWeakEntityHandle {
Model(AnyWeakModelHandle),
View(AnyWeakViewHandle),
}
enum AnyEntityHandle {
Model(AnyModelHandle),
View(AnyViewHandle),
}
#[derive(Clone, Debug)]
pub struct Credentials {
pub user_id: u64,
@@ -163,11 +189,11 @@ impl Default for ClientState {
credentials: None,
status: watch::channel_with(Status::SignedOut),
entity_id_extractors: Default::default(),
_maintain_connection: None,
heartbeat_interval: Duration::from_secs(5),
_reconnect_task: None,
reconnect_interval: Duration::from_secs(5),
models_by_message_type: Default::default(),
models_by_entity_type_and_remote_id: Default::default(),
model_types_by_message_type: Default::default(),
entities_by_type_and_remote_id: Default::default(),
entity_types_by_message_type: Default::default(),
message_handlers: Default::default(),
}
}
@@ -190,13 +216,13 @@ impl Drop for Subscription {
Subscription::Entity { client, id } => {
if let Some(client) = client.upgrade() {
let mut state = client.state.write();
let _ = state.models_by_entity_type_and_remote_id.remove(id);
let _ = state.entities_by_type_and_remote_id.remove(id);
}
}
Subscription::Message { client, id } => {
if let Some(client) = client.upgrade() {
let mut state = client.state.write();
let _ = state.model_types_by_message_type.remove(id);
let _ = state.entity_types_by_message_type.remove(id);
let _ = state.message_handlers.remove(id);
}
}
@@ -215,8 +241,11 @@ impl Client {
peer: Peer::new(),
http,
state: Default::default(),
authenticate: None,
establish_connection: None,
#[cfg(any(test, feature = "test-support"))]
authenticate: Default::default(),
#[cfg(any(test, feature = "test-support"))]
establish_connection: Default::default(),
})
}
@@ -229,23 +258,34 @@ impl Client {
}
#[cfg(any(test, feature = "test-support"))]
pub fn override_authenticate<F>(&mut self, authenticate: F) -> &mut Self
pub fn tear_down(&self) {
let mut state = self.state.write();
state._reconnect_task.take();
state.message_handlers.clear();
state.models_by_message_type.clear();
state.entities_by_type_and_remote_id.clear();
state.entity_id_extractors.clear();
self.peer.reset();
}
#[cfg(any(test, feature = "test-support"))]
pub fn override_authenticate<F>(&self, authenticate: F) -> &Self
where
F: 'static + Send + Sync + Fn(&AsyncAppContext) -> Task<Result<Credentials>>,
{
self.authenticate = Some(Box::new(authenticate));
*self.authenticate.write() = Some(Box::new(authenticate));
self
}
#[cfg(any(test, feature = "test-support"))]
pub fn override_establish_connection<F>(&mut self, connect: F) -> &mut Self
pub fn override_establish_connection<F>(&self, connect: F) -> &Self
where
F: 'static
+ Send
+ Sync
+ Fn(&Credentials, &AsyncAppContext) -> Task<Result<Connection, EstablishConnectionError>>,
{
self.establish_connection = Some(Box::new(connect));
*self.establish_connection.write() = Some(Box::new(connect));
self
}
@@ -262,61 +302,72 @@ impl Client {
}
fn set_status(self: &Arc<Self>, status: Status, cx: &AsyncAppContext) {
log::info!("set status on client {}: {:?}", self.id, status);
let mut state = self.state.write();
*state.status.0.borrow_mut() = status;
match status {
Status::Connected { .. } => {
let heartbeat_interval = state.heartbeat_interval;
let this = self.clone();
let foreground = cx.foreground();
state._maintain_connection = Some(cx.foreground().spawn(async move {
loop {
foreground.timer(heartbeat_interval).await;
let _ = this.request(proto::Ping {}).await;
}
}));
state._reconnect_task = None;
}
Status::ConnectionLost => {
let this = self.clone();
let foreground = cx.foreground();
let heartbeat_interval = state.heartbeat_interval;
state._maintain_connection = Some(cx.spawn(|cx| async move {
let reconnect_interval = state.reconnect_interval;
state._reconnect_task = Some(cx.spawn(|cx| async move {
let mut rng = StdRng::from_entropy();
let mut delay = Duration::from_millis(100);
while let Err(error) = this.authenticate_and_connect(&cx).await {
while let Err(error) = this.authenticate_and_connect(true, &cx).await {
log::error!("failed to connect {}", error);
this.set_status(
Status::ReconnectionError {
next_reconnection: Instant::now() + delay,
},
&cx,
);
foreground.timer(delay).await;
delay = delay
.mul_f32(rng.gen_range(1.0..=2.0))
.min(heartbeat_interval);
if matches!(*this.status().borrow(), Status::ConnectionError) {
this.set_status(
Status::ReconnectionError {
next_reconnection: Instant::now() + delay,
},
&cx,
);
cx.background().timer(delay).await;
delay = delay
.mul_f32(rng.gen_range(1.0..=2.0))
.min(reconnect_interval);
} else {
break;
}
}
}));
}
Status::SignedOut | Status::UpgradeRequired => {
state._maintain_connection.take();
state._reconnect_task.take();
}
_ => {}
}
}
pub fn add_view_for_remote_entity<T: View>(
self: &Arc<Self>,
remote_id: u64,
cx: &mut ViewContext<T>,
) -> Subscription {
let id = (TypeId::of::<T>(), remote_id);
self.state
.write()
.entities_by_type_and_remote_id
.insert(id, AnyWeakEntityHandle::View(cx.weak_handle().into()));
Subscription::Entity {
client: Arc::downgrade(self),
id,
}
}
pub fn add_model_for_remote_entity<T: Entity>(
self: &Arc<Self>,
remote_id: u64,
cx: &mut ModelContext<T>,
) -> Subscription {
let handle = AnyModelHandle::from(cx.handle());
let mut state = self.state.write();
let id = (TypeId::of::<T>(), remote_id);
state
.models_by_entity_type_and_remote_id
.insert(id, handle.downgrade());
self.state
.write()
.entities_by_type_and_remote_id
.insert(id, AnyWeakEntityHandle::Model(cx.weak_handle().into()));
Subscription::Entity {
client: Arc::downgrade(self),
id,
@@ -339,15 +390,19 @@ impl Client {
{
let message_type_id = TypeId::of::<M>();
let client = self.clone();
let mut state = self.state.write();
state
.models_by_message_type
.insert(message_type_id, model.into());
.insert(message_type_id, model.downgrade().into());
let prev_handler = state.message_handlers.insert(
message_type_id,
Arc::new(move |handle, envelope, cx| {
Arc::new(move |handle, envelope, client, cx| {
let handle = if let AnyEntityHandle::Model(handle) = handle {
handle
} else {
unreachable!();
};
let model = handle.downcast::<E>().unwrap();
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
handler(model, *envelope, client.clone(), cx).boxed_local()
@@ -363,7 +418,26 @@ impl Client {
}
}
pub fn add_entity_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
pub fn add_view_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
where
M: EntityMessage,
E: View,
H: 'static
+ Send
+ Sync
+ Fn(ViewHandle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
F: 'static + Future<Output = Result<()>>,
{
self.add_entity_message_handler::<M, E, _, _>(move |handle, message, client, cx| {
if let AnyEntityHandle::View(handle) = handle {
handler(handle.downcast::<E>().unwrap(), message, client, cx)
} else {
unreachable!();
}
})
}
pub fn add_model_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
where
M: EntityMessage,
E: Entity,
@@ -372,34 +446,51 @@ impl Client {
+ Sync
+ Fn(ModelHandle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
F: 'static + Future<Output = Result<()>>,
{
self.add_entity_message_handler::<M, E, _, _>(move |handle, message, client, cx| {
if let AnyEntityHandle::Model(handle) = handle {
handler(handle.downcast::<E>().unwrap(), message, client, cx)
} else {
unreachable!();
}
})
}
fn add_entity_message_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
where
M: EntityMessage,
E: Entity,
H: 'static
+ Send
+ Sync
+ Fn(AnyEntityHandle, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
F: 'static + Future<Output = Result<()>>,
{
let model_type_id = TypeId::of::<E>();
let message_type_id = TypeId::of::<M>();
let client = self.clone();
let mut state = self.state.write();
state
.model_types_by_message_type
.entity_types_by_message_type
.insert(message_type_id, model_type_id);
state
.entity_id_extractors
.entry(message_type_id)
.or_insert_with(|| {
Box::new(|envelope| {
let envelope = envelope
|envelope| {
envelope
.as_any()
.downcast_ref::<TypedEnvelope<M>>()
.unwrap();
envelope.payload.remote_entity_id()
})
.unwrap()
.payload
.remote_entity_id()
}
});
let prev_handler = state.message_handlers.insert(
message_type_id,
Arc::new(move |handle, envelope, cx| {
let model = handle.downcast::<E>().unwrap();
Arc::new(move |handle, envelope, client, cx| {
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
handler(model, *envelope, client.clone(), cx).boxed_local()
handler(handle, *envelope, client.clone(), cx).boxed_local()
}),
);
if prev_handler.is_some() {
@@ -407,7 +498,7 @@ impl Client {
}
}
pub fn add_entity_request_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
pub fn add_model_request_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
where
M: EntityMessage + RequestMessage,
E: Entity,
@@ -417,29 +508,56 @@ impl Client {
+ Fn(ModelHandle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
F: 'static + Future<Output = Result<M::Response>>,
{
self.add_entity_message_handler(move |model, envelope, client, cx| {
let receipt = envelope.receipt();
let response = handler(model, envelope, client.clone(), cx);
async move {
match response.await {
Ok(response) => {
client.respond(receipt, response)?;
Ok(())
}
Err(error) => {
client.respond_with_error(
receipt,
proto::Error {
message: error.to_string(),
},
)?;
Err(error)
}
}
}
self.add_model_message_handler(move |entity, envelope, client, cx| {
Self::respond_to_request::<M, _>(
envelope.receipt(),
handler(entity, envelope, client.clone(), cx),
client,
)
})
}
pub fn add_view_request_handler<M, E, H, F>(self: &Arc<Self>, handler: H)
where
M: EntityMessage + RequestMessage,
E: View,
H: 'static
+ Send
+ Sync
+ Fn(ViewHandle<E>, TypedEnvelope<M>, Arc<Self>, AsyncAppContext) -> F,
F: 'static + Future<Output = Result<M::Response>>,
{
self.add_view_message_handler(move |entity, envelope, client, cx| {
Self::respond_to_request::<M, _>(
envelope.receipt(),
handler(entity, envelope, client.clone(), cx),
client,
)
})
}
async fn respond_to_request<T: RequestMessage, F: Future<Output = Result<T::Response>>>(
receipt: Receipt<T>,
response: F,
client: Arc<Self>,
) -> Result<()> {
match response.await {
Ok(response) => {
client.respond(receipt, response)?;
Ok(())
}
Err(error) => {
client.respond_with_error(
receipt,
proto::Error {
message: error.to_string(),
},
)?;
Err(error)
}
}
}
pub fn has_keychain_credentials(&self, cx: &AsyncAppContext) -> bool {
read_credentials_from_keychain(cx).is_some()
}
@@ -447,6 +565,7 @@ impl Client {
#[async_recursion(?Send)]
pub async fn authenticate_and_connect(
self: &Arc<Self>,
try_keychain: bool,
cx: &AsyncAppContext,
) -> anyhow::Result<()> {
let was_disconnected = match *self.status().borrow() {
@@ -468,23 +587,22 @@ impl Client {
self.set_status(Status::Reauthenticating, cx)
}
let mut used_keychain = false;
let credentials = self.state.read().credentials.clone();
let credentials = if let Some(credentials) = credentials {
credentials
} else if let Some(credentials) = read_credentials_from_keychain(cx) {
used_keychain = true;
credentials
} else {
let credentials = match self.authenticate(&cx).await {
let mut read_from_keychain = false;
let mut credentials = self.state.read().credentials.clone();
if credentials.is_none() && try_keychain {
credentials = read_credentials_from_keychain(cx);
read_from_keychain = credentials.is_some();
}
if credentials.is_none() {
credentials = Some(match self.authenticate(&cx).await {
Ok(credentials) => credentials,
Err(err) => {
self.set_status(Status::ConnectionError, cx);
return Err(err);
}
};
credentials
};
});
}
let credentials = credentials.unwrap();
if was_disconnected {
self.set_status(Status::Connecting, cx);
@@ -495,7 +613,7 @@ impl Client {
match self.establish_connection(&credentials, cx).await {
Ok(conn) => {
self.state.write().credentials = Some(credentials.clone());
if !used_keychain && IMPERSONATE_LOGIN.is_none() {
if !read_from_keychain && IMPERSONATE_LOGIN.is_none() {
write_credentials_to_keychain(&credentials, cx).log_err();
}
self.set_connection(conn, cx).await;
@@ -503,10 +621,10 @@ impl Client {
}
Err(EstablishConnectionError::Unauthorized) => {
self.state.write().credentials.take();
if used_keychain {
if read_from_keychain {
cx.platform().delete_credentials(&ZED_SERVER_URL).log_err();
self.set_status(Status::SignedOut, cx);
self.authenticate_and_connect(cx).await
self.authenticate_and_connect(false, cx).await
} else {
self.set_status(Status::ConnectionError, cx);
Err(EstablishConnectionError::Unauthorized)?
@@ -524,39 +642,51 @@ impl Client {
}
async fn set_connection(self: &Arc<Self>, conn: Connection, cx: &AsyncAppContext) {
let (connection_id, handle_io, mut incoming) = self.peer.add_connection(conn).await;
let executor = cx.background();
log::info!("add connection to peer");
let (connection_id, handle_io, mut incoming) = self
.peer
.add_connection(conn, move |duration| executor.timer(duration))
.await;
log::info!("set status to connected {}", connection_id);
self.set_status(Status::Connected { connection_id }, cx);
cx.foreground()
.spawn({
let cx = cx.clone();
let this = self.clone();
async move {
let mut message_id = 0_usize;
while let Some(message) = incoming.next().await {
let mut state = this.state.write();
let payload_type_id = message.payload_type_id();
message_id += 1;
let type_name = message.payload_type_name();
let payload_type_id = message.payload_type_id();
let sender_id = message.original_sender_id().map(|id| id.0);
let model = state
.models_by_message_type
.get(&payload_type_id)
.cloned()
.and_then(|model| model.upgrade(&cx))
.map(AnyEntityHandle::Model)
.or_else(|| {
let model_type_id =
*state.model_types_by_message_type.get(&payload_type_id)?;
let entity_type_id =
*state.entity_types_by_message_type.get(&payload_type_id)?;
let entity_id = state
.entity_id_extractors
.get(&message.payload_type_id())
.map(|extract_entity_id| {
(extract_entity_id)(message.as_ref())
})?;
let model = state
.models_by_entity_type_and_remote_id
.get(&(model_type_id, entity_id))?;
if let Some(model) = model.upgrade(&cx) {
Some(model)
let entity = state
.entities_by_type_and_remote_id
.get(&(entity_type_id, entity_id))?;
if let Some(entity) = entity.upgrade(&cx) {
Some(entity)
} else {
state
.models_by_entity_type_and_remote_id
.remove(&(model_type_id, entity_id));
.entities_by_type_and_remote_id
.remove(&(entity_type_id, entity_id));
None
}
});
@@ -571,12 +701,14 @@ impl Client {
if let Some(handler) = state.message_handlers.get(&payload_type_id).cloned()
{
drop(state); // Avoid deadlocks if the handler interacts with rpc::Client
let future = handler(model, message, cx.clone());
let future = handler(model, message, &this, cx.clone());
let client_id = this.id;
log::debug!(
"rpc message received. client_id:{}, name:{}",
"rpc message received. client_id:{}, message_id:{}, sender_id:{:?}, type:{}",
client_id,
message_id,
sender_id,
type_name
);
cx.foreground()
@@ -584,15 +716,19 @@ impl Client {
match future.await {
Ok(()) => {
log::debug!(
"rpc message handled. client_id:{}, name:{}",
"rpc message handled. client_id:{}, message_id:{}, sender_id:{:?}, type:{}",
client_id,
message_id,
sender_id,
type_name
);
}
Err(error) => {
log::error!(
"error handling message. client_id:{}, name:{}, {}",
"error handling message. client_id:{}, message_id:{}, sender_id:{:?}, type:{}, error:{:?}",
client_id,
message_id,
sender_id,
type_name,
error
);
@@ -603,20 +739,25 @@ impl Client {
} else {
log::info!("unhandled message {}", type_name);
}
// Don't starve the main thread when receiving lots of messages at once.
smol::future::yield_now().await;
}
}
})
.detach();
self.set_status(Status::Connected { connection_id }, cx);
let handle_io = cx.background().spawn(handle_io);
let this = self.clone();
let cx = cx.clone();
cx.foreground()
.spawn(async move {
match handle_io.await {
Ok(()) => this.set_status(Status::SignedOut, &cx),
Ok(()) => {
if *this.status().borrow() == (Status::Connected { connection_id }) {
this.set_status(Status::SignedOut, &cx);
}
}
Err(err) => {
log::error!("connection error: {:?}", err);
this.set_status(Status::ConnectionLost, &cx);
@@ -627,11 +768,12 @@ impl Client {
}
fn authenticate(self: &Arc<Self>, cx: &AsyncAppContext) -> Task<Result<Credentials>> {
if let Some(callback) = self.authenticate.as_ref() {
callback(cx)
} else {
self.authenticate_with_browser(cx)
#[cfg(any(test, feature = "test-support"))]
if let Some(callback) = self.authenticate.read().as_ref() {
return callback(cx);
}
self.authenticate_with_browser(cx)
}
fn establish_connection(
@@ -639,11 +781,12 @@ impl Client {
credentials: &Credentials,
cx: &AsyncAppContext,
) -> Task<Result<Connection, EstablishConnectionError>> {
if let Some(callback) = self.establish_connection.as_ref() {
callback(credentials, cx)
} else {
self.establish_websocket_connection(credentials, cx)
#[cfg(any(test, feature = "test-support"))]
if let Some(callback) = self.establish_connection.read().as_ref() {
return callback(credentials, cx);
}
self.establish_websocket_connection(credentials, cx)
}
fn establish_websocket_connection(
@@ -656,35 +799,32 @@ impl Client {
"Authorization",
format!("{} {}", credentials.user_id, credentials.access_token),
)
.header("X-Zed-Protocol-Version", rpc::PROTOCOL_VERSION);
.header("x-zed-protocol-version", rpc::PROTOCOL_VERSION);
let http = self.http.clone();
cx.background().spawn(async move {
let mut rpc_url = format!("{}/rpc", *ZED_SERVER_URL);
let rpc_request = surf::Request::new(
Method::Get,
surf::Url::parse(&rpc_url).context("invalid ZED_SERVER_URL")?,
);
let rpc_response = http.send(rpc_request).await?;
let rpc_response = http.get(&rpc_url, Default::default(), false).await?;
if rpc_response.status().is_redirection() {
rpc_url = rpc_response
.header("Location")
.headers()
.get("Location")
.ok_or_else(|| anyhow!("missing location header in /rpc response"))?
.as_str()
.to_str()
.map_err(|error| EstablishConnectionError::other(error))?
.to_string();
}
// Until we switch the zed.dev domain to point to the new Next.js app, there
// will be no redirect required, and the app will connect directly to
// wss://zed.dev/rpc.
else if rpc_response.status() != surf::StatusCode::UpgradeRequired {
else if rpc_response.status() != StatusCode::UPGRADE_REQUIRED {
Err(anyhow!(
"unexpected /rpc response status {}",
rpc_response.status()
))?
}
let mut rpc_url = surf::Url::parse(&rpc_url).context("invalid rpc url")?;
let mut rpc_url = Url::parse(&rpc_url).context("invalid rpc url")?;
let rpc_host = rpc_url
.host_str()
.zip(rpc_url.port_or_known_default())
@@ -699,13 +839,21 @@ impl Client {
let request = request.uri(rpc_url.as_str()).body(())?;
let (stream, _) =
async_tungstenite::async_tls::client_async_tls(request, stream).await?;
Ok(Connection::new(stream))
Ok(Connection::new(
stream
.map_err(|error| anyhow!(error))
.sink_map_err(|error| anyhow!(error)),
))
}
"http" => {
rpc_url.set_scheme("ws").unwrap();
let request = request.uri(rpc_url.as_str()).body(())?;
let (stream, _) = async_tungstenite::client_async(request, stream).await?;
Ok(Connection::new(stream))
Ok(Connection::new(
stream
.map_err(|error| anyhow!(error))
.sink_map_err(|error| anyhow!(error)),
))
}
_ => Err(anyhow!("invalid rpc url: {}", rpc_url))?,
}
@@ -827,7 +975,7 @@ impl Client {
) -> impl Future<Output = Result<T::Response>> {
let client_id = self.id;
log::debug!(
"rpc request start. client_id: {}. name:{}",
"rpc request start. client_id:{}. name:{}",
client_id,
T::NAME
);
@@ -837,7 +985,7 @@ impl Client {
async move {
let response = response?.await;
log::debug!(
"rpc request finish. client_id: {}. name:{}",
"rpc request finish. client_id:{}. name:{}",
client_id,
T::NAME
);
@@ -846,7 +994,7 @@ impl Client {
}
fn respond<T: RequestMessage>(&self, receipt: Receipt<T>, response: T::Response) -> Result<()> {
log::debug!("rpc respond. client_id: {}. name:{}", self.id, T::NAME);
log::debug!("rpc respond. client_id:{}. name:{}", self.id, T::NAME);
self.peer.respond(receipt, response)
}
@@ -855,11 +1003,20 @@ impl Client {
receipt: Receipt<T>,
error: proto::Error,
) -> Result<()> {
log::debug!("rpc respond. client_id: {}. name:{}", self.id, T::NAME);
log::debug!("rpc respond. client_id:{}. name:{}", self.id, T::NAME);
self.peer.respond_with_error(receipt, error)
}
}
impl AnyWeakEntityHandle {
fn upgrade(&self, cx: &AsyncAppContext) -> Option<AnyEntityHandle> {
match self {
AnyWeakEntityHandle::Model(handle) => handle.upgrade(cx).map(AnyEntityHandle::Model),
AnyWeakEntityHandle::View(handle) => handle.upgrade(cx).map(AnyEntityHandle::View),
}
}
}
fn read_credentials_from_keychain(cx: &AsyncAppContext) -> Option<Credentials> {
if IMPERSONATE_LOGIN.is_some() {
return None;
@@ -908,27 +1065,7 @@ mod tests {
use gpui::TestAppContext;
#[gpui::test(iterations = 10)]
async fn test_heartbeat(cx: TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
let mut client = Client::new(FakeHttpClient::with_404_response());
let server = FakeServer::for_client(user_id, &mut client, &cx).await;
cx.foreground().advance_clock(Duration::from_secs(10));
let ping = server.receive::<proto::Ping>().await.unwrap();
server.respond(ping.receipt(), proto::Ack {}).await;
cx.foreground().advance_clock(Duration::from_secs(10));
let ping = server.receive::<proto::Ping>().await.unwrap();
server.respond(ping.receipt(), proto::Ack {}).await;
client.disconnect(&cx.to_async()).unwrap();
assert!(server.receive::<proto::Ping>().await.is_err());
}
#[gpui::test(iterations = 10)]
async fn test_reconnection(cx: TestAppContext) {
async fn test_reconnection(cx: &mut TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
@@ -958,8 +1095,6 @@ mod tests {
server.roll_access_token();
server.allow_connections();
cx.foreground().advance_clock(Duration::from_secs(10));
assert_eq!(server.auth_count(), 1);
cx.foreground().advance_clock(Duration::from_secs(10));
while !matches!(status.next().await, Some(Status::Connected { .. })) {}
assert_eq!(server.auth_count(), 2); // Client re-authenticated due to an invalid token
}
@@ -976,7 +1111,7 @@ mod tests {
}
#[gpui::test]
async fn test_subscribing_to_entity(mut cx: TestAppContext) {
async fn test_subscribing_to_entity(cx: &mut TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
@@ -985,8 +1120,8 @@ mod tests {
let (done_tx1, mut done_rx1) = smol::channel::unbounded();
let (done_tx2, mut done_rx2) = smol::channel::unbounded();
client.add_entity_message_handler(
move |model: ModelHandle<Model>, _: TypedEnvelope<proto::UnshareProject>, _, cx| {
client.add_model_message_handler(
move |model: ModelHandle<Model>, _: TypedEnvelope<proto::JoinProject>, _, cx| {
match model.read_with(&cx, |model, _| model.id) {
1 => done_tx1.try_send(()).unwrap(),
2 => done_tx2.try_send(()).unwrap(),
@@ -1008,24 +1143,21 @@ mod tests {
subscription: None,
});
let _subscription1 =
model1.update(&mut cx, |_, cx| client.add_model_for_remote_entity(1, cx));
let _subscription2 =
model2.update(&mut cx, |_, cx| client.add_model_for_remote_entity(2, cx));
let _subscription1 = model1.update(cx, |_, cx| client.add_model_for_remote_entity(1, cx));
let _subscription2 = model2.update(cx, |_, cx| client.add_model_for_remote_entity(2, cx));
// Ensure dropping a subscription for the same entity type still allows receiving of
// messages for other entity IDs of the same type.
let subscription3 =
model3.update(&mut cx, |_, cx| client.add_model_for_remote_entity(3, cx));
let subscription3 = model3.update(cx, |_, cx| client.add_model_for_remote_entity(3, cx));
drop(subscription3);
server.send(proto::UnshareProject { project_id: 1 });
server.send(proto::UnshareProject { project_id: 2 });
server.send(proto::JoinProject { project_id: 1 });
server.send(proto::JoinProject { project_id: 2 });
done_rx1.next().await.unwrap();
done_rx2.next().await.unwrap();
}
#[gpui::test]
async fn test_subscribing_after_dropping_subscription(mut cx: TestAppContext) {
async fn test_subscribing_after_dropping_subscription(cx: &mut TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
@@ -1053,7 +1185,7 @@ mod tests {
}
#[gpui::test]
async fn test_dropping_subscription_in_handler(mut cx: TestAppContext) {
async fn test_dropping_subscription_in_handler(cx: &mut TestAppContext) {
cx.foreground().forbid_parking();
let user_id = 5;
@@ -1070,7 +1202,7 @@ mod tests {
async { Ok(()) }
},
);
model.update(&mut cx, |model, _| {
model.update(cx, |model, _| {
model.subscription = Some(subscription);
});
server.send(proto::Ping {});

View File

@@ -1,26 +1,51 @@
pub use anyhow::{anyhow, Result};
use futures::future::BoxFuture;
use std::sync::Arc;
pub use surf::{
http::{Method, Response as ServerResponse},
Request, Response, Url,
use isahc::{
config::{Configurable, RedirectPolicy},
AsyncBody,
};
pub use isahc::{
http::{Method, Uri},
Error,
};
use smol::future::FutureExt;
use std::sync::Arc;
pub use url::Url;
pub type Request = isahc::Request<AsyncBody>;
pub type Response = isahc::Response<AsyncBody>;
pub trait HttpClient: Send + Sync {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response>>;
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response, Error>>;
fn get<'a>(
&'a self,
uri: &str,
body: AsyncBody,
follow_redirects: bool,
) -> BoxFuture<'a, Result<Response, Error>> {
let request = isahc::Request::builder()
.redirect_policy(if follow_redirects {
RedirectPolicy::Follow
} else {
RedirectPolicy::None
})
.method(Method::GET)
.uri(uri)
.body(body);
match request {
Ok(request) => self.send(request),
Err(error) => async move { Err(error.into()) }.boxed(),
}
}
}
pub fn client() -> Arc<dyn HttpClient> {
Arc::new(surf::client())
Arc::new(isahc::HttpClient::builder().build().unwrap())
}
impl HttpClient for surf::Client {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response>> {
Box::pin(async move {
Ok(self
.send(req)
.await
.map_err(|e| anyhow!("http request failed: {}", e))?)
})
impl HttpClient for isahc::HttpClient {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response, Error>> {
Box::pin(async move { self.send_async(req).await })
}
}

View File

@@ -1,5 +1,5 @@
use crate::{
http::{HttpClient, Request, Response, ServerResponse},
http::{self, HttpClient, Request, Response},
Client, Connection, Credentials, EstablishConnectionError, UserStore,
};
use anyhow::{anyhow, Result};
@@ -28,7 +28,7 @@ struct FakeServerState {
impl FakeServer {
pub async fn for_client(
client_user_id: u64,
client: &mut Arc<Client>,
client: &Arc<Client>,
cx: &TestAppContext,
) -> Self {
let server = Self {
@@ -38,15 +38,16 @@ impl FakeServer {
executor: cx.foreground(),
};
Arc::get_mut(client)
.unwrap()
client
.override_authenticate({
let state = server.state.clone();
let state = Arc::downgrade(&server.state);
move |cx| {
let mut state = state.lock();
state.auth_count += 1;
let access_token = state.access_token.to_string();
let state = state.clone();
cx.spawn(move |_| async move {
let state = state.upgrade().ok_or_else(|| anyhow!("server dropped"))?;
let mut state = state.lock();
state.auth_count += 1;
let access_token = state.access_token.to_string();
Ok(Credentials {
user_id: client_user_id,
access_token,
@@ -55,27 +56,30 @@ impl FakeServer {
}
})
.override_establish_connection({
let peer = server.peer.clone();
let state = server.state.clone();
let peer = Arc::downgrade(&server.peer).clone();
let state = Arc::downgrade(&server.state);
move |credentials, cx| {
let peer = peer.clone();
let state = state.clone();
let credentials = credentials.clone();
cx.spawn(move |cx| async move {
assert_eq!(credentials.user_id, client_user_id);
let state = state.upgrade().ok_or_else(|| anyhow!("server dropped"))?;
let peer = peer.upgrade().ok_or_else(|| anyhow!("server dropped"))?;
if state.lock().forbid_connections {
Err(EstablishConnectionError::Other(anyhow!(
"server is forbidding connections"
)))?
}
assert_eq!(credentials.user_id, client_user_id);
if credentials.access_token != state.lock().access_token.to_string() {
Err(EstablishConnectionError::Unauthorized)?
}
let (client_conn, server_conn, _) = Connection::in_memory(cx.background());
let (connection_id, io, incoming) = peer.add_connection(server_conn).await;
let (connection_id, io, incoming) =
peer.add_test_connection(server_conn, cx.background()).await;
cx.background().spawn(io).detach();
let mut state = state.lock();
state.connection_id = Some(connection_id);
@@ -86,7 +90,7 @@ impl FakeServer {
});
client
.authenticate_and_connect(&cx.to_async())
.authenticate_and_connect(false, &cx.to_async())
.await
.unwrap();
server
@@ -174,15 +178,25 @@ impl FakeServer {
}
}
impl Drop for FakeServer {
fn drop(&mut self) {
self.disconnect();
}
}
pub struct FakeHttpClient {
handler:
Box<dyn 'static + Send + Sync + Fn(Request) -> BoxFuture<'static, Result<ServerResponse>>>,
handler: Box<
dyn 'static
+ Send
+ Sync
+ Fn(Request) -> BoxFuture<'static, Result<Response, http::Error>>,
>,
}
impl FakeHttpClient {
pub fn new<Fut, F>(handler: F) -> Arc<dyn HttpClient>
where
Fut: 'static + Send + Future<Output = Result<ServerResponse>>,
Fut: 'static + Send + Future<Output = Result<Response, http::Error>>,
F: 'static + Send + Sync + Fn(Request) -> Fut,
{
Arc::new(Self {
@@ -191,7 +205,12 @@ impl FakeHttpClient {
}
pub fn with_404_response() -> Arc<dyn HttpClient> {
Self::new(|_| async move { Ok(ServerResponse::new(404)) })
Self::new(|_| async move {
Ok(isahc::Response::builder()
.status(404)
.body(Default::default())
.unwrap())
})
}
}
@@ -202,7 +221,7 @@ impl fmt::Debug for FakeHttpClient {
}
impl HttpClient for FakeHttpClient {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response>> {
fn send<'a>(&'a self, req: Request) -> BoxFuture<'a, Result<Response, crate::http::Error>> {
let future = (self.handler)(req);
Box::pin(async move { future.await.map(Into::into) })
}

View File

@@ -1,15 +1,11 @@
use super::{
http::{HttpClient, Method, Request, Url},
proto, Client, Status, TypedEnvelope,
};
use super::{http::HttpClient, proto, Client, Status, TypedEnvelope};
use anyhow::{anyhow, Context, Result};
use futures::future;
use collections::{hash_map::Entry, BTreeSet, HashMap, HashSet};
use futures::{channel::mpsc, future, AsyncReadExt, Future, StreamExt};
use gpui::{AsyncAppContext, Entity, ImageData, ModelContext, ModelHandle, Task};
use postage::{prelude::Stream, sink::Sink, watch};
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use rpc::proto::{RequestMessage, UsersResponse};
use std::sync::{Arc, Weak};
use util::TryFutureExt as _;
#[derive(Debug)]
@@ -19,37 +15,94 @@ pub struct User {
pub avatar: Option<Arc<ImageData>>,
}
#[derive(Debug)]
impl PartialOrd for User {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(&other))
}
}
impl Ord for User {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.github_login.cmp(&other.github_login)
}
}
impl PartialEq for User {
fn eq(&self, other: &Self) -> bool {
self.id == other.id && self.github_login == other.github_login
}
}
impl Eq for User {}
#[derive(Debug, PartialEq)]
pub struct Contact {
pub user: Arc<User>,
pub online: bool,
pub projects: Vec<ProjectMetadata>,
}
#[derive(Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct ProjectMetadata {
pub id: u64,
pub is_shared: bool,
pub worktree_root_names: Vec<String>,
pub guests: Vec<Arc<User>>,
pub visible_worktree_root_names: Vec<String>,
pub guests: BTreeSet<Arc<User>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ContactRequestStatus {
None,
RequestSent,
RequestReceived,
RequestAccepted,
}
pub struct UserStore {
users: HashMap<u64, Arc<User>>,
update_contacts_tx: watch::Sender<Option<proto::UpdateContacts>>,
update_contacts_tx: mpsc::UnboundedSender<UpdateContacts>,
current_user: watch::Receiver<Option<Arc<User>>>,
contacts: Arc<[Contact]>,
client: Arc<Client>,
contacts: Vec<Arc<Contact>>,
incoming_contact_requests: Vec<Arc<User>>,
outgoing_contact_requests: Vec<Arc<User>>,
pending_contact_requests: HashMap<u64, usize>,
invite_info: Option<InviteInfo>,
client: Weak<Client>,
http: Arc<dyn HttpClient>,
_maintain_contacts: Task<()>,
_maintain_current_user: Task<()>,
}
pub enum Event {}
#[derive(Clone)]
pub struct InviteInfo {
pub count: u32,
pub url: Arc<str>,
}
pub enum Event {
Contact {
user: Arc<User>,
kind: ContactEventKind,
},
ShowContacts,
}
#[derive(Clone, Copy)]
pub enum ContactEventKind {
Requested,
Accepted,
Cancelled,
}
impl Entity for UserStore {
type Event = Event;
}
enum UpdateContacts {
Update(proto::UpdateContacts),
Wait(postage::barrier::Sender),
Clear(postage::barrier::Sender),
}
impl UserStore {
pub fn new(
client: Arc<Client>,
@@ -57,21 +110,26 @@ impl UserStore {
cx: &mut ModelContext<Self>,
) -> Self {
let (mut current_user_tx, current_user_rx) = watch::channel();
let (update_contacts_tx, mut update_contacts_rx) =
watch::channel::<Option<proto::UpdateContacts>>();
let rpc_subscription =
client.add_message_handler(cx.handle(), Self::handle_update_contacts);
let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded();
let rpc_subscriptions = vec![
client.add_message_handler(cx.handle(), Self::handle_update_contacts),
client.add_message_handler(cx.handle(), Self::handle_update_invite_info),
client.add_message_handler(cx.handle(), Self::handle_show_contacts),
];
Self {
users: Default::default(),
current_user: current_user_rx,
contacts: Arc::from([]),
client: client.clone(),
contacts: Default::default(),
incoming_contact_requests: Default::default(),
outgoing_contact_requests: Default::default(),
invite_info: None,
client: Arc::downgrade(&client),
update_contacts_tx,
http,
_maintain_contacts: cx.spawn_weak(|this, mut cx| async move {
let _subscription = rpc_subscription;
while let Some(message) = update_contacts_rx.recv().await {
if let Some((message, this)) = message.zip(this.upgrade(&cx)) {
let _subscriptions = rpc_subscriptions;
while let Some(message) = update_contacts_rx.next().await {
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, cx| this.update_contacts(message, cx))
.log_err()
.await;
@@ -93,90 +151,385 @@ impl UserStore {
}
Status::SignedOut => {
current_user_tx.send(None).await.ok();
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, _| this.clear_contacts()).await;
}
}
Status::ConnectionLost => {
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, _| this.clear_contacts()).await;
}
}
_ => {}
}
}
}),
pending_contact_requests: Default::default(),
}
}
async fn handle_update_invite_info(
this: ModelHandle<Self>,
message: TypedEnvelope<proto::UpdateInviteInfo>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |this, cx| {
this.invite_info = Some(InviteInfo {
url: Arc::from(message.payload.url),
count: message.payload.count,
});
cx.notify();
});
Ok(())
}
async fn handle_show_contacts(
this: ModelHandle<Self>,
_: TypedEnvelope<proto::ShowContacts>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |_, cx| cx.emit(Event::ShowContacts));
Ok(())
}
pub fn invite_info(&self) -> Option<&InviteInfo> {
self.invite_info.as_ref()
}
async fn handle_update_contacts(
this: ModelHandle<Self>,
msg: TypedEnvelope<proto::UpdateContacts>,
message: TypedEnvelope<proto::UpdateContacts>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |this, _| {
*this.update_contacts_tx.borrow_mut() = Some(msg.payload);
this.update_contacts_tx
.unbounded_send(UpdateContacts::Update(message.payload))
.unwrap();
});
Ok(())
}
fn update_contacts(
&mut self,
message: proto::UpdateContacts,
message: UpdateContacts,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let mut user_ids = HashSet::new();
for contact in &message.contacts {
user_ids.insert(contact.user_id);
user_ids.extend(contact.projects.iter().flat_map(|w| &w.guests).copied());
}
let load_users = self.load_users(user_ids.into_iter().collect(), cx);
cx.spawn(|this, mut cx| async move {
load_users.await?;
let mut contacts = Vec::new();
for contact in message.contacts {
contacts.push(Contact::from_proto(contact, &this, &mut cx).await?);
match message {
UpdateContacts::Wait(barrier) => {
drop(barrier);
Task::ready(Ok(()))
}
UpdateContacts::Clear(barrier) => {
self.contacts.clear();
self.incoming_contact_requests.clear();
self.outgoing_contact_requests.clear();
drop(barrier);
Task::ready(Ok(()))
}
UpdateContacts::Update(message) => {
let mut user_ids = HashSet::default();
for contact in &message.contacts {
user_ids.insert(contact.user_id);
user_ids.extend(contact.projects.iter().flat_map(|w| &w.guests).copied());
}
user_ids.extend(message.incoming_requests.iter().map(|req| req.requester_id));
user_ids.extend(message.outgoing_requests.iter());
this.update(&mut cx, |this, cx| {
contacts.sort_by(|a, b| a.user.github_login.cmp(&b.user.github_login));
this.contacts = contacts.into();
cx.notify();
});
let load_users = self.get_users(user_ids.into_iter().collect(), cx);
cx.spawn(|this, mut cx| async move {
load_users.await?;
// Users are fetched in parallel above and cached in call to get_users
// No need to paralellize here
let mut updated_contacts = Vec::new();
for contact in message.contacts {
let should_notify = contact.should_notify;
updated_contacts.push((
Arc::new(Contact::from_proto(contact, &this, &mut cx).await?),
should_notify,
));
}
let mut incoming_requests = Vec::new();
for request in message.incoming_requests {
incoming_requests.push({
let user = this
.update(&mut cx, |this, cx| {
this.fetch_user(request.requester_id, cx)
})
.await?;
(user, request.should_notify)
});
}
let mut outgoing_requests = Vec::new();
for requested_user_id in message.outgoing_requests {
outgoing_requests.push(
this.update(&mut cx, |this, cx| this.fetch_user(requested_user_id, cx))
.await?,
);
}
let removed_contacts =
HashSet::<u64>::from_iter(message.remove_contacts.iter().copied());
let removed_incoming_requests =
HashSet::<u64>::from_iter(message.remove_incoming_requests.iter().copied());
let removed_outgoing_requests =
HashSet::<u64>::from_iter(message.remove_outgoing_requests.iter().copied());
this.update(&mut cx, |this, cx| {
// Remove contacts
this.contacts
.retain(|contact| !removed_contacts.contains(&contact.user.id));
// Update existing contacts and insert new ones
for (updated_contact, should_notify) in updated_contacts {
if should_notify {
cx.emit(Event::Contact {
user: updated_contact.user.clone(),
kind: ContactEventKind::Accepted,
});
}
match this.contacts.binary_search_by_key(
&&updated_contact.user.github_login,
|contact| &contact.user.github_login,
) {
Ok(ix) => this.contacts[ix] = updated_contact,
Err(ix) => this.contacts.insert(ix, updated_contact),
}
}
// Remove incoming contact requests
this.incoming_contact_requests.retain(|user| {
if removed_incoming_requests.contains(&user.id) {
cx.emit(Event::Contact {
user: user.clone(),
kind: ContactEventKind::Cancelled,
});
false
} else {
true
}
});
// Update existing incoming requests and insert new ones
for (user, should_notify) in incoming_requests {
if should_notify {
cx.emit(Event::Contact {
user: user.clone(),
kind: ContactEventKind::Requested,
});
}
match this
.incoming_contact_requests
.binary_search_by_key(&&user.github_login, |contact| {
&contact.github_login
}) {
Ok(ix) => this.incoming_contact_requests[ix] = user,
Err(ix) => this.incoming_contact_requests.insert(ix, user),
}
}
// Remove outgoing contact requests
this.outgoing_contact_requests
.retain(|user| !removed_outgoing_requests.contains(&user.id));
// Update existing incoming requests and insert new ones
for request in outgoing_requests {
match this
.outgoing_contact_requests
.binary_search_by_key(&&request.github_login, |contact| {
&contact.github_login
}) {
Ok(ix) => this.outgoing_contact_requests[ix] = request,
Err(ix) => this.outgoing_contact_requests.insert(ix, request),
}
}
cx.notify();
});
Ok(())
})
}
}
}
pub fn contacts(&self) -> &[Arc<Contact>] {
&self.contacts
}
pub fn has_contact(&self, user: &Arc<User>) -> bool {
self.contacts
.binary_search_by_key(&&user.github_login, |contact| &contact.user.github_login)
.is_ok()
}
pub fn incoming_contact_requests(&self) -> &[Arc<User>] {
&self.incoming_contact_requests
}
pub fn outgoing_contact_requests(&self) -> &[Arc<User>] {
&self.outgoing_contact_requests
}
pub fn is_contact_request_pending(&self, user: &User) -> bool {
self.pending_contact_requests.contains_key(&user.id)
}
pub fn contact_request_status(&self, user: &User) -> ContactRequestStatus {
if self
.contacts
.binary_search_by_key(&&user.github_login, |contact| &contact.user.github_login)
.is_ok()
{
ContactRequestStatus::RequestAccepted
} else if self
.outgoing_contact_requests
.binary_search_by_key(&&user.github_login, |user| &user.github_login)
.is_ok()
{
ContactRequestStatus::RequestSent
} else if self
.incoming_contact_requests
.binary_search_by_key(&&user.github_login, |user| &user.github_login)
.is_ok()
{
ContactRequestStatus::RequestReceived
} else {
ContactRequestStatus::None
}
}
pub fn request_contact(
&mut self,
responder_id: u64,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
self.perform_contact_request(responder_id, proto::RequestContact { responder_id }, cx)
}
pub fn remove_contact(
&mut self,
user_id: u64,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
self.perform_contact_request(user_id, proto::RemoveContact { user_id }, cx)
}
pub fn respond_to_contact_request(
&mut self,
requester_id: u64,
accept: bool,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
self.perform_contact_request(
requester_id,
proto::RespondToContactRequest {
requester_id,
response: if accept {
proto::ContactRequestResponse::Accept
} else {
proto::ContactRequestResponse::Decline
} as i32,
},
cx,
)
}
pub fn dismiss_contact_request(
&mut self,
requester_id: u64,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let client = self.client.upgrade();
cx.spawn_weak(|_, _| async move {
client
.ok_or_else(|| anyhow!("can't upgrade client reference"))?
.request(proto::RespondToContactRequest {
requester_id,
response: proto::ContactRequestResponse::Dismiss as i32,
})
.await?;
Ok(())
})
}
pub fn contacts(&self) -> &Arc<[Contact]> {
&self.contacts
fn perform_contact_request<T: RequestMessage>(
&mut self,
user_id: u64,
request: T,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let client = self.client.upgrade();
*self.pending_contact_requests.entry(user_id).or_insert(0) += 1;
cx.notify();
cx.spawn(|this, mut cx| async move {
let response = client
.ok_or_else(|| anyhow!("can't upgrade client reference"))?
.request(request)
.await;
this.update(&mut cx, |this, cx| {
if let Entry::Occupied(mut request_count) =
this.pending_contact_requests.entry(user_id)
{
*request_count.get_mut() -= 1;
if *request_count.get() == 0 {
request_count.remove();
}
}
cx.notify();
});
response?;
Ok(())
})
}
pub fn load_users(
pub fn clear_contacts(&mut self) -> impl Future<Output = ()> {
let (tx, mut rx) = postage::barrier::channel();
self.update_contacts_tx
.unbounded_send(UpdateContacts::Clear(tx))
.unwrap();
async move {
rx.recv().await;
}
}
pub fn contact_updates_done(&mut self) -> impl Future<Output = ()> {
let (tx, mut rx) = postage::barrier::channel();
self.update_contacts_tx
.unbounded_send(UpdateContacts::Wait(tx))
.unwrap();
async move {
rx.recv().await;
}
}
pub fn get_users(
&mut self,
mut user_ids: Vec<u64>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let rpc = self.client.clone();
let http = self.http.clone();
user_ids.retain(|id| !self.users.contains_key(id));
cx.spawn_weak(|this, mut cx| async move {
if !user_ids.is_empty() {
let response = rpc.request(proto::GetUsers { user_ids }).await?;
let new_users = future::join_all(
response
.users
.into_iter()
.map(|user| User::new(user, http.as_ref())),
)
.await;
if user_ids.is_empty() {
Task::ready(Ok(()))
} else {
let load = self.load_users(proto::GetUsers { user_ids }, cx);
cx.foreground().spawn(async move {
load.await?;
Ok(())
})
}
}
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, _| {
for user in new_users {
this.users.insert(user.id, Arc::new(user));
}
});
}
}
Ok(())
})
pub fn fuzzy_search_users(
&mut self,
query: String,
cx: &mut ModelContext<Self>,
) -> Task<Result<Vec<Arc<User>>>> {
self.load_users(proto::FuzzySearchUsers { query }, cx)
}
pub fn fetch_user(
@@ -185,10 +538,10 @@ impl UserStore {
cx: &mut ModelContext<Self>,
) -> Task<Result<Arc<User>>> {
if let Some(user) = self.users.get(&user_id).cloned() {
return cx.spawn_weak(|_, _| async move { Ok(user) });
return cx.foreground().spawn(async move { Ok(user) });
}
let load_users = self.load_users(vec![user_id], cx);
let load_users = self.get_users(vec![user_id], cx);
cx.spawn(|this, mut cx| async move {
load_users.await?;
this.update(&mut cx, |this, _| {
@@ -207,15 +560,47 @@ impl UserStore {
pub fn watch_current_user(&self) -> watch::Receiver<Option<Arc<User>>> {
self.current_user.clone()
}
fn load_users(
&mut self,
request: impl RequestMessage<Response = UsersResponse>,
cx: &mut ModelContext<Self>,
) -> Task<Result<Vec<Arc<User>>>> {
let client = self.client.clone();
let http = self.http.clone();
cx.spawn_weak(|this, mut cx| async move {
if let Some(rpc) = client.upgrade() {
let response = rpc.request(request).await.context("error loading users")?;
let users = future::join_all(
response
.users
.into_iter()
.map(|user| User::new(user, http.as_ref())),
)
.await;
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, _| {
for user in &users {
this.users.insert(user.id, user.clone());
}
});
}
Ok(users)
} else {
Ok(Vec::new())
}
})
}
}
impl User {
async fn new(message: proto::User, http: &dyn HttpClient) -> Self {
User {
async fn new(message: proto::User, http: &dyn HttpClient) -> Arc<Self> {
Arc::new(User {
id: message.id,
github_login: message.github_login,
avatar: fetch_avatar(http, &message.avatar_url).warn_on_err().await,
}
})
}
}
@@ -232,9 +617,9 @@ impl Contact {
.await?;
let mut projects = Vec::new();
for project in contact.projects {
let mut guests = Vec::new();
let mut guests = BTreeSet::new();
for participant_id in project.guests {
guests.push(
guests.insert(
user_store
.update(cx, |user_store, cx| {
user_store.fetch_user(participant_id, cx)
@@ -244,32 +629,41 @@ impl Contact {
}
projects.push(ProjectMetadata {
id: project.id,
worktree_root_names: project.worktree_root_names.clone(),
is_shared: project.is_shared,
visible_worktree_root_names: project.visible_worktree_root_names.clone(),
guests,
});
}
Ok(Self { user, projects })
Ok(Self {
user,
online: contact.online,
projects,
})
}
pub fn non_empty_projects(&self) -> impl Iterator<Item = &ProjectMetadata> {
self.projects
.iter()
.filter(|project| !project.visible_worktree_root_names.is_empty())
}
}
async fn fetch_avatar(http: &dyn HttpClient, url: &str) -> Result<Arc<ImageData>> {
let url = Url::parse(url).with_context(|| format!("failed to parse avatar url {:?}", url))?;
let mut request = Request::new(Method::Get, url);
request.middleware(surf::middleware::Redirect::default());
let mut response = http
.send(request)
.get(url, Default::default(), true)
.await
.map_err(|e| anyhow!("failed to send user avatar request: {}", e))?;
if !response.status().is_success() {
return Err(anyhow!("avatar request failed {:?}", response.status()));
}
let bytes = response
.body_bytes()
let mut body = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.map_err(|e| anyhow!("failed to read user avatar response body: {}", e))?;
let format = image::guess_format(&bytes)?;
let image = image::load_from_memory_with_format(&bytes, format)?.into_bgra8();
let format = image::guess_format(&body)?;
let image = image::load_from_memory_with_format(&body, format)?.into_bgra8();
Ok(ImageData::new(image))
}

View File

@@ -5,7 +5,7 @@ edition = "2021"
[lib]
path = "src/clock.rs"
doctest = false
[dependencies]
smallvec = { version = "1.6", features = ["union"] }
rpc = { path = "../rpc" }

View File

@@ -69,37 +69,6 @@ impl<'a> AddAssign<&'a Local> for Local {
#[derive(Clone, Default, Hash, Eq, PartialEq)]
pub struct Global(SmallVec<[u32; 8]>);
impl From<Vec<rpc::proto::VectorClockEntry>> for Global {
fn from(message: Vec<rpc::proto::VectorClockEntry>) -> Self {
let mut version = Self::new();
for entry in message {
version.observe(Local {
replica_id: entry.replica_id as ReplicaId,
value: entry.timestamp,
});
}
version
}
}
impl<'a> From<&'a Global> for Vec<rpc::proto::VectorClockEntry> {
fn from(version: &'a Global) -> Self {
version
.iter()
.map(|entry| rpc::proto::VectorClockEntry {
replica_id: entry.replica_id as u32,
timestamp: entry.value,
})
.collect()
}
}
impl From<Global> for Vec<rpc::proto::VectorClockEntry> {
fn from(version: Global) -> Self {
(&version).into()
}
}
impl Global {
pub fn new() -> Self {
Self::default()

View File

@@ -0,0 +1,9 @@
DATABASE_URL = "postgres://postgres@localhost/zed"
HTTP_PORT = 8080
API_TOKEN = "secret"
INVITE_LINK_PREFIX = "http://localhost:3000/invites/"
# HONEYCOMB_API_KEY=
# HONEYCOMB_DATASET=
# RUST_LOG=info
# LOG_JSON=true

75
crates/collab/Cargo.toml Normal file
View File

@@ -0,0 +1,75 @@
[package]
authors = ["Nathan Sobo <nathan@warp.dev>"]
default-run = "collab"
edition = "2021"
name = "collab"
version = "0.1.0"
[[bin]]
name = "collab"
[[bin]]
name = "seed"
required-features = ["seed-support"]
[dependencies]
collections = { path = "../collections" }
rpc = { path = "../rpc" }
util = { path = "../util" }
anyhow = "1.0.40"
async-trait = "0.1.50"
async-tungstenite = "0.16"
axum = { version = "0.5", features = ["json", "headers", "ws"] }
axum-extra = { version = "0.3", features = ["erased-json"] }
base64 = "0.13"
clap = { version = "3.1", features = ["derive"], optional = true }
envy = "0.4.2"
futures = "0.3"
hyper = "0.14"
lazy_static = "1.4"
lipsum = { version = "0.8", optional = true }
nanoid = "0.4"
parking_lot = "0.11.1"
prometheus = "0.13"
rand = "0.8"
reqwest = { version = "0.11", features = ["json"], optional = true }
scrypt = "0.7"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
sha-1 = "0.9"
time = { version = "0.3", features = ["serde", "serde-well-known"] }
tokio = { version = "1", features = ["full"] }
tokio-tungstenite = "0.17"
tonic = "0.6"
tower = "0.4"
toml = "0.5.8"
tracing = "0.1.34"
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
[dependencies.sqlx]
version = "0.6"
features = ["runtime-tokio-rustls", "postgres", "time", "uuid"]
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
gpui = { path = "../gpui", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] }
client = { path = "../client", features = ["test-support"] }
editor = { path = "../editor", features = ["test-support"] }
language = { path = "../language", features = ["test-support"] }
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
lsp = { path = "../lsp", features = ["test-support"] }
project = { path = "../project", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] }
theme = { path = "../theme" }
workspace = { path = "../workspace", features = ["test-support"] }
ctor = "0.1"
env_logger = "0.9"
util = { path = "../util" }
lazy_static = "1.4"
serde_json = { version = "1.0", features = ["preserve_order"] }
[features]
seed-support = ["clap", "lipsum", "reqwest"]

View File

@@ -1,2 +1,2 @@
web: ./target/release/zed-server
collab: ./target/release/collab
release: ./target/release/sqlx migrate run

5
crates/collab/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Zed Server
This crate is what we run at https://collab.zed.dev.
It contains our back-end logic for collaboration, to which we connect from the Zed client via a websocket after authenticating via https://zed.dev, which is a separate repo running on Vercel.

View File

@@ -0,0 +1,3 @@
ZED_ENVIRONMENT=production
RUST_LOG=info
INVITE_LINK_PREFIX=https://zed.dev/invites/

View File

@@ -0,0 +1,3 @@
ZED_ENVIRONMENT=staging
RUST_LOG=info
INVITE_LINK_PREFIX=https://staging.zed.dev/invites/

View File

@@ -8,14 +8,14 @@ kind: Service
apiVersion: v1
metadata:
namespace: ${ZED_KUBE_NAMESPACE}
name: zed
name: collab
annotations:
service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443"
service.beta.kubernetes.io/do-loadbalancer-certificate-id: "2634d353-1ab4-437f-add2-4ffd8f315233"
service.beta.kubernetes.io/do-loadbalancer-certificate-id: "40879815-9a6b-4bbb-8207-8f2c7c0218f9"
spec:
type: LoadBalancer
selector:
app: zed
app: collab
ports:
- name: web
protocol: TCP
@@ -26,19 +26,33 @@ apiVersion: apps/v1
kind: Deployment
metadata:
namespace: ${ZED_KUBE_NAMESPACE}
name: zed
name: collab
spec:
replicas: 1
selector:
matchLabels:
app: zed
app: collab
template:
metadata:
labels:
app: zed
app: collab
annotations:
ad.datadoghq.com/collab.check_names: |
["openmetrics"]
ad.datadoghq.com/collab.init_configs: |
[{}]
ad.datadoghq.com/collab.instances: |
[
{
"openmetrics_endpoint": "http://%%host%%:%%port%%/metrics",
"namespace": "collab_${ZED_KUBE_NAMESPACE}",
"metrics": [".*"]
}
]
spec:
containers:
- name: zed
- name: collab
image: "${ZED_IMAGE_ID}"
ports:
- containerPort: 8080
@@ -81,6 +95,19 @@ spec:
secretKeyRef:
name: api
key: token
- name: INVITE_LINK_PREFIX
value: ${INVITE_LINK_PREFIX}
- name: RUST_LOG
value: ${RUST_LOG}
- name: LOG_JSON
value: "true"
- name: HONEYCOMB_DATASET
value: "collab"
- name: HONEYCOMB_API_KEY
valueFrom:
secretKeyRef:
name: honeycomb
key: apiKey
securityContext:
capabilities:
# FIXME - Switch to the more restrictive `PERFMON` capability.

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS "signups";

View File

@@ -0,0 +1,2 @@
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX trigram_index_users_on_github_login ON users USING GIN(github_login gin_trgm_ops);

View File

@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS "contacts" (
"id" SERIAL PRIMARY KEY,
"user_id_a" INTEGER REFERENCES users (id) NOT NULL,
"user_id_b" INTEGER REFERENCES users (id) NOT NULL,
"a_to_b" BOOLEAN NOT NULL,
"should_notify" BOOLEAN NOT NULL,
"accepted" BOOLEAN NOT NULL
);
CREATE UNIQUE INDEX "index_contacts_user_ids" ON "contacts" ("user_id_a", "user_id_b");
CREATE INDEX "index_contacts_user_id_b" ON "contacts" ("user_id_b");

View File

@@ -0,0 +1,9 @@
ALTER TABLE users
ADD email_address VARCHAR(255) DEFAULT NULL,
ADD invite_code VARCHAR(64),
ADD invite_count INTEGER NOT NULL DEFAULT 0,
ADD inviter_id INTEGER REFERENCES users (id),
ADD connected_once BOOLEAN NOT NULL DEFAULT false,
ADD created_at TIMESTAMP NOT NULL DEFAULT NOW();
CREATE UNIQUE INDEX "index_invite_code_users" ON "users" ("invite_code");

View File

@@ -0,0 +1,6 @@
ALTER TABLE contacts DROP CONSTRAINT contacts_user_id_a_fkey;
ALTER TABLE contacts DROP CONSTRAINT contacts_user_id_b_fkey;
ALTER TABLE contacts ADD CONSTRAINT contacts_user_id_a_fkey FOREIGN KEY (user_id_a) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE contacts ADD CONSTRAINT contacts_user_id_b_fkey FOREIGN KEY (user_id_b) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE users DROP CONSTRAINT users_inviter_id_fkey;
ALTER TABLE users ADD CONSTRAINT users_inviter_id_fkey FOREIGN KEY (inviter_id) REFERENCES users(id) ON DELETE SET NULL;

View File

@@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS "projects" (
"id" SERIAL PRIMARY KEY,
"host_user_id" INTEGER REFERENCES users (id) NOT NULL,
"unregistered" BOOLEAN NOT NULL DEFAULT false
);
CREATE TABLE IF NOT EXISTS "worktree_extensions" (
"id" SERIAL PRIMARY KEY,
"project_id" INTEGER REFERENCES projects (id) NOT NULL,
"worktree_id" INTEGER NOT NULL,
"extension" VARCHAR(255),
"count" INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS "project_activity_periods" (
"id" SERIAL PRIMARY KEY,
"duration_millis" INTEGER NOT NULL,
"ended_at" TIMESTAMP NOT NULL,
"user_id" INTEGER REFERENCES users (id) NOT NULL,
"project_id" INTEGER REFERENCES projects (id) NOT NULL
);
CREATE INDEX "index_project_activity_periods_on_ended_at" ON "project_activity_periods" ("ended_at");
CREATE UNIQUE INDEX "index_worktree_extensions_on_project_id_and_worktree_id_and_extension" ON "worktree_extensions" ("project_id", "worktree_id", "extension");

360
crates/collab/src/api.rs Normal file
View File

@@ -0,0 +1,360 @@
use crate::{
auth,
db::{ProjectId, User, UserId},
rpc::{self, ResultExt},
AppState, Error, Result,
};
use anyhow::anyhow;
use axum::{
body::Body,
extract::{Path, Query},
http::{self, Request, StatusCode},
middleware::{self, Next},
response::IntoResponse,
routing::{get, post, put},
Extension, Json, Router,
};
use axum_extra::response::ErasedJson;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::sync::Arc;
use time::OffsetDateTime;
use tower::ServiceBuilder;
use tracing::instrument;
pub fn routes(rpc_server: &Arc<rpc::Server>, state: Arc<AppState>) -> Router<Body> {
Router::new()
.route("/users", get(get_users).post(create_user))
.route(
"/users/:id",
put(update_user).delete(destroy_user).get(get_user),
)
.route("/users/:id/access_tokens", post(create_access_token))
.route("/bulk_users", post(create_users))
.route("/users_with_no_invites", get(get_users_with_no_invites))
.route("/invite_codes/:code", get(get_user_for_invite_code))
.route("/panic", post(trace_panic))
.route("/rpc_server_snapshot", get(get_rpc_server_snapshot))
.route(
"/project_activity_summary",
get(get_project_activity_summary),
)
.route("/project_metadata", get(get_project_metadata))
.layer(
ServiceBuilder::new()
.layer(Extension(state))
.layer(Extension(rpc_server.clone()))
.layer(middleware::from_fn(validate_api_token)),
)
}
pub async fn validate_api_token<B>(req: Request<B>, next: Next<B>) -> impl IntoResponse {
let token = req
.headers()
.get(http::header::AUTHORIZATION)
.and_then(|header| header.to_str().ok())
.ok_or_else(|| {
Error::Http(
StatusCode::BAD_REQUEST,
"missing authorization header".to_string(),
)
})?
.strip_prefix("token ")
.ok_or_else(|| {
Error::Http(
StatusCode::BAD_REQUEST,
"invalid authorization header".to_string(),
)
})?;
let state = req.extensions().get::<Arc<AppState>>().unwrap();
if token != state.api_token {
Err(Error::Http(
StatusCode::UNAUTHORIZED,
"invalid authorization token".to_string(),
))?
}
Ok::<_, Error>(next.run(req).await)
}
#[derive(Debug, Deserialize)]
struct GetUsersQueryParams {
query: Option<String>,
page: Option<u32>,
limit: Option<u32>,
}
async fn get_users(
Query(params): Query<GetUsersQueryParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<Vec<User>>> {
let limit = params.limit.unwrap_or(100);
let users = if let Some(query) = params.query {
app.db.fuzzy_search_users(&query, limit).await?
} else {
app.db
.get_all_users(params.page.unwrap_or(0), limit)
.await?
};
Ok(Json(users))
}
#[derive(Deserialize, Debug)]
struct CreateUserParams {
github_login: String,
invite_code: Option<String>,
email_address: Option<String>,
admin: bool,
}
async fn create_user(
Json(params): Json<CreateUserParams>,
Extension(app): Extension<Arc<AppState>>,
Extension(rpc_server): Extension<Arc<rpc::Server>>,
) -> Result<Json<User>> {
let user_id = if let Some(invite_code) = params.invite_code {
let invitee_id = app
.db
.redeem_invite_code(
&invite_code,
&params.github_login,
params.email_address.as_deref(),
)
.await?;
rpc_server
.invite_code_redeemed(&invite_code, invitee_id)
.await
.trace_err();
invitee_id
} else {
app.db
.create_user(
&params.github_login,
params.email_address.as_deref(),
params.admin,
)
.await?
};
let user = app
.db
.get_user_by_id(user_id)
.await?
.ok_or_else(|| anyhow!("couldn't find the user we just created"))?;
Ok(Json(user))
}
#[derive(Deserialize)]
struct UpdateUserParams {
admin: Option<bool>,
invite_count: Option<u32>,
}
async fn update_user(
Path(user_id): Path<i32>,
Json(params): Json<UpdateUserParams>,
Extension(app): Extension<Arc<AppState>>,
Extension(rpc_server): Extension<Arc<rpc::Server>>,
) -> Result<()> {
let user_id = UserId(user_id);
if let Some(admin) = params.admin {
app.db.set_user_is_admin(user_id, admin).await?;
}
if let Some(invite_count) = params.invite_count {
app.db.set_invite_count(user_id, invite_count).await?;
rpc_server.invite_count_updated(user_id).await.trace_err();
}
Ok(())
}
async fn destroy_user(
Path(user_id): Path<i32>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<()> {
app.db.destroy_user(UserId(user_id)).await?;
Ok(())
}
async fn get_user(
Path(login): Path<String>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<User>> {
let user = app
.db
.get_user_by_github_login(&login)
.await?
.ok_or_else(|| Error::Http(StatusCode::NOT_FOUND, "User not found".to_string()))?;
Ok(Json(user))
}
#[derive(Deserialize)]
struct CreateUsersParams {
users: Vec<CreateUsersEntry>,
}
#[derive(Deserialize)]
struct CreateUsersEntry {
github_login: String,
email_address: String,
invite_count: usize,
}
async fn create_users(
Json(params): Json<CreateUsersParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<Vec<User>>> {
let user_ids = app
.db
.create_users(
params
.users
.into_iter()
.map(|params| {
(
params.github_login,
params.email_address,
params.invite_count,
)
})
.collect(),
)
.await?;
let users = app.db.get_users_by_ids(user_ids).await?;
Ok(Json(users))
}
#[derive(Debug, Deserialize)]
struct GetUsersWithNoInvites {
invited_by_another_user: bool,
}
async fn get_users_with_no_invites(
Query(params): Query<GetUsersWithNoInvites>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<Vec<User>>> {
Ok(Json(
app.db
.get_users_with_no_invites(params.invited_by_another_user)
.await?,
))
}
#[derive(Debug, Deserialize)]
struct Panic {
version: String,
text: String,
}
#[instrument(skip(panic))]
async fn trace_panic(panic: Json<Panic>) -> Result<()> {
tracing::error!(version = %panic.version, text = %panic.text, "panic report");
Ok(())
}
async fn get_rpc_server_snapshot(
Extension(rpc_server): Extension<Arc<rpc::Server>>,
) -> Result<ErasedJson> {
Ok(ErasedJson::pretty(rpc_server.snapshot().await))
}
#[derive(Deserialize)]
struct GetProjectActivityParams {
#[serde(with = "time::serde::iso8601")]
start: OffsetDateTime,
#[serde(with = "time::serde::iso8601")]
end: OffsetDateTime,
}
async fn get_project_activity_summary(
Query(params): Query<GetProjectActivityParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<ErasedJson> {
let summary = app
.db
.summarize_project_activity(params.start..params.end, 100)
.await?;
Ok(ErasedJson::pretty(summary))
}
#[derive(Deserialize)]
struct GetProjectMetadataParams {
project_id: u64,
}
async fn get_project_metadata(
Query(params): Query<GetProjectMetadataParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<ErasedJson> {
let extensions = app
.db
.get_project_extensions(ProjectId::from_proto(params.project_id))
.await?;
Ok(ErasedJson::pretty(json!({ "extensions": extensions })))
}
#[derive(Deserialize)]
struct CreateAccessTokenQueryParams {
public_key: String,
impersonate: Option<String>,
}
#[derive(Serialize)]
struct CreateAccessTokenResponse {
user_id: UserId,
encrypted_access_token: String,
}
async fn create_access_token(
Path(login): Path<String>,
Query(params): Query<CreateAccessTokenQueryParams>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<CreateAccessTokenResponse>> {
// request.require_token().await?;
let user = app
.db
.get_user_by_github_login(&login)
.await?
.ok_or_else(|| anyhow!("user not found"))?;
let mut user_id = user.id;
if let Some(impersonate) = params.impersonate {
if user.admin {
if let Some(impersonated_user) = app.db.get_user_by_github_login(&impersonate).await? {
user_id = impersonated_user.id;
} else {
return Err(Error::Http(
StatusCode::UNPROCESSABLE_ENTITY,
format!("user {impersonate} does not exist"),
));
}
} else {
return Err(Error::Http(
StatusCode::UNAUTHORIZED,
format!("you do not have permission to impersonate other users"),
));
}
}
let access_token = auth::create_access_token(app.db.as_ref(), user_id).await?;
let encrypted_access_token =
auth::encrypt_access_token(&access_token, params.public_key.clone())?;
Ok(Json(CreateAccessTokenResponse {
user_id,
encrypted_access_token,
}))
}
async fn get_user_for_invite_code(
Path(code): Path<String>,
Extension(app): Extension<Arc<AppState>>,
) -> Result<Json<User>> {
Ok(Json(app.db.get_user_for_invite_code(&code).await?))
}

111
crates/collab/src/auth.rs Normal file
View File

@@ -0,0 +1,111 @@
use std::sync::Arc;
use super::db::{self, UserId};
use crate::{AppState, Error, Result};
use anyhow::{anyhow, Context};
use axum::{
http::{self, Request, StatusCode},
middleware::Next,
response::IntoResponse,
};
use rand::thread_rng;
use scrypt::{
password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
Scrypt,
};
pub async fn validate_header<B>(mut req: Request<B>, next: Next<B>) -> impl IntoResponse {
let mut auth_header = req
.headers()
.get(http::header::AUTHORIZATION)
.and_then(|header| header.to_str().ok())
.ok_or_else(|| {
Error::Http(
StatusCode::BAD_REQUEST,
"missing authorization header".to_string(),
)
})?
.split_whitespace();
let user_id = UserId(auth_header.next().unwrap_or("").parse().map_err(|_| {
Error::Http(
StatusCode::BAD_REQUEST,
"missing user id in authorization header".to_string(),
)
})?);
let access_token = auth_header.next().ok_or_else(|| {
Error::Http(
StatusCode::BAD_REQUEST,
"missing access token in authorization header".to_string(),
)
})?;
let state = req.extensions().get::<Arc<AppState>>().unwrap();
let mut credentials_valid = false;
for password_hash in state.db.get_access_token_hashes(user_id).await? {
if verify_access_token(&access_token, &password_hash)? {
credentials_valid = true;
break;
}
}
if credentials_valid {
let user = state
.db
.get_user_by_id(user_id)
.await?
.ok_or_else(|| anyhow!("user {} not found", user_id))?;
req.extensions_mut().insert(user);
Ok::<_, Error>(next.run(req).await)
} else {
Err(Error::Http(
StatusCode::UNAUTHORIZED,
"invalid credentials".to_string(),
))
}
}
const MAX_ACCESS_TOKENS_TO_STORE: usize = 8;
pub async fn create_access_token(db: &dyn db::Db, user_id: UserId) -> Result<String> {
let access_token = rpc::auth::random_token();
let access_token_hash =
hash_access_token(&access_token).context("failed to hash access token")?;
db.create_access_token_hash(user_id, &access_token_hash, MAX_ACCESS_TOKENS_TO_STORE)
.await?;
Ok(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::recommended()
};
Ok(Scrypt
.hash_password(
token.as_bytes(),
None,
params,
&SaltString::generate(thread_rng()),
)
.map_err(anyhow::Error::new)?
.to_string())
}
pub fn encrypt_access_token(access_token: &str, public_key: String) -> Result<String> {
let native_app_public_key =
rpc::auth::PublicKey::try_from(public_key).context("failed to parse app public key")?;
let encrypted_access_token = native_app_public_key
.encrypt_string(&access_token)
.context("failed to encrypt access token with public key")?;
Ok(encrypted_access_token)
}
pub fn verify_access_token(token: &str, hash: &str) -> Result<bool> {
let hash = PasswordHash::new(hash).map_err(anyhow::Error::new)?;
Ok(Scrypt.verify_password(token.as_bytes(), &hash).is_ok())
}

View File

@@ -1,31 +1,88 @@
use db::{Db, UserId};
use clap::Parser;
use collab::{Error, Result};
use db::{Db, PostgresDb, UserId};
use rand::prelude::*;
use serde::Deserialize;
use std::fmt::Write;
use time::{Duration, OffsetDateTime};
#[allow(unused)]
#[path = "../db.rs"]
mod db;
#[async_std::main]
#[derive(Parser)]
struct Args {
/// Seed users from GitHub.
#[clap(short, long)]
github_users: bool,
}
#[derive(Debug, Deserialize)]
struct GitHubUser {
id: usize,
login: String,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
let mut rng = StdRng::from_entropy();
let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var");
let db = Db::new(&database_url, 5)
let db = PostgresDb::new(&database_url, 5)
.await
.expect("failed to connect to postgres database");
let zed_users = ["nathansobo", "maxbrunsfeld", "as-cii", "iamnbutler"];
let mut zed_users = vec![
("nathansobo".to_string(), Some("nathan@zed.dev")),
("maxbrunsfeld".to_string(), Some("max@zed.dev")),
("as-cii".to_string(), Some("antonio@zed.dev")),
("iamnbutler".to_string(), Some("nate@zed.dev")),
("gibusu".to_string(), Some("greg@zed.dev")),
("Kethku".to_string(), Some("keith@zed.dev")),
];
if args.github_users {
let github_token = std::env::var("GITHUB_TOKEN").expect("missing GITHUB_TOKEN env var");
let client = reqwest::Client::new();
let mut last_user_id = None;
for page in 0..20 {
println!("Downloading users from GitHub, page {}", page);
let mut uri = "https://api.github.com/users?per_page=100".to_string();
if let Some(last_user_id) = last_user_id {
write!(&mut uri, "&since={}", last_user_id).unwrap();
}
let response = client
.get(uri)
.bearer_auth(&github_token)
.header("user-agent", "zed")
.send()
.await
.expect("failed to fetch github users");
let users = response
.json::<Vec<GitHubUser>>()
.await
.expect("failed to deserialize github user");
zed_users.extend(users.iter().map(|user| (user.login.clone(), None)));
if let Some(last_user) = users.last() {
last_user_id = Some(last_user.id);
} else {
break;
}
}
}
let mut zed_user_ids = Vec::<UserId>::new();
for zed_user in zed_users {
for (zed_user, email) in zed_users {
if let Some(user) = db
.get_user_by_github_login(zed_user)
.get_user_by_github_login(&zed_user)
.await
.expect("failed to fetch user")
{
zed_user_ids.push(user.id);
} else {
zed_user_ids.push(
db.create_user(zed_user, true)
db.create_user(&zed_user, email, true)
.await
.expect("failed to insert user"),
);

2657
crates/collab/src/db.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
// Allow tide Results to accept context like other Results do when
// using anyhow.
pub trait TideResultExt {
fn context<C>(self, cx: C) -> Self
where
C: std::fmt::Display + Send + Sync + 'static;
fn with_context<C, F>(self, f: F) -> Self
where
C: std::fmt::Display + Send + Sync + 'static,
F: FnOnce() -> C;
}
impl<T> TideResultExt for tide::Result<T> {
fn context<C>(self, cx: C) -> Self
where
C: std::fmt::Display + Send + Sync + 'static,
{
self.map_err(|e| tide::Error::new(e.status(), e.into_inner().context(cx)))
}
fn with_context<C, F>(self, f: F) -> Self
where
C: std::fmt::Display + Send + Sync + 'static,
F: FnOnce() -> C,
{
self.map_err(|e| tide::Error::new(e.status(), e.into_inner().context(f())))
}
}

File diff suppressed because it is too large Load Diff

69
crates/collab/src/lib.rs Normal file
View File

@@ -0,0 +1,69 @@
use axum::{http::StatusCode, response::IntoResponse};
pub type Result<T, E = Error> = std::result::Result<T, E>;
pub enum Error {
Http(StatusCode, String),
Internal(anyhow::Error),
}
impl From<anyhow::Error> for Error {
fn from(error: anyhow::Error) -> Self {
Self::Internal(error)
}
}
impl From<sqlx::Error> for Error {
fn from(error: sqlx::Error) -> Self {
Self::Internal(error.into())
}
}
impl From<axum::Error> for Error {
fn from(error: axum::Error) -> Self {
Self::Internal(error.into())
}
}
impl From<hyper::Error> for Error {
fn from(error: hyper::Error) -> Self {
Self::Internal(error.into())
}
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Self::Internal(error.into())
}
}
impl IntoResponse for Error {
fn into_response(self) -> axum::response::Response {
match self {
Error::Http(code, message) => (code, message).into_response(),
Error::Internal(error) => {
(StatusCode::INTERNAL_SERVER_ERROR, format!("{}", &error)).into_response()
}
}
}
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Http(code, message) => (code, message).fmt(f),
Error::Internal(error) => error.fmt(f),
}
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Http(code, message) => write!(f, "{code}: {message}"),
Error::Internal(error) => error.fmt(f),
}
}
}
impl std::error::Error for Error {}

113
crates/collab/src/main.rs Normal file
View File

@@ -0,0 +1,113 @@
mod api;
mod auth;
mod db;
mod env;
mod rpc;
#[cfg(test)]
mod integration_tests;
use axum::{body::Body, Router};
use collab::{Error, Result};
use db::{Db, PostgresDb};
use serde::Deserialize;
use std::{
net::{SocketAddr, TcpListener},
sync::Arc,
time::Duration,
};
use tracing_log::LogTracer;
use tracing_subscriber::{filter::EnvFilter, fmt::format::JsonFields, Layer};
use util::ResultExt;
#[derive(Default, Deserialize)]
pub struct Config {
pub http_port: u16,
pub database_url: String,
pub api_token: String,
pub invite_link_prefix: String,
pub honeycomb_api_key: Option<String>,
pub honeycomb_dataset: Option<String>,
pub rust_log: Option<String>,
pub log_json: Option<bool>,
}
pub struct AppState {
db: Arc<dyn Db>,
api_token: String,
invite_link_prefix: String,
}
impl AppState {
async fn new(config: &Config) -> Result<Arc<Self>> {
let db = PostgresDb::new(&config.database_url, 5).await?;
let this = Self {
db: Arc::new(db),
api_token: config.api_token.clone(),
invite_link_prefix: config.invite_link_prefix.clone(),
};
Ok(Arc::new(this))
}
}
#[tokio::main]
async fn main() -> Result<()> {
if let Err(error) = env::load_dotenv() {
eprintln!(
"error loading .env.toml (this is expected in production): {}",
error
);
}
let config = envy::from_env::<Config>().expect("error loading config");
init_tracing(&config);
let state = AppState::new(&config).await?;
let listener = TcpListener::bind(&format!("0.0.0.0:{}", config.http_port))
.expect("failed to bind TCP listener");
let rpc_server = rpc::Server::new(state.clone(), None);
rpc_server.start_recording_project_activity(Duration::from_secs(5 * 60), rpc::RealExecutor);
let app = Router::<Body>::new()
.merge(api::routes(&rpc_server, state.clone()))
.merge(rpc::routes(rpc_server));
axum::Server::from_tcp(listener)?
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
.await?;
Ok(())
}
pub fn init_tracing(config: &Config) -> Option<()> {
use std::str::FromStr;
use tracing_subscriber::layer::SubscriberExt;
let rust_log = config.rust_log.clone()?;
LogTracer::init().log_err()?;
let subscriber = tracing_subscriber::Registry::default()
.with(if config.log_json.unwrap_or(false) {
Box::new(
tracing_subscriber::fmt::layer()
.fmt_fields(JsonFields::default())
.event_format(
tracing_subscriber::fmt::format()
.json()
.flatten_event(true)
.with_span_list(true),
),
) as Box<dyn Layer<_> + Send + Sync>
} else {
Box::new(
tracing_subscriber::fmt::layer()
.event_format(tracing_subscriber::fmt::format().pretty()),
)
})
.with(EnvFilter::from_str(rust_log.as_str()).log_err()?);
tracing::subscriber::set_global_default(subscriber).unwrap();
None
}

1857
crates/collab/src/rpc.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,860 @@
use crate::db::{self, ChannelId, ProjectId, UserId};
use anyhow::{anyhow, Result};
use collections::{btree_map, hash_map::Entry, BTreeMap, BTreeSet, HashMap, HashSet};
use rpc::{proto, ConnectionId, Receipt};
use serde::Serialize;
use std::{
mem,
path::{Path, PathBuf},
str,
time::Duration,
};
use time::OffsetDateTime;
use tracing::instrument;
#[derive(Default, Serialize)]
pub struct Store {
connections: BTreeMap<ConnectionId, ConnectionState>,
connections_by_user_id: BTreeMap<UserId, HashSet<ConnectionId>>,
projects: BTreeMap<ProjectId, Project>,
#[serde(skip)]
channels: BTreeMap<ChannelId, Channel>,
}
#[derive(Serialize)]
struct ConnectionState {
user_id: UserId,
admin: bool,
projects: BTreeSet<ProjectId>,
requested_projects: HashSet<ProjectId>,
channels: HashSet<ChannelId>,
}
#[derive(Serialize)]
pub struct Project {
pub host_connection_id: ConnectionId,
pub host: Collaborator,
pub guests: HashMap<ConnectionId, Collaborator>,
#[serde(skip)]
pub join_requests: HashMap<UserId, Vec<Receipt<proto::JoinProject>>>,
pub active_replica_ids: HashSet<ReplicaId>,
pub worktrees: BTreeMap<u64, Worktree>,
pub language_servers: Vec<proto::LanguageServer>,
}
#[derive(Serialize)]
pub struct Collaborator {
pub replica_id: ReplicaId,
pub user_id: UserId,
#[serde(skip)]
pub last_activity: Option<OffsetDateTime>,
pub admin: bool,
}
#[derive(Default, Serialize)]
pub struct Worktree {
pub root_name: String,
pub visible: bool,
#[serde(skip)]
pub entries: BTreeMap<u64, proto::Entry>,
#[serde(skip)]
pub extension_counts: HashMap<String, usize>,
#[serde(skip)]
pub diagnostic_summaries: BTreeMap<PathBuf, proto::DiagnosticSummary>,
pub scan_id: u64,
}
#[derive(Default)]
pub struct Channel {
pub connection_ids: HashSet<ConnectionId>,
}
pub type ReplicaId = u16;
#[derive(Default)]
pub struct RemovedConnectionState {
pub user_id: UserId,
pub hosted_projects: HashMap<ProjectId, Project>,
pub guest_project_ids: HashSet<ProjectId>,
pub contact_ids: HashSet<UserId>,
}
pub struct LeftProject {
pub host_user_id: UserId,
pub host_connection_id: ConnectionId,
pub connection_ids: Vec<ConnectionId>,
pub remove_collaborator: bool,
pub cancel_request: Option<UserId>,
pub unshare: bool,
}
#[derive(Copy, Clone)]
pub struct Metrics {
pub connections: usize,
pub registered_projects: usize,
pub active_projects: usize,
pub shared_projects: usize,
}
impl Store {
pub fn metrics(&self) -> Metrics {
const ACTIVE_PROJECT_TIMEOUT: Duration = Duration::from_secs(60);
let active_window_start = OffsetDateTime::now_utc() - ACTIVE_PROJECT_TIMEOUT;
let connections = self.connections.values().filter(|c| !c.admin).count();
let mut registered_projects = 0;
let mut active_projects = 0;
let mut shared_projects = 0;
for project in self.projects.values() {
if let Some(connection) = self.connections.get(&project.host_connection_id) {
if !connection.admin {
registered_projects += 1;
if project.is_active_since(active_window_start) {
active_projects += 1;
if !project.guests.is_empty() {
shared_projects += 1;
}
}
}
}
}
Metrics {
connections,
registered_projects,
active_projects,
shared_projects,
}
}
#[instrument(skip(self))]
pub fn add_connection(&mut self, connection_id: ConnectionId, user_id: UserId, admin: bool) {
self.connections.insert(
connection_id,
ConnectionState {
user_id,
admin,
projects: Default::default(),
requested_projects: Default::default(),
channels: Default::default(),
},
);
self.connections_by_user_id
.entry(user_id)
.or_default()
.insert(connection_id);
}
#[instrument(skip(self))]
pub fn remove_connection(
&mut self,
connection_id: ConnectionId,
) -> Result<RemovedConnectionState> {
let connection = self
.connections
.get_mut(&connection_id)
.ok_or_else(|| anyhow!("no such connection"))?;
let user_id = connection.user_id;
let connection_projects = mem::take(&mut connection.projects);
let connection_channels = mem::take(&mut connection.channels);
let mut result = RemovedConnectionState::default();
result.user_id = user_id;
// Leave all channels.
for channel_id in connection_channels {
self.leave_channel(connection_id, channel_id);
}
// Unregister and leave all projects.
for project_id in connection_projects {
if let Ok(project) = self.unregister_project(project_id, connection_id) {
result.hosted_projects.insert(project_id, project);
} else if self.leave_project(connection_id, project_id).is_ok() {
result.guest_project_ids.insert(project_id);
}
}
let user_connections = self.connections_by_user_id.get_mut(&user_id).unwrap();
user_connections.remove(&connection_id);
if user_connections.is_empty() {
self.connections_by_user_id.remove(&user_id);
}
self.connections.remove(&connection_id).unwrap();
Ok(result)
}
#[cfg(test)]
pub fn channel(&self, id: ChannelId) -> Option<&Channel> {
self.channels.get(&id)
}
pub fn join_channel(&mut self, connection_id: ConnectionId, channel_id: ChannelId) {
if let Some(connection) = self.connections.get_mut(&connection_id) {
connection.channels.insert(channel_id);
self.channels
.entry(channel_id)
.or_default()
.connection_ids
.insert(connection_id);
}
}
pub fn leave_channel(&mut self, connection_id: ConnectionId, channel_id: ChannelId) {
if let Some(connection) = self.connections.get_mut(&connection_id) {
connection.channels.remove(&channel_id);
if let btree_map::Entry::Occupied(mut entry) = self.channels.entry(channel_id) {
entry.get_mut().connection_ids.remove(&connection_id);
if entry.get_mut().connection_ids.is_empty() {
entry.remove();
}
}
}
}
pub fn user_id_for_connection(&self, connection_id: ConnectionId) -> Result<UserId> {
Ok(self
.connections
.get(&connection_id)
.ok_or_else(|| anyhow!("unknown connection"))?
.user_id)
}
pub fn connection_ids_for_user<'a>(
&'a self,
user_id: UserId,
) -> impl 'a + Iterator<Item = ConnectionId> {
self.connections_by_user_id
.get(&user_id)
.into_iter()
.flatten()
.copied()
}
pub fn is_user_online(&self, user_id: UserId) -> bool {
!self
.connections_by_user_id
.get(&user_id)
.unwrap_or(&Default::default())
.is_empty()
}
pub fn build_initial_contacts_update(
&self,
contacts: Vec<db::Contact>,
) -> proto::UpdateContacts {
let mut update = proto::UpdateContacts::default();
for contact in contacts {
match contact {
db::Contact::Accepted {
user_id,
should_notify,
} => {
update
.contacts
.push(self.contact_for_user(user_id, should_notify));
}
db::Contact::Outgoing { user_id } => {
update.outgoing_requests.push(user_id.to_proto())
}
db::Contact::Incoming {
user_id,
should_notify,
} => update
.incoming_requests
.push(proto::IncomingContactRequest {
requester_id: user_id.to_proto(),
should_notify,
}),
}
}
update
}
pub fn contact_for_user(&self, user_id: UserId, should_notify: bool) -> proto::Contact {
proto::Contact {
user_id: user_id.to_proto(),
projects: self.project_metadata_for_user(user_id),
online: self.is_user_online(user_id),
should_notify,
}
}
pub fn project_metadata_for_user(&self, user_id: UserId) -> Vec<proto::ProjectMetadata> {
let connection_ids = self.connections_by_user_id.get(&user_id);
let project_ids = connection_ids.iter().flat_map(|connection_ids| {
connection_ids
.iter()
.filter_map(|connection_id| self.connections.get(connection_id))
.flat_map(|connection| connection.projects.iter().copied())
});
let mut metadata = Vec::new();
for project_id in project_ids {
if let Some(project) = self.projects.get(&project_id) {
if project.host.user_id == user_id {
metadata.push(proto::ProjectMetadata {
id: project_id.to_proto(),
visible_worktree_root_names: project
.worktrees
.values()
.filter(|worktree| worktree.visible)
.map(|worktree| worktree.root_name.clone())
.collect(),
guests: project
.guests
.values()
.map(|guest| guest.user_id.to_proto())
.collect(),
});
}
}
}
metadata
}
pub fn register_project(
&mut self,
host_connection_id: ConnectionId,
project_id: ProjectId,
) -> Result<()> {
let connection = self
.connections
.get_mut(&host_connection_id)
.ok_or_else(|| anyhow!("no such connection"))?;
connection.projects.insert(project_id);
self.projects.insert(
project_id,
Project {
host_connection_id,
host: Collaborator {
user_id: connection.user_id,
replica_id: 0,
last_activity: None,
admin: connection.admin,
},
guests: Default::default(),
join_requests: Default::default(),
active_replica_ids: Default::default(),
worktrees: Default::default(),
language_servers: Default::default(),
},
);
Ok(())
}
pub fn update_project(
&mut self,
project_id: ProjectId,
worktrees: &[proto::WorktreeMetadata],
connection_id: ConnectionId,
) -> Result<()> {
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id {
let mut old_worktrees = mem::take(&mut project.worktrees);
for worktree in worktrees {
if let Some(old_worktree) = old_worktrees.remove(&worktree.id) {
project.worktrees.insert(worktree.id, old_worktree);
} else {
project.worktrees.insert(
worktree.id,
Worktree {
root_name: worktree.root_name.clone(),
visible: worktree.visible,
..Default::default()
},
);
}
}
Ok(())
} else {
Err(anyhow!("no such project"))?
}
}
pub fn unregister_project(
&mut self,
project_id: ProjectId,
connection_id: ConnectionId,
) -> Result<Project> {
match self.projects.entry(project_id) {
btree_map::Entry::Occupied(e) => {
if e.get().host_connection_id == connection_id {
let project = e.remove();
if let Some(host_connection) = self.connections.get_mut(&connection_id) {
host_connection.projects.remove(&project_id);
}
for guest_connection in project.guests.keys() {
if let Some(connection) = self.connections.get_mut(&guest_connection) {
connection.projects.remove(&project_id);
}
}
for requester_user_id in project.join_requests.keys() {
if let Some(requester_connection_ids) =
self.connections_by_user_id.get_mut(&requester_user_id)
{
for requester_connection_id in requester_connection_ids.iter() {
if let Some(requester_connection) =
self.connections.get_mut(requester_connection_id)
{
requester_connection.requested_projects.remove(&project_id);
}
}
}
}
Ok(project)
} else {
Err(anyhow!("no such project"))?
}
}
btree_map::Entry::Vacant(_) => Err(anyhow!("no such project"))?,
}
}
pub fn update_diagnostic_summary(
&mut self,
project_id: ProjectId,
worktree_id: u64,
connection_id: ConnectionId,
summary: proto::DiagnosticSummary,
) -> Result<Vec<ConnectionId>> {
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id {
let worktree = project
.worktrees
.get_mut(&worktree_id)
.ok_or_else(|| anyhow!("no such worktree"))?;
worktree
.diagnostic_summaries
.insert(summary.path.clone().into(), summary);
return Ok(project.connection_ids());
}
Err(anyhow!("no such worktree"))?
}
pub fn start_language_server(
&mut self,
project_id: ProjectId,
connection_id: ConnectionId,
language_server: proto::LanguageServer,
) -> Result<Vec<ConnectionId>> {
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id {
project.language_servers.push(language_server);
return Ok(project.connection_ids());
}
Err(anyhow!("no such project"))?
}
pub fn request_join_project(
&mut self,
requester_id: UserId,
project_id: ProjectId,
receipt: Receipt<proto::JoinProject>,
) -> Result<()> {
let connection = self
.connections
.get_mut(&receipt.sender_id)
.ok_or_else(|| anyhow!("no such connection"))?;
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
connection.requested_projects.insert(project_id);
project
.join_requests
.entry(requester_id)
.or_default()
.push(receipt);
Ok(())
}
pub fn deny_join_project_request(
&mut self,
responder_connection_id: ConnectionId,
requester_id: UserId,
project_id: ProjectId,
) -> Option<Vec<Receipt<proto::JoinProject>>> {
let project = self.projects.get_mut(&project_id)?;
if responder_connection_id != project.host_connection_id {
return None;
}
let receipts = project.join_requests.remove(&requester_id)?;
for receipt in &receipts {
let requester_connection = self.connections.get_mut(&receipt.sender_id)?;
requester_connection.requested_projects.remove(&project_id);
}
project.host.last_activity = Some(OffsetDateTime::now_utc());
Some(receipts)
}
pub fn accept_join_project_request(
&mut self,
responder_connection_id: ConnectionId,
requester_id: UserId,
project_id: ProjectId,
) -> Option<(Vec<(Receipt<proto::JoinProject>, ReplicaId)>, &Project)> {
let project = self.projects.get_mut(&project_id)?;
if responder_connection_id != project.host_connection_id {
return None;
}
let receipts = project.join_requests.remove(&requester_id)?;
let mut receipts_with_replica_ids = Vec::new();
for receipt in receipts {
let requester_connection = self.connections.get_mut(&receipt.sender_id)?;
requester_connection.requested_projects.remove(&project_id);
requester_connection.projects.insert(project_id);
let mut replica_id = 1;
while project.active_replica_ids.contains(&replica_id) {
replica_id += 1;
}
project.active_replica_ids.insert(replica_id);
project.guests.insert(
receipt.sender_id,
Collaborator {
replica_id,
user_id: requester_id,
last_activity: Some(OffsetDateTime::now_utc()),
admin: requester_connection.admin,
},
);
receipts_with_replica_ids.push((receipt, replica_id));
}
project.host.last_activity = Some(OffsetDateTime::now_utc());
Some((receipts_with_replica_ids, project))
}
pub fn leave_project(
&mut self,
connection_id: ConnectionId,
project_id: ProjectId,
) -> Result<LeftProject> {
let user_id = self.user_id_for_connection(connection_id)?;
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
// If the connection leaving the project is a collaborator, remove it.
let remove_collaborator = if let Some(guest) = project.guests.remove(&connection_id) {
project.active_replica_ids.remove(&guest.replica_id);
true
} else {
false
};
// If the connection leaving the project has a pending request, remove it.
// If that user has no other pending requests on other connections, indicate that the request should be cancelled.
let mut cancel_request = None;
if let Entry::Occupied(mut entry) = project.join_requests.entry(user_id) {
entry
.get_mut()
.retain(|receipt| receipt.sender_id != connection_id);
if entry.get().is_empty() {
entry.remove();
cancel_request = Some(user_id);
}
}
if let Some(connection) = self.connections.get_mut(&connection_id) {
connection.projects.remove(&project_id);
}
let connection_ids = project.connection_ids();
let unshare = connection_ids.len() <= 1 && project.join_requests.is_empty();
if unshare {
project.language_servers.clear();
for worktree in project.worktrees.values_mut() {
worktree.diagnostic_summaries.clear();
worktree.entries.clear();
worktree.extension_counts.clear();
}
}
Ok(LeftProject {
host_connection_id: project.host_connection_id,
host_user_id: project.host.user_id,
connection_ids,
cancel_request,
unshare,
remove_collaborator,
})
}
pub fn update_worktree(
&mut self,
connection_id: ConnectionId,
project_id: ProjectId,
worktree_id: u64,
worktree_root_name: &str,
removed_entries: &[u64],
updated_entries: &[proto::Entry],
scan_id: u64,
) -> Result<(Vec<ConnectionId>, bool, HashMap<String, usize>)> {
let project = self.write_project(project_id, connection_id)?;
let connection_ids = project.connection_ids();
let mut worktree = project.worktrees.entry(worktree_id).or_default();
let metadata_changed = worktree_root_name != worktree.root_name;
worktree.root_name = worktree_root_name.to_string();
for entry_id in removed_entries {
if let Some(entry) = worktree.entries.remove(&entry_id) {
if !entry.is_ignored {
if let Some(extension) = extension_for_entry(&entry) {
if let Some(count) = worktree.extension_counts.get_mut(extension) {
*count = count.saturating_sub(1);
}
}
}
}
}
for entry in updated_entries {
if let Some(old_entry) = worktree.entries.insert(entry.id, entry.clone()) {
if !old_entry.is_ignored {
if let Some(extension) = extension_for_entry(&old_entry) {
if let Some(count) = worktree.extension_counts.get_mut(extension) {
*count = count.saturating_sub(1);
}
}
}
}
if !entry.is_ignored {
if let Some(extension) = extension_for_entry(&entry) {
if let Some(count) = worktree.extension_counts.get_mut(extension) {
*count += 1;
} else {
worktree.extension_counts.insert(extension.into(), 1);
}
}
}
}
worktree.scan_id = scan_id;
Ok((
connection_ids,
metadata_changed,
worktree.extension_counts.clone(),
))
}
pub fn project_connection_ids(
&self,
project_id: ProjectId,
acting_connection_id: ConnectionId,
) -> Result<Vec<ConnectionId>> {
Ok(self
.read_project(project_id, acting_connection_id)?
.connection_ids())
}
pub fn channel_connection_ids(&self, channel_id: ChannelId) -> Result<Vec<ConnectionId>> {
Ok(self
.channels
.get(&channel_id)
.ok_or_else(|| anyhow!("no such channel"))?
.connection_ids())
}
pub fn project(&self, project_id: ProjectId) -> Result<&Project> {
self.projects
.get(&project_id)
.ok_or_else(|| anyhow!("no such project"))
}
pub fn register_project_activity(
&mut self,
project_id: ProjectId,
connection_id: ConnectionId,
) -> Result<()> {
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
let collaborator = if connection_id == project.host_connection_id {
&mut project.host
} else if let Some(guest) = project.guests.get_mut(&connection_id) {
guest
} else {
return Err(anyhow!("no such project"))?;
};
collaborator.last_activity = Some(OffsetDateTime::now_utc());
Ok(())
}
pub fn projects(&self) -> impl Iterator<Item = (&ProjectId, &Project)> {
self.projects.iter()
}
pub fn read_project(
&self,
project_id: ProjectId,
connection_id: ConnectionId,
) -> Result<&Project> {
let project = self
.projects
.get(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id
|| project.guests.contains_key(&connection_id)
{
Ok(project)
} else {
Err(anyhow!("no such project"))?
}
}
fn write_project(
&mut self,
project_id: ProjectId,
connection_id: ConnectionId,
) -> Result<&mut Project> {
let project = self
.projects
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id
|| project.guests.contains_key(&connection_id)
{
Ok(project)
} else {
Err(anyhow!("no such project"))?
}
}
#[cfg(test)]
pub fn check_invariants(&self) {
for (connection_id, connection) in &self.connections {
for project_id in &connection.projects {
let project = &self.projects.get(&project_id).unwrap();
if project.host_connection_id != *connection_id {
assert!(project.guests.contains_key(connection_id));
}
for (worktree_id, worktree) in project.worktrees.iter() {
let mut paths = HashMap::default();
for entry in worktree.entries.values() {
let prev_entry = paths.insert(&entry.path, entry);
assert_eq!(
prev_entry,
None,
"worktree {:?}, duplicate path for entries {:?} and {:?}",
worktree_id,
prev_entry.unwrap(),
entry
);
}
}
}
for channel_id in &connection.channels {
let channel = self.channels.get(channel_id).unwrap();
assert!(channel.connection_ids.contains(connection_id));
}
assert!(self
.connections_by_user_id
.get(&connection.user_id)
.unwrap()
.contains(connection_id));
}
for (user_id, connection_ids) in &self.connections_by_user_id {
for connection_id in connection_ids {
assert_eq!(
self.connections.get(connection_id).unwrap().user_id,
*user_id
);
}
}
for (project_id, project) in &self.projects {
let host_connection = self.connections.get(&project.host_connection_id).unwrap();
assert!(host_connection.projects.contains(project_id));
for guest_connection_id in project.guests.keys() {
let guest_connection = self.connections.get(guest_connection_id).unwrap();
assert!(guest_connection.projects.contains(project_id));
}
assert_eq!(project.active_replica_ids.len(), project.guests.len(),);
assert_eq!(
project.active_replica_ids,
project
.guests
.values()
.map(|guest| guest.replica_id)
.collect::<HashSet<_>>(),
);
}
for (channel_id, channel) in &self.channels {
for connection_id in &channel.connection_ids {
let connection = self.connections.get(connection_id).unwrap();
assert!(connection.channels.contains(channel_id));
}
}
}
}
impl Project {
fn is_active_since(&self, start_time: OffsetDateTime) -> bool {
self.guests
.values()
.chain([&self.host])
.any(|collaborator| {
collaborator
.last_activity
.map_or(false, |active_time| active_time > start_time)
})
}
pub fn guest_connection_ids(&self) -> Vec<ConnectionId> {
self.guests.keys().copied().collect()
}
pub fn connection_ids(&self) -> Vec<ConnectionId> {
self.guests
.keys()
.copied()
.chain(Some(self.host_connection_id))
.collect()
}
}
impl Channel {
fn connection_ids(&self) -> Vec<ConnectionId> {
self.connection_ids.iter().copied().collect()
}
}
fn extension_for_entry(entry: &proto::Entry) -> Option<&str> {
str::from_utf8(&entry.path)
.ok()
.map(Path::new)
.and_then(|p| p.extension())
.and_then(|e| e.to_str())
}

View File

@@ -5,6 +5,7 @@ edition = "2021"
[lib]
path = "src/collections.rs"
doctest = false
[features]
test-support = ["seahash"]

View File

@@ -0,0 +1,29 @@
[package]
name = "command_palette"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/command_palette.rs"
doctest = false
[dependencies]
collections = { path = "../collections" }
editor = { path = "../editor" }
fuzzy = { path = "../fuzzy" }
gpui = { path = "../gpui" }
picker = { path = "../picker" }
project = { path = "../project" }
settings = { path = "../settings" }
util = { path = "../util" }
theme = { path = "../theme" }
workspace = { path = "../workspace" }
[dev-dependencies]
gpui = { path = "../gpui", features = ["test-support"] }
editor = { path = "../editor", features = ["test-support"] }
project = { path = "../project", features = ["test-support"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
workspace = { path = "../workspace", features = ["test-support"] }
ctor = "0.1"
env_logger = "0.9"

View File

@@ -0,0 +1,417 @@
use collections::HashSet;
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
actions,
elements::{ChildView, Flex, Label, ParentElement},
keymap::Keystroke,
Action, Element, Entity, MouseState, MutableAppContext, View, ViewContext, ViewHandle,
};
use picker::{Picker, PickerDelegate};
use settings::Settings;
use std::cmp;
use workspace::Workspace;
#[derive(Default)]
pub struct CommandPaletteFilter {
pub filtered_namespaces: HashSet<&'static str>,
}
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(CommandPalette::toggle);
Picker::<CommandPalette>::init(cx);
}
actions!(command_palette, [Toggle]);
pub struct CommandPalette {
picker: ViewHandle<Picker<Self>>,
actions: Vec<Command>,
matches: Vec<StringMatch>,
selected_ix: usize,
focused_view_id: usize,
}
pub enum Event {
Dismissed,
Confirmed {
window_id: usize,
focused_view_id: usize,
action: Box<dyn Action>,
},
}
struct Command {
name: String,
action: Box<dyn Action>,
keystrokes: Vec<Keystroke>,
}
impl CommandPalette {
pub fn new(focused_view_id: usize, cx: &mut ViewContext<Self>) -> Self {
let this = cx.weak_handle();
let actions = cx
.available_actions(cx.window_id(), focused_view_id)
.filter_map(|(name, action, bindings)| {
if cx.has_global::<CommandPaletteFilter>() {
let filter = cx.global::<CommandPaletteFilter>();
if filter.filtered_namespaces.contains(action.namespace()) {
return None;
}
}
Some(Command {
name: humanize_action_name(name),
action,
keystrokes: bindings
.last()
.map_or(Vec::new(), |binding| binding.keystrokes().to_vec()),
})
})
.collect();
let picker = cx.add_view(|cx| Picker::new(this, cx));
Self {
picker,
actions,
matches: vec![],
selected_ix: 0,
focused_view_id,
}
}
fn toggle(_: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) {
let workspace = cx.handle();
let window_id = cx.window_id();
let focused_view_id = cx.focused_view_id(window_id).unwrap_or(workspace.id());
cx.as_mut().defer(move |cx| {
let this = cx.add_view(window_id, |cx| Self::new(focused_view_id, cx));
workspace.update(cx, |workspace, cx| {
workspace.toggle_modal(cx, |_, cx| {
cx.subscribe(&this, Self::on_event).detach();
this
});
});
});
}
fn on_event(
workspace: &mut Workspace,
_: ViewHandle<Self>,
event: &Event,
cx: &mut ViewContext<Workspace>,
) {
match event {
Event::Dismissed => workspace.dismiss_modal(cx),
Event::Confirmed {
window_id,
focused_view_id,
action,
} => {
let window_id = *window_id;
let focused_view_id = *focused_view_id;
let action = (*action).boxed_clone();
workspace.dismiss_modal(cx);
cx.as_mut()
.defer(move |cx| cx.dispatch_action_at(window_id, focused_view_id, &*action))
}
}
}
}
impl Entity for CommandPalette {
type Event = Event;
}
impl View for CommandPalette {
fn ui_name() -> &'static str {
"CommandPalette"
}
fn render(&mut self, _: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
ChildView::new(self.picker.clone()).boxed()
}
fn on_focus(&mut self, cx: &mut ViewContext<Self>) {
cx.focus(&self.picker);
}
}
impl PickerDelegate for CommandPalette {
fn match_count(&self) -> usize {
self.matches.len()
}
fn selected_index(&self) -> usize {
self.selected_ix
}
fn set_selected_index(&mut self, ix: usize, _: &mut ViewContext<Self>) {
self.selected_ix = ix;
}
fn update_matches(
&mut self,
query: String,
cx: &mut gpui::ViewContext<Self>,
) -> gpui::Task<()> {
let candidates = self
.actions
.iter()
.enumerate()
.map(|(ix, command)| StringMatchCandidate {
id: ix,
string: command.name.to_string(),
char_bag: command.name.chars().collect(),
})
.collect::<Vec<_>>();
cx.spawn(move |this, mut cx| async move {
let matches = if query.is_empty() {
candidates
.into_iter()
.enumerate()
.map(|(index, candidate)| StringMatch {
candidate_id: index,
string: candidate.string,
positions: Vec::new(),
score: 0.0,
})
.collect()
} else {
fuzzy::match_strings(
&candidates,
&query,
true,
10000,
&Default::default(),
cx.background(),
)
.await
};
this.update(&mut cx, |this, _| {
this.matches = matches;
if this.matches.is_empty() {
this.selected_ix = 0;
} else {
this.selected_ix = cmp::min(this.selected_ix, this.matches.len() - 1);
}
});
})
}
fn dismiss(&mut self, cx: &mut ViewContext<Self>) {
cx.emit(Event::Dismissed);
}
fn confirm(&mut self, cx: &mut ViewContext<Self>) {
if !self.matches.is_empty() {
let action_ix = self.matches[self.selected_ix].candidate_id;
cx.emit(Event::Confirmed {
window_id: cx.window_id(),
focused_view_id: self.focused_view_id,
action: self.actions.remove(action_ix).action,
});
} else {
cx.emit(Event::Dismissed);
}
}
fn render_match(
&self,
ix: usize,
mouse_state: MouseState,
selected: bool,
cx: &gpui::AppContext,
) -> gpui::ElementBox {
let mat = &self.matches[ix];
let command = &self.actions[mat.candidate_id];
let settings = cx.global::<Settings>();
let theme = &settings.theme;
let style = theme.picker.item.style_for(mouse_state, selected);
let key_style = &theme.command_palette.key.style_for(mouse_state, selected);
let keystroke_spacing = theme.command_palette.keystroke_spacing;
Flex::row()
.with_child(
Label::new(mat.string.clone(), style.label.clone())
.with_highlights(mat.positions.clone())
.boxed(),
)
.with_children(command.keystrokes.iter().map(|keystroke| {
Flex::row()
.with_children(
[
(keystroke.ctrl, "^"),
(keystroke.alt, ""),
(keystroke.cmd, ""),
(keystroke.shift, ""),
]
.into_iter()
.filter_map(|(modifier, label)| {
if modifier {
Some(
Label::new(label.into(), key_style.label.clone())
.contained()
.with_style(key_style.container)
.boxed(),
)
} else {
None
}
}),
)
.with_child(
Label::new(keystroke.key.clone(), key_style.label.clone())
.contained()
.with_style(key_style.container)
.boxed(),
)
.contained()
.with_margin_left(keystroke_spacing)
.flex_float()
.boxed()
}))
.contained()
.with_style(style.container)
.boxed()
}
}
fn humanize_action_name(name: &str) -> String {
let capacity = name.len() + name.chars().filter(|c| c.is_uppercase()).count();
let mut result = String::with_capacity(capacity);
for char in name.chars() {
if char == ':' {
if result.ends_with(':') {
result.push(' ');
} else {
result.push(':');
}
} else if char == '_' {
result.push(' ');
} else if char.is_uppercase() {
if !result.ends_with(' ') {
result.push(' ');
}
result.extend(char.to_lowercase());
} else {
result.push(char);
}
}
result
}
impl std::fmt::Debug for Command {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Command")
.field("name", &self.name)
.field("keystrokes", &self.keystrokes)
.finish()
}
}
#[cfg(test)]
mod tests {
use super::*;
use editor::Editor;
use gpui::TestAppContext;
use project::Project;
use workspace::{AppState, Workspace};
#[test]
fn test_humanize_action_name() {
assert_eq!(
humanize_action_name("editor::GoToDefinition"),
"editor: go to definition"
);
assert_eq!(
humanize_action_name("editor::Backspace"),
"editor: backspace"
);
assert_eq!(
humanize_action_name("go_to_line::Deploy"),
"go to line: deploy"
);
}
#[gpui::test]
async fn test_command_palette(cx: &mut TestAppContext) {
let app_state = cx.update(AppState::test);
cx.update(|cx| {
editor::init(cx);
workspace::init(app_state.clone(), cx);
init(cx);
});
let project = Project::test(app_state.fs.clone(), [], cx).await;
let (window_id, workspace) = cx.add_window(|cx| Workspace::new(project, cx));
let editor = cx.add_view(window_id, |cx| {
let mut editor = Editor::single_line(None, cx);
editor.set_text("abc", cx);
editor
});
workspace.update(cx, |workspace, cx| {
cx.focus(editor.clone());
workspace.add_item(Box::new(editor.clone()), cx)
});
workspace.update(cx, |workspace, cx| {
CommandPalette::toggle(workspace, &Toggle, cx)
});
let palette = workspace.read_with(cx, |workspace, _| {
workspace
.modal()
.unwrap()
.clone()
.downcast::<CommandPalette>()
.unwrap()
});
palette
.update(cx, |palette, cx| {
palette.update_matches("bcksp".to_string(), cx)
})
.await;
palette.update(cx, |palette, cx| {
assert_eq!(palette.matches[0].string, "editor: backspace");
palette.confirm(cx);
});
editor.read_with(cx, |editor, cx| {
assert_eq!(editor.text(cx), "ab");
});
// Add namespace filter, and redeploy the palette
cx.update(|cx| {
cx.update_default_global::<CommandPaletteFilter, _, _>(|filter, _| {
filter.filtered_namespaces.insert("editor");
})
});
workspace.update(cx, |workspace, cx| {
CommandPalette::toggle(workspace, &Toggle, cx);
});
// Assert editor command not present
let palette = workspace.read_with(cx, |workspace, _| {
workspace
.modal()
.unwrap()
.clone()
.downcast::<CommandPalette>()
.unwrap()
});
palette
.update(cx, |palette, cx| {
palette.update_matches("bcksp".to_string(), cx)
})
.await;
palette.update(cx, |palette, _| assert!(palette.matches.is_empty()));
}
}

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