Commit Graph

2877 Commits

Author SHA1 Message Date
Kirill Bulatov
c45adce2e3
Run slash commands both on enter and on argument completion that requires it (#16283)
Release Notes:

- N/A
2024-08-15 19:36:30 +03:00
Kirill Bulatov
e8bae839ed
Disable forceful sorting of the slash command argument completions (#16240)
Also bubble up the current active tab's path in the \tab argument
completions.

Release Notes:

- N/A
2024-08-14 22:34:25 +03:00
Stanislav Alekseev
aa31f9ded0
Fix diagnostic popups not having a max width (#16092)
They were probably broken by #14518 

Release Notes:

- N/A
2024-08-14 16:37:35 +02:00
Mikayla Maki
97469cd049
Improve slash commands (#16195)
This PR:

- Makes slash commands easier to compose by adding a concept,
`CompletionIntent`. When using `tab` on a completion in the assistant
panel, that completion item will be expanded but the associated command
will not be run. Using `enter` will still either run the completion item
or continue command composition as before.
- Fixes a bug where running `/diagnostics` on a project with no
diagnostics will delete the entire command, rather than rendering an
empty header.
- Improves the autocomplete rendering for files, showing when
directories are selected and re-arranging the results to have the file
name or trailing directory show first.

<img width="642" alt="Screenshot 2024-08-13 at 8 12 43 PM"
src="https://github.com/user-attachments/assets/97c96cd2-741f-4f15-ad03-7cf78129a71c">


Release Notes:

- N/A
2024-08-13 23:06:07 -07:00
Richard Feldman
b1a581e81b
Copy/paste images into editors (Mac only) (#15782)
For future reference: WIP branch of copy/pasting a mixture of images and
text: https://github.com/zed-industries/zed/tree/copy-paste-images -
we'll come back to that one after landing this one.

Release Notes:

- You can now paste images into the Assistant Panel to include them as
context. Currently works only on Mac, and with Anthropic models. Future
support is planned for more models, operating systems, and image
clipboard operations.

---------

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Jason <jason@zed.dev>
Co-authored-by: Kyle <kylek@zed.dev>
2024-08-13 13:18:25 -04:00
CharlesChen0823
fe190359d5
editor: Add revert file action to command palette (#16012)
Release Notes:

- Added an `editor::RevertFile` action
2024-08-13 14:44:41 +03:00
Stanislav Alekseev
c2b254a67a
Fallback to using tree-sitter when determining ranges for info popovers (#16062)
Closes #15382

Release Notes:

- Added fallback to a smallest tree sitter node when hovering over a
symbol
2024-08-13 12:01:14 +02:00
Kirill Bulatov
3bebb8b401
Allow to cycle through center/top/bot scroll positions (#16134)
On top of `editor::ScrollCursorCenter`, `editor::ScrollCursorTop`,
`editor::ScrollCursorBottom` actions, adds an
`editor::ScrollCursorCenterTopBottom` one, that allows using a single
keybinding to scroll between positions on the screen.

The implementation matches a corresponding Emacs feature: there's a
timeout (1s) that is kept after every switch, to allow continuously
changing the positions, center (initial) -> top -> bottom
Scrolling behavior is the same as the existing actions (e.g. editor will
ignore scroll to bottom, if there's not enough space above).

After 1s, next position is reset to the initial, center, one.


Release Notes:

- Added an `editor::ScrollCursorCenterTopBottom` action for toggling
scroll position with a single keybinding

---------

Co-authored-by: Alex Kladov <aleksey.kladov@gmail.com>
2024-08-13 00:32:30 +03:00
Kirill Bulatov
f398ecc3fb
Allow inserting text into the editor via the action (#16131)
Improves workflows, based on the keymaps that group actions behind a
certain symbol.
E.g.

```json5
", o k": "zed::OpenKeymap",
", o K": "zed::OpenDefaultKeymap",
// other `,`-based keymaps
```

Now, it's possible to do 
```json
", ,": ["editor::HandleInput", ","]
```

and type `,` without waiting for the timeout due to `,`-based bindings.

Release Notes:

- Add an `editor::HandleInput` action to ease typing symbols that are
part of keymaps. E.g. if `, o k` keybinding is bound, `", ,":
["editor::HandleInput", ","]` would allow to type `,` without timeouts.

---------

Co-authored-by: Alex Kladov <aleksey.kladov@gmail.com>
2024-08-13 00:02:52 +03:00
Massimo Mund
e783142528
Fix vertical_scroll_margin not being capped for large vertical_scroll_margin values (#15473)
When switching to function definitions in a new buffer the
`AutoscrollStrategy::Focused` being emitted to scroll to the found
location.
If a large value `vertical_scroll_margin` (e.g.: 99) is set, this leads
to an incorrectly calculated position and the new buffer opens in the
wrong place.

In `autoscroll_vertically()` there is a margin calculated to cap the
value of `vertical_scroll_margin` for certain AutoscrollStrategies. This
margin is being used in `AutoscrollStrategy::Fit` and
`AutoscrollStrategy::Newest` but was probably forgotten for
`AutoscrollStrategy::Focused`.

- Might fix [#15101](https://github.com/zed-industries/zed/issues/15101)

Release Notes:

- N/A
2024-08-09 09:35:57 +02:00
Conrad Irwin
bd59af1df5
vim: Support ranges in command (#15985)
The most requested feature here is "search and replace in visual mode",
but as a happy side effect we can now support things like :2,12j to join
those lines, and much much more.



Release Notes:

- vim: Added support for range syntax in command
([#9428](https://github.com/zed-industries/zed/issues/9428)).
- vim: Prefill command with `:'<,'>` from visual mode
([#13535](https://github.com/zed-industries/zed/issues/13535)).
2024-08-08 21:47:27 +01:00
Piotr Osiewicz
73fb8277fc
assistant: Polish /workflow and steps UI (#15936)
Fixes #15923
Release Notes:

- Assistant workflow steps can now be applied and reverted directly from
within the assistant panel.

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Antonio <antonio@zed.dev>
2024-08-08 15:46:33 +02:00
Nathan Sobo
da8d1306af
Open workflow step editors as preview tabs (#15928)
This PR opens workflow step editors as preview tabs and closes them upon
exiting the step if they are still in preview mode and they weren't
already open before entering the step.

Making this work was tricky, because we often edit the buffer as part of
displaying the workflow step suggestions to create empty lines where we
can generate. We undo these edits if the transformation is not applied,
but they were causing the preview to be dismissed.

After trying a few approaches, I decided to give workspace `Item`s a
`preserve_preview` method that defaults to false. When the workspace
sees an edit event for the item, it checks if the item wants to preserve
its preview. For buffers, after editing, you can call `refresh_preview`,
which sets a preview version to the current version of the buffer. Any
edits after this version will cause preview to not be preserved.

One final issue is with async auto-indent. To ensure these async edits
don't dismiss the preview, I automatically refresh the preview version
if preview was preserved prior to performing the auto-indent. The
assumption is that these are edits created by other edits, and if we
didn't want to dismiss the preview with the originating edits, then the
auto-indent edits shouldn't dismiss it either.

Release Notes:

- N/A

---------

Co-authored-by: Jason <jason@zed.dev>
2024-08-07 19:33:58 -06:00
Antonio Scandurra
104d7adc49
Don't insert unnecessary space below the end of an inline transformation (#15865)
We achieved this by allowing block decorations to have a height of `0`
and superimposing the border on top of the line, as opposed to carving
out space below it.

Release Notes:

- N/A

---------

Co-authored-by: Jason <jason@zed.dev>
2024-08-06 19:00:23 +02:00
Luis Cossío
7b5fdcee7f
lsp: Support Goto Declaration (#15785)
Adds support for [Goto
Declaration](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_declaration)
LSP command.

I am particularly interested in [this for Rust
projects](https://rust-analyzer.github.io/manual.html#go-to-declaration),
to be able to navigate to the place where a trait method is declared,
coming from a trait method implementation.

I noticed this was something I could do in VSCode before, but was
somehow missing is Zed. Thanks to the already existing infrastructure
for Goto Definition, I just followed and copy-paste-adapted it for Goto
Declaration.

As a bonus, I added `ctrl-F12` and `alt-ctrl-F12` as default macOS
keybindings for `GoToDeclaration` and `GoToDeclarationSplit`,
respectively. They are not keybindings from another editor, but I
figured they made sense to be grouped along with the other *F12
commands.

### Release Notes:

- Added "Go to declaration" editor action.
- vim: Breaking change to keybindings after introduction of the `Go to
declaration` editor action. The new keybindings are the following (and
can be found [here](https://zed.dev/docs/vim), alongside the other key
bindings):
  - `g d` - Go to definition
  - `g D` - Go to declaration
  - `g y` - Go to type definition
  - `g I` - Go to implementation




https://github.com/user-attachments/assets/ee5c10a8-94f0-4e50-afbb-6f71db540c1b

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-08-06 11:20:51 +02:00
Kyle Kelley
4528e9d582
repl: Create better terminal output for REPL stdio (#15715)
Rely on our implementation of a GPUI powered alacritty terminal to
render stdout & stderr from the repl.

Release Notes:

- Fixed ANSI escape code and carriage return handling in repl outputs
(https://github.com/zed-industries/zed/issues/15640,
https://github.com/zed-industries/zed/issues/14855)


https://github.com/user-attachments/assets/bd3f1584-863a-4afa-b60b-9d222a830ff8

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-08-03 05:48:16 -07:00
Piotr Osiewicz
e2eb68abca
chore: Remove leftover code from #15646 (#15697)
Release Notes:

- N/A
2024-08-02 20:08:57 +02:00
Piotr Osiewicz
ad11d83724
Skip over folded regions when iterating over multibuffer chunks (#15646)
This commit weaves through new APIs for language::BufferChunks, multi_buffer::MultiBufferChunks and inlay_map::InlayChunks that allow seeking with an upper-bound. This allows us to omit doing syntax highligting and looking up diagnostics for folded ranges. This in turn directly improves performance of assistant panel with large contexts.

Release Notes:

- Fixed poor performance when editing in the assistant panel after
inserting large files using slash commands

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-08-02 19:51:26 +02:00
Nathan Sobo
1b85793ebc
Fix inline assist deletion blocks (#15651)
After the changes in #15536, block decorations need to be given an
explicit height if their content doesn't consume height on its own. We
missed that inline transformation deletion decorations didn't do this,
creating weird results. This fixes the issue and prevents block
decorations from ever having a zero height. That helps avoid major
weirdness, but this still a bit of a gotcha.

We need to back port this to Preview Channel (0.147.x)

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
2024-08-01 22:41:25 +02:00
Kirill Bulatov
c98918aed8
Properly calculate y offsets for multi buffer context menus (#15594)
Follow-up of https://github.com/zed-industries/zed/pull/14727

Release Notes:

- Fixed multi buffer context menus not showing properly

Co-authored-by: Max Brunsfeld <max@zed.dev>
2024-08-01 12:35:46 +03:00
Antonio Scandurra
5b1ea7eda0
Clean up inline assist editor rendering (#15536)
Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Max <max@zed.dev>
2024-07-31 17:43:08 +02:00
Jason Lee
0c8b17d252
Hide blinking cursor when window is deactivated (#15408)
## Before 

https://github.com/user-attachments/assets/affb8407-a20e-4258-a8f7-b271da5d7b77

## After

https://github.com/user-attachments/assets/654fe7b9-330a-40c8-8885-72e69fa85b0a

Release Notes:

- Hide blinking cursor when window is deactivated ([4710](https://github.com/zed-industries/zed/issues/4710))
2024-07-30 10:49:15 +03:00
Antonio Scandurra
02c51c9b56
Fix rendering of focused offscreen block when scrolled to bottom (#15449)
This change fixes a bug when a block is focused but offscreen.
Previously, we used the last row, but this caused a spurious block to be
rendered when scrolled to the end of the file. With this change we
always render off-screen blocks below the editor's clipping box.

Release Notes:

- Fixed a bug that caused the inline assistant to be displayed twice in
certain circumstances.

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-29 20:39:21 +02:00
Ephram
78a2539d59
Selectable diagnostic popover text (#14518)
Release Notes:

- Added the ability to select and copy text from diagnostic popovers

- Fixed #12695




https://github.com/user-attachments/assets/b896bacf-ecbc-48f5-8228-a3821f0b1a4e

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-07-28 23:13:13 -06:00
Marshall Bowers
f1d777434b
ui: Give NumericSteppers an ID (#15344)
This PR gives the `NumericStepper` component an ID.

This prevents the UI and buffer font size settings controls from having
their increment/decrement buttons visually change when the other one is
pressed.

Release Notes:

- N/A
2024-07-27 13:02:27 -04:00
Calin Martinconi
3751f67730
fix: Typos (#15313)
Fixed typos in the code base according with output from `codespell`
tool.

Release Notes:

- N/A
2024-07-26 17:52:37 -07:00
Mikayla Maki
a1bd7a1297
Feature/fallback fonts (#15306)
Supersedes https://github.com/zed-industries/zed/pull/12090

fixes #5180
fixes #5055

See original PR for an example of the feature at work.

This PR changes the settings interface to be backwards compatible, and
adds the `ui_font_fallbacks`, `buffer_font_fallbacks`, and
`terminal.font_fallbacks` settings.

Release Notes:

- Added support for font fallbacks via three new settings:
`ui_font_fallbacks`, `buffer_font_fallbacks`, and
`terminal.font_fallbacks`.(#5180, #5055).

---------

Co-authored-by: Junkui Zhang <364772080@qq.com>
2024-07-26 16:42:21 -07:00
Conrad Irwin
3e31955b7f
SSH remote ui (#15129)
Still TODO:
* [x] hide this UI unless you have some ssh projects in settings
* [x] add the "open folder" flow with the new open picker
* [ ] integrate with recent projects / workspace restoration

Release Notes:

- N/A
2024-07-26 16:45:44 -06:00
Marshall Bowers
bde02a350e
settings_ui: Add line number settings controls (#15310)
This PR adds settings controls for the line numbers and relative line
numbers settings.

Release Notes:

- N/A
2024-07-26 18:31:45 -04:00
Marshall Bowers
27f97ba762
settings_ui: Add font ligature settings controls (#15301)
This PR adds settings controls for changing whether ligatures are
enabled for the UI and buffer fonts.

Release Notes:

- N/A
2024-07-26 17:06:14 -04:00
Thorsten Ball
18daf17d0e
refactoring: Use helper instead of adjusting selection manually (#15262)
I added `newest_adjusted` recently and now just bumped into the old code
that didn't use it.

Release Notes:

- N/A
2024-07-26 11:12:33 +02:00
Kirill Bulatov
10c9e337cf
Fix more gutter close button alignment issues (#15233)
Follow-up of https://github.com/zed-industries/zed/pull/15178

* shows proper cursor on hovering a block that's over a git hunk
* show gutter buttons better when git hunks are on the same line
* show deleted hunks' gutter buttons better when git blame info is shown
in the gutter

Release Notes:

- N/A
2024-07-26 01:42:25 +03:00
Piotr Osiewicz
0d5de88c4b
chore: Bump Rust version to 1.80 (#15186)
Release Notes:

- N/A
2024-07-25 22:48:42 +02:00
Piotr Osiewicz
86456ce379
chore: Fix clippy violations from Cargo.toml (#15216)
/cc @maxdeviant 
Release Notes:

- N/A
2024-07-25 20:22:01 +02:00
Thorsten Ball
7146087b44
zed: Mark restored buffers as conflicted if file changed on disk between store & restore (#15207)
Previously, we've only marked restored buffers as dirty. This PR changes
that behavior in case the buffer has been associated with a file and
that file has changed on disk since the last time Zed stored its
contents.

Example timeline:

1. User edits file in Zed, buffer is dirty
2. User quites Zed with `cmd-q`
3. User changes file on disk: `echo foobar >> file.txt` or `git checkout
file.txt`
4. User starts Zed
5. File/buffer are now marked as having a conflict (yellow icon)

Release Notes:

- Unsaved files that are restored when Zed starts are now marked as
having a conflict if they have been changed on disk since the last time
they were stored.

Demo:



https://github.com/user-attachments/assets/6098b485-b325-49b7-b694-fd2fc60cce64
2024-07-25 18:04:47 +02:00
Kirill Bulatov
856a8ef5e8
Layout gutter hunk diff close button (X) better (#15178)
Closes https://github.com/zed-industries/zed/issues/15164

* Deleted hunk
Before:

![before_top](https://github.com/user-attachments/assets/27c72ee5-719f-4787-b222-4f597840936a)

After:

![after_top](https://github.com/user-attachments/assets/58095b21-698d-4778-8412-b680d5253e2c)

* Modified hunk
Before:

![before_down](https://github.com/user-attachments/assets/3fffb73b-7101-493c-b63b-15c3ccaf5362)

After:

![after_down](https://github.com/user-attachments/assets/f07a05ed-1260-4e2a-9388-c9cb93020d78)

* Added hunk
Before:

![before_mid](https://github.com/user-attachments/assets/0dd3f0f9-51e8-449a-bdd7-4c3ba5cd7791)

After:

![after_mid](https://github.com/user-attachments/assets/92f749bd-2d95-4650-8334-1d5c38c6aeb6)

Release Notes:

- N/A
2024-07-25 15:50:57 +03:00
Marshall Bowers
659f34bf21
settings_ui: Add UI and buffer font family controls (#15124)
This PR adds settings controls for changing the UI and buffer font
families.

Release Notes:

- N/A
2024-07-24 18:01:35 -04:00
Kirill Bulatov
596ee58be8
Bump tree-sitter and related core language parser libraries (#14986)
Closes https://github.com/zed-industries/zed/issues/4565

To fix issues with code blocks' parsing in Markdown, a
tree-sitter-markdown library update is needed.
But `tree_sitter::language` is used in many places within core Zed,
which forced more library updates.

Release Notes:

- Updated tree-sitter parsers for core languages

---------

Co-authored-by: Max Brunsfeld <max@zed.dev>
Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
2024-07-24 23:38:21 +03:00
Marshall Bowers
0297a42735
Use US English spelling of "behavior" and "customize" (#15117)
This PR fixes some instances that weren't using US English spellings of
"behavior" and "customize".

Release Notes:

- N/A
2024-07-24 16:36:01 -04:00
Vitaly Slobodin
9c9a0bd24f
lsp: Check if "Goto Definition" supported before request (#15111)
This is related to #15023 where we have the running Rubocop LSP that
provides diagnostics and formatting capabilities. Rubocop LSP sends its
capabilities
back to Zed without support for "textDocument/definition" request, Zed
actually does not check that and sends a request to Rubocop that results
in the server error "Unsupported method: textDocument/definition".

The fix here is related to
https://github.com/zed-industries/zed/pull/14666

Release Notes:

- N/A
2024-07-24 23:28:23 +03:00
Marshall Bowers
740c444089
settings_ui: Add theme settings controls (#15115)
This PR adds settings controls for the theme settings.

Release Notes:

- N/A
2024-07-24 16:25:52 -04:00
Piotr Osiewicz
325e6b9fef
editor: Improve performance of buffer/project search (#15109)
Fixes #15102
Release Notes:

- Improved performance of project and buffer search when there are many
matches.
2024-07-24 21:04:07 +02:00
Marshall Bowers
274e56b086
settings_ui: Add UI and buffer font weight controls (#15104)
This PR adds settings controls for the UI and buffer font weight
settings.

It also does some work around grouping the settings into related
sections.

Release Notes:

- N/A
2024-07-24 14:09:13 -04:00
Kirill Bulatov
64b15d3a0e
Display blocks over the git hunks (#15083)
Before:

![before](https://github.com/user-attachments/assets/614bbafd-f344-4c86-bd62-fff5f1ab143a)

After:

![after](https://github.com/user-attachments/assets/40a72a46-9fc4-4f94-9090-fb389f824a8d)


Release Notes:

- N/A
2024-07-24 07:23:20 -07:00
Piotr Osiewicz
23c5fc1b03
chore: Use explicit if let instead of for .. in option (#15086)
Fixes one clippy violation from 1.80 (that's due for release tomorrow).

Release Notes:

- N/A
2024-07-24 16:19:29 +02:00
Kirill Bulatov
babf8923ee
Do not show signature help when editor is not focused (#15080)
Show the help again, if it was not dismissed and the editor regains
focus.

Release Notes:

- N/A
2024-07-24 14:37:35 +03:00
Nathan Sobo
87d93033d1
Support Jupytext-style line comments for REPL evaluation ranges (#15073)
This adds support for detecting line comments in the
[Jupytext](https://jupytext.readthedocs.io/) format. When line comments
such as `# %%` is present, invoking `repl: run` will evaluate the code
between these line comments as a unit.

/cc @rgbkrk 

```py
# %%
# This is my first block
print(1)
print(2)

# %%
# This is my second block
print(3)
```

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-07-24 11:53:58 +02:00
Mikayla Maki
855048041d
Update http crate name (#15041)
Release Notes:

- N/A
2024-07-23 15:01:05 -07:00
Stanislav Alekseev
5021397c01
Fix diagnostic popups flickering when moving cursor in the boundaries of the symbol (#14870)
This PR just uses ranges returned by an LSP to work, the subsequent PR
would focus on trying to fall back onto tree-sitter in case of info
hovers. I'm also unsure if I'm supposed to use `local_diagnostic` or
`primary_diagnostic` when both are available
Release Notes:

- Fix diagnostic popups flickering when moving cursor in the boundaries
of the symbol

Before:


https://github.com/user-attachments/assets/4905a7e5-c333-453b-b204-264b3ef79586

After:


https://github.com/user-attachments/assets/c742c424-fb20-450d-8848-baaf1937dd47
2024-07-23 14:10:19 -06:00
Max Brunsfeld
38e3182bef
Handle buffer diff base updates and file renames properly for SSH projects (#14989)
Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
2024-07-23 11:32:37 -07:00