Commit Graph

8297 Commits

Author SHA1 Message Date
Max Brunsfeld
e7ba5a1edb
Search UI polish (#2904)
This PR polishes the search bar UI, making the layout more dense, and
the spacing more consistent with the rest of the app. I've also
re-ordered the toolbar items to reflect some of @iamnbutler's original
search designs. The items related to the search query are on the left,
and the actions that navigate the buffer (next, prev, select all, result
count) are on the right.
2023-08-29 12:53:32 -07:00
Conrad Irwin
dd577074f2
vim: Fix relative motions (#2888)
This changes vim motions to be relative to fold lines, not display
lines, to match the behaviour of vim.

This is necessary for relative line numbers to make sense (as the most
important thing is you can do `3j` to get th e line that is numbered 3).


Release Notes:

- vim: Fix handling of motions when `soft_wrap` is enabled in zed. Like
in vim `j,k,up,down,$,^,0,home,end` will all now navigate in file
coordinates not display coordinates.
- vim: Add `g {j,k,up,down,$,^,0,home,end}` to navigate in display
coordinates.
- vim: Add `z o` and `z c` to open and close folds.
- vim: Add `z f` in visual mode to fold selection.

Note: this may be a jarring change if you're grown used to the current
behaviour of `j` and `k`. You can make the issue less acute by setting
`"soft_wrap":"none"` in your settings; or you can manually copy the
bindings for `g j` to the binding for `j` (etc.) in your keymap.json to
preserve the existing behaviour.
2023-08-29 11:19:37 -07:00
Nate Butler
f0ab27a83d Reorder "Select All" button 2023-08-29 14:04:17 -04:00
Max Brunsfeld
7ae5ee699f
Debounce code action and document highlight requests (#2905)
Lately, I've been finding Rust-analyzer unusably slow when editing large
files (like `editor_tests.rs`, or `integration_tests.rs`). When I
profile the Rust-analyzer process, I see that it sometimes saturates up
to 10 cores processing a queue of code actions requests.

Additionally, sometimes when collaborating on large files like these, we
see long delays in propagating buffer operations. I'm still not sure why
this is happening, but whenever I look at the server logs in Datadog, I
see that there are remote `CodeActions` and `DocumentHighlights`
messages being processed that take upwards of 30 seconds. I think what
may be happening is that many such requests are resolving at once, and
the responses are taking up too much of the host's bandwidth.

I think that both of these problems are caused by us sending way too
many code action and document highlight requests to rust-analyzer. This
PR adds a simple debounce between changing selections and making these
requests.

From my local testing, this debounce makes Rust-analyzer *much* more
responsive when moving the cursor around a large file like
`editor_tests.rs`.
2023-08-29 09:30:36 -07:00
Piotr Osiewicz
ea0e5e880e
chore: Use IsTerminal trait instead of relying on libc to detect stdout being a terminal (#2908)
IsTerminal was added in 1.70.

Release Notes:
- N/A
2023-08-29 15:56:50 +02:00
Kirill Bulatov
7c498feb85 Trim off surrounding [] when parsing terminal hover links
Terminal has to accept `[` and `]` as valid word parts, due to
`[slug].tsx` being a valid file name.
Yet, terminal has to exclude these to match paths in strings like
`[/some/path/[slug].tsx]`.
2023-08-29 10:40:20 +03:00
Max Brunsfeld
791f6cf9e7 Update some tests to reflect code action debouncing 2023-08-28 17:45:32 -07:00
Max Brunsfeld
5142049515 Demote some Peer logging to trace level 2023-08-28 17:45:19 -07:00
Max Brunsfeld
89eab78cf7 Debounce document highlight and code actions requests 2023-08-28 15:48:55 -07:00
Max Brunsfeld
70bea75897 Change cycle mode action to reflect new mode button order 2023-08-28 15:15:54 -07:00
Max Brunsfeld
3eee282a6b Overhaul search bar layout
* Use a single row, instead of centering the search bar within a double-row toolbar.
* Search query controls on the left, navigation on the right
* Semantic is the final mode, for greater stability between buffer and project search.
* Prevent query editor from moving when toggling path filters
2023-08-28 14:20:09 -07:00
Max Brunsfeld
bb448b91d5 Don't add a quick actions toolbar item for non-editor views
Rather than adding primary toolbar item that renders as empty,
don't add an item at all. This prevents spurious spacing from
being added after other primary toolbar items.
2023-08-28 14:16:45 -07:00
Max Brunsfeld
9521f6da42 Simplify implementation of flex with spacing 2023-08-28 14:16:21 -07:00
Max Brunsfeld
04354675ca Remove search dismiss button 2023-08-28 10:35:23 -07:00
Piotr Osiewicz
07b9c6c302
language: Make Buffer::new take an explicit ID (#2900)
See Linear description for the full explanation of the issue. This PR is
mostly a mechanical change, except for the one case where we do pass in
an explicit `next_id` instead of `model_id` in project.rs.

Release Notes:
- Fixed a bug where some results were not reported in project search in
presence of unnamed buffers.
2023-08-28 11:51:50 +02:00
Kirill Bulatov
506ec01df3 Allow [ and ] symbols in terminal links
` ./src/pages/[[...slug]].tsx` is a valid file path in macOs and Linux,
and should be available for cmd-hover-click in terminal.
2023-08-28 11:19:57 +03:00
Kirill Bulatov
3bfe78b1df Use proper property names for inlay hint resolve capabilities 2023-08-28 00:27:59 +03:00
Kirill Bulatov
38da2a587a Fix the tests 2023-08-27 19:41:15 +03:00
Kirill Bulatov
81e70905bb Do not allow cmd+click in invalid inlay context 2023-08-27 19:12:32 +03:00
Kirill Bulatov
693e91f335 Properly compare previous hover trigger point when hover changes 2023-08-27 18:23:40 +03:00
Kirill Bulatov
dad64edde1 Better highlight hint ranges 2023-08-27 15:14:45 +03:00
Kirill Bulatov
5cf51211b6 Use better names, simplify 2023-08-27 00:01:31 +03:00
Kirill Bulatov
73937876b6 Properly omit throttled hint queries 2023-08-26 21:12:04 +03:00
Kirill Bulatov
f8a8b998ce Properly react on excerpts drop 2023-08-26 15:21:45 +03:00
Kirill Bulatov
84284099e2 Properly handle padding when highlighting inlay hints 2023-08-26 15:04:48 +03:00
Kirill Bulatov
2a42a08f46 Invalidate skipped throttled hint fetch tasks' ranges 2023-08-26 14:47:42 +03:00
Kirill Bulatov
9bdf76f445 Properly handle hover-less areas hover 2023-08-26 14:42:20 +03:00
Kirill Bulatov
48659d3b3c Treat multibuffer edit events properly
Miltibuffer emits edit events even if it only got an excerpt
added/removed/etc.
Separate buffer edits and trigger hint invalidation refresh for them
only, also trigger hint new lines refresh on excerpt addition events.
2023-08-26 14:13:24 +03:00
Kirill Bulatov
3fc48fc277 Log LSP inlay hint path 2023-08-26 13:46:55 +03:00
Kirill Bulatov
e6fb909d89 Limit LSP non-invalidating queries 2023-08-26 13:06:50 +03:00
Kirill Bulatov
2b007930a9 Remove query ranges for failed inlay hint requests 2023-08-26 12:09:12 +03:00
Mikayla Maki
8ddee0e58d
Server-sent feature flags (#2894)
This PR adds the wiring to both the server and the client for sending
and receiving individual feature flags, as well as a client side API for
convenient access to these feature flags.

Release Notes:

- N/A
2023-08-25 17:11:33 -07:00
Mikayla
74565ed0b8
Add feature flags handling to the client, rewrite staff mode to a trait extension style 2023-08-25 17:00:53 -07:00
Kirill Bulatov
81c64647e8 Fix the test 2023-08-26 03:00:53 +03:00
Kirill Bulatov
e6c4802488 Properly clip request offsets 2023-08-26 02:54:50 +03:00
Kirill Bulatov
b2b0918790 Consider padding during hint highlight range mapping 2023-08-26 02:45:08 +03:00
Kirill Bulatov
665d86ea73 Defer navigation target buffer opening 2023-08-26 02:45:08 +03:00
Kirill Bulatov
ddd7ab116f Do not convert lsp::Location of hint labels before resolve 2023-08-26 02:45:08 +03:00
Max Brunsfeld
d6ffb68305
Fix bugs in autoscroll with 'fit' strategy (#2893)
This fixes a bug where text moved up and down by one pixel in the buffer
search query editor, while typing.

Release  notes:
* Fixed a bug where editors didn't auto-scroll when typing if all
cursors could not fit within the viewport.
2023-08-25 16:36:33 -07:00
Piotr Osiewicz
2495d6581e
Un serialize project search (#2857)
This is the first batch of improvements to current project search. There
are few things we can do better still, but I want to get this out in
next Preview.
Most of the slowness at this point seems to stem from updating UI too
often.

Release Notes:
- Improved project search by making it report results sooner.

---------

Co-authored-by: Julia Risley <julia@zed.dev>
2023-08-26 01:31:52 +02:00
Max Brunsfeld
a3b2c03b17 Fix bugs in autoscroll with 'fit' strategy
* Scroll to the newest cursor if all cursors can't fit in the viewport.
* Refuse to layout an editor less tall than one line height.

Co-authored-by: Nathan <nathan@zed.dev>
2023-08-25 16:13:12 -07:00
Mikayla
6fdf101745
Update database and RPC to provide configured feature flags 2023-08-25 14:34:32 -07:00
Conrad Irwin
dee1a433dd A few more fixes for wrapped line motions 2023-08-25 14:40:04 -06:00
Conrad Irwin
20aa2a4c54 vim: Fix relative line motion
Before this change up and down were in display co-ordinates, after this
change they are in fold coordinates (which matches the vim behaviour).

To make this work without causing usabliity problems, a bunch of extra
keyboard shortcuts now work:

- vim: `z {o,c}` to open,close a fold
- vim: `z f` to fold current visual selection
- vim: `g {j,k,up,down}` to move up/down a display line
- vim: `g {0,^,$,home,end}` to get to start/end of a display line

Fixes: zed-industries/community#1562
2023-08-25 14:40:04 -06:00
Conrad Irwin
0280d5d010 vim change for wrapped lines 2023-08-25 14:40:03 -06:00
Conrad Irwin
104f5ae9cd
relative line numbers (#2887)
- Add relative_line_mode
- vim change for wrapped lines

Release Notes:

- Add a `relative_line_numbers` setting
([#988](https://github.com/zed-industries/community/issues/998)).
2023-08-25 14:17:41 -06:00
Joseph T. Lyons
c1fd648390
Add setting to automatically enable virtual environment (#2882)
This isn't ready to go - I'm opening a PR to ask for some advice. When
activating a python virtual environment, the typical command used is
`source path_to_venv/bin/activate`. The problem is, the activatate
script isn't portable to all shells, so some additional scripts are
bundled in the env, for example, `activate.fish`. We don't have a good
way of knowing what shell we are in, in order to know what script to
run.

Julia gave the alternative of simply activating the virtual environment
while in the zsh context, before the user's custom shell is launched,
which I think does work, but because we activate the virtual environment
before we launch the custom shell, the shell isn't really aware that we
are in the virtual environment and it fails to display the information
in the prompt that is typically shown after activating.

Is there a clean way for us to know for a fact what shell is being ran,
so we know what script to run?

Check out the code comments below for more context.

---


https://github.com/zed-industries/zed/assets/19867440/ddb76aaa-152b-4c93-a513-3cd580b7c40f

I've used Zed to write Python scripts, but working on an actual project
has really magnified where Python dev is falling short. A huge
quality-of-life thing we can do is provide a setting to automaticaly
search for and activate virtual environments when found, when terminals
are created. Manually starting these up in every terminal instance is
such a drag.

A few quirks:
- We don't have a way of knowing if the prompt is ready before we try
run the command, which means we see the text inserted at the top of the
terminal and on the prompt - I dont think this should be a blocker
though.
- If a user has multiple python projects with mutliple virtual
environments, we only detect and activate the first one, since can't
really make any assumptions about which one to activate. I dont think
this should be a blocker either, as I think most users will have a
single project open in Zed.

Release Notes:

- Added a `detect_venv` setting for the terminal. When configured, the
Zed terminal will automatically activate Python virtual environments on
terminal creation.
2023-08-25 15:14:24 -04:00
Joseph T. Lyons
507a5db09c WIP
Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
2023-08-25 15:06:31 -04:00
Conrad Irwin
bde67b2b9c Fix merge-conflict 2023-08-25 11:59:16 -06:00
Conrad Irwin
f18cdcba54 Fix relative line numbers in vim visual mode
In visual mode when your selection ends with a newline we show the
cursor at the end of the previous line (not the start of the current
line). We had only been accounting for this if the cursor was on-screen.
2023-08-25 11:50:41 -06:00