Commit Graph

14993 Commits

Author SHA1 Message Date
Piotr Osiewicz
298e9c9387
task: Allow Rerun action to override properties of task being reran (#10468)
For example:
```
"alt-t": [
    "task::Rerun",
     { "reevaluate_context": true, "allow_concurrent_runs": true }
],
```
Overriding `allow_concurrent_runs` to `true` by itself should terminate
current instance of the task, if there's any.

This PR also fixes task deduplication in terminal panel to use expanded
label and not the id, which depends on task context. It kinda aligns
with how task rerun worked prior to #10341 . That's omitted in the
release notes though, as it's not in Preview yet.

Release Notes:

- `Task::Rerun` action can now override `allow_concurrent_runs` and
`use_new_terminal` properties of the task that is being reran.
2024-04-12 12:44:50 +02:00
Thorsten Ball
6e1ba7e936
Allow hovering over tooltips in git blame sidebar (#10466)
This introduces a new API on `StatefulInteractiveElement` to create a
tooltip that can be hovered, scrolled inside, and clicked:
`.hoverable_tooltip`.

Right now we only use it in the `git blame` gutter, but the plan is to
use the new hover/click/scroll behavior in #10398 to introduce new
git-blame-tooltips.

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
2024-04-12 11:47:32 +02:00
Mehmet Efe Akça
29a50573a9
Add git blame error reporting with notification (#10408)
<img width="1035" alt="Screenshot 2024-04-11 at 13 13 44"
src="https://github.com/zed-industries/zed/assets/13402668/cd0e96a0-41c6-4757-8840-97d15a75c511">

Release Notes:

- Added a notification to show possible `git blame` errors if it fails to run.

Caveats:
- ~git blame now executes in foreground
executor  (required since the Fut is !Send)~

TODOs:
- After a failed toggle, the app thinks the blame
is shown. This means toggling again will do nothing
instead of retrying. (Caused by editor.show_git_blame
being set to true before the git blame is generated)
- ~(Maybe) Trim error?~ Done

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-04-12 07:20:34 +02:00
Conrad Irwin
08786fa7bf
Make BufferSearch less wide (#10459)
This also adds some "responsiveness" so that UI elements are hidden
before everything has to be occluded

Release Notes:

- Improved search UI. It now works in narrower panes, and avoids
scrolling the editor on open.

<img width="899" alt="Screenshot 2024-04-11 at 21 33 17"
src="https://github.com/zed-industries/zed/assets/94272/44b95d4f-08d6-4c40-a175-0e594402ca01">
<img width="508" alt="Screenshot 2024-04-11 at 21 33 45"
src="https://github.com/zed-industries/zed/assets/94272/baf4638d-427b-43e6-ad67-13d43f0f18a2">
<img width="361" alt="Screenshot 2024-04-11 at 21 34 00"
src="https://github.com/zed-industries/zed/assets/94272/ff60b561-2f77-49c0-9df7-e26227fe9225">
<img width="348" alt="Screenshot 2024-04-11 at 21 37 03"
src="https://github.com/zed-industries/zed/assets/94272/a2a700a2-ce99-41bd-bf47-9b14d7082b0e">
2024-04-11 23:07:29 -06:00
Hans
f2d61f3ea5
Add feature to display commands for vim mode (#10349)
Release Notes:

- Added the current operator stack to the Vim status bar at the bottom
of the editor. #4447

This commit introduces a new feature that displays the current partial
command in the vim mode, similar to the behavior in Vim plugin. This
helps users keep track of the commands they're entering.
2024-04-12 06:39:57 +02:00
Conrad Irwin
98533079e4
Use buffer font for search (#10455)
It's wierd to type code/regex in the UI font

Release Notes:

- Continue to use buffer font for search
2024-04-11 22:15:12 -06:00
Nate Butler
27ba165046
Organize Project Panel context menus (#10456)
This design polish PR brings the project panel context menu into better
alignment with other editors, better follows system patterns and
identifies focus shifting actions with the `…` indicator (like adding a
new folder to a project, which will open a modal window.)

## Before & After:

**Root level**

![CleanShot - 2024-04-11 at 22 40
53@2x](https://github.com/zed-industries/zed/assets/1714999/aa103d14-0747-4be9-acbf-1c3ed0542a15)

**Folder level**

![CleanShot - 2024-04-11 at 22 43
45@2x](https://github.com/zed-industries/zed/assets/1714999/180224f2-26d1-45bd-8f78-822f46068a6d)

**File level**

![CleanShot - 2024-04-11 at 22 44
56@2x](https://github.com/zed-industries/zed/assets/1714999/67edd0ae-bcb6-4920-a480-c4d50c6bccfa)

Note: That double divider in the after has been fixed 😅

---

Release Notes:

- Improved ordering and organization of context menus in the project
panel to bring them closer to those in similar applications.
2024-04-11 22:52:49 -04:00
Hans
32806b8320
vim: Don’t allow edits in the read-only state (#10404)
Fix #8423 

Release Notes:

- vim: Fixed vim-surround motions editing read-only buffer
(preview-only)
2024-04-11 18:19:49 -06:00
CharlesChen0823
3ab9700155
Windows: Add missing delete key (#10422)
Add miss delete key in windows platform.
Release Notes:

- N/A
2024-04-11 16:20:28 -07:00
Mikayla Maki
9d96ae6e78
Redo linux state again (#10452)
With the recent Linux rewrite, I attempted to simplify the number of
wrapper structs involved in the Linux code, following the macOS code as
an example. Unfortunately, I missed a vital component: pointers to the
platform state, held by platform data structures. As we hold all of the
platform data structures on Linux, this PR reintroduces a wrapper around
the internal state of both the platform and the window. This allows us
to close and drop windows correctly.

This PR also fixes a performance problem introduced by:
https://github.com/zed-industries/zed/pull/10343, where each configure
request would add a new frame callback quickly saturating the main
thread and slowing everything down.

Release Notes:
- N/A
2024-04-11 16:12:14 -07:00
Max Brunsfeld
8d7f5eab79
Extract Ocaml language support into an extension (#10450)
Release Notes:

- Extracted Ocaml language support into an extension

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 15:20:19 -07:00
Conrad Irwin
f6c85b28d5
WIP: remoting (#10085)
Release Notes:

- Added private alpha support for remote development. Please reach out to hi@zed.dev if you'd like to be part of shaping this feature.
2024-04-11 15:36:35 -06:00
Bennet Bo Fenner
ea4419076e
Add preview tabs (#9125)
This PR implements the preview tabs feature from VSCode.
More details and thanks for the head start of the implementation here
#6782.

Here is what I have observed from using the vscode implementation ([x]
-> already implemented):
- [x] Single click on project file opens tab as preview
- [x] Double click on item in project panel opens tab as permanent
- [x] Double click on the tab makes it permanent
- [x] Navigating away from the tab makes the tab permanent and the new
tab is shown as preview (e.g. GoToReference)
- [x] Existing preview tab is reused when opening a new tab
- [x] Dragging tab to the same/another panel makes the tab permanent
- [x] Opening a tab from the file finder makes the tab permanent
- [x] Editing a preview tab will make the tab permanent
- [x] Using the space key in the project panel opens the tab as preview
- [x] Handle navigation history correctly (restore a preview tab as
preview as well)
- [x] Restore preview tabs after restarting
- [x] Support opening files from file finder in preview mode (vscode:
"Enable Preview From Quick Open")
 
I need to do some more testing of the vscode implementation, there might
be other behaviors/workflows which im not aware of that open an item as
preview/make them permanent.

Showcase:


https://github.com/zed-industries/zed/assets/53836821/9be16515-c740-4905-bea1-88871112ef86


TODOs
- [x] Provide `enable_preview_tabs` setting
- [x] Write some tests
- [x] How should we handle this in collaboration mode (have not tested
the behavior so far)
- [x] Keyboard driven usage (probably need workspace commands)
- [x] Register `TogglePreviewTab` only when setting enabled?
- [x] Render preview tabs in tab switcher as italic
- [x] Render preview tabs in image viewer as italic
- [x] Should this be enabled by default (it is the default behavior in
VSCode)?
- [x] Docs

Future improvements (out of scope for now):
- Support preview mode for find all references and possibly other
multibuffers (VSCode: "Enable Preview From Code Navigation")


Release Notes:

- Added preview tabs
([#4922](https://github.com/zed-industries/zed/issues/4922)).

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-04-11 23:09:12 +02:00
Kyle Kelley
edb1ea2433
Do not show image viewer for SVGs (#10435)
Absent some ability to toggle between viewing and editing a file, I
think it would be best to get a fix out quick for people to edit SVGs as
text files.

Release Notes:

- Fixed editing of SVG images by disabling it from the image viewer
([#10403](https://github.com/zed-industries/zed/issues/10403)).
2024-04-11 13:27:32 -07:00
Marshall Bowers
86aa352ad9
Remove leftover commented-out code (#10445)
This PR removes some commented-out code that was left over from #10430.

Release Notes:

- N/A
2024-04-11 16:08:27 -04:00
Max Brunsfeld
253aa28375
Extract Scheme and Racket language support into extensions (#10442)
Release Notes:

- Extracted Scheme and Racket language support into extensions.

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 12:45:46 -07:00
Piotr Osiewicz
165d6b9edb
task: Fix variable substitution for free variables (#10434)
Fixes regression from https://github.com/zed-industries/zed/pull/10341
where it was not possible to use non-zed environmental variables (e.g.
$PATH) in task definitions.

No release note, as this didn't land on Preview yet.
Release Notes:

- N/A
2024-04-11 21:15:33 +02:00
Max Brunsfeld
0ac31302d3
Remove built-in Nix support (#10439)
Release Notes:

- Removed built-in Nix support, now that there is a Nix extension.

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 11:44:08 -07:00
Max Brunsfeld
176f440158
Extract lua language support into an extension (#10437)
Release Notes:

- Extracted lua language support into an extension, and improved Lua
highlighting and completion label styling.

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 11:32:10 -07:00
Max Brunsfeld
c38f72d194
Extract GLSL language support into an extension (#10433)
Release Notes:

- Extracted GLSL language support into an extension.

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-11 13:52:10 -04:00
Max Brunsfeld
47f698d5a3
Validate content-length of downloaded extension tar gz files (#10430)
Release Notes:

- Fixed a bug where extension installation would appear to succeed even
if the download did not complete due to network interruptions
([#10330](https://github.com/zed-industries/zed/issues/10330)).

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 10:24:09 -07:00
Max Brunsfeld
bcd2ca6196
Extract Elm language into an extension (#10432)
Release Notes:

- Extracted Elm language support into an extension

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 10:23:49 -07:00
Bennet Bo Fenner
78d6beee80
Fix invisible chat icons (#10406)
As of #10393 some icons in the chat were invisible, looking at the icons
I noticed that the viewport was actually 800x800, I scaled that down to
16x16 and now they work fine again.

Also remove the `reply_arrow_left` icon because it is not used at all.

Thanks to @RemcoSmitsDev for noticing.

I don't have any expertise in svg's, so if something is off about the
svg markup reach out to me.

Release Notes:

- N/A
2024-04-11 18:36:58 +02:00
Nate Butler
837b7111b3
Update TextField (#10415)
This PR makes some simple updates to the TextField api and update it's
styling.

Release Notes:

- N/A
2024-04-11 10:03:36 -04:00
Piotr Osiewicz
ea165e134d
gpui-macros: Hide autogenerated action types/functions (#10417)
I've found it a bit annoying that autogenerated code shows up in
completions when working on Zed, so I've moved them into an associated
function of a struct we're "implementing" Action on. That way, neither a
generated function nor a static show up in completions.

Note that this change only affects Zed codebase! I'm pushing it up right
after last Preview to give it some time on Nightly.
Before:

![image](https://github.com/zed-industries/zed/assets/24362066/7343201f-f05b-4342-a9f7-97f002d88a48)

![image](https://github.com/zed-industries/zed/assets/24362066/e67f9dcb-e090-40e0-873c-e51bd39e0c7e)

After:

![image](https://github.com/zed-industries/zed/assets/24362066/0704211a-73f5-4f12-8583-9e47f092e5b7)

![image](https://github.com/zed-industries/zed/assets/24362066/c6fa00f5-fd8f-4f06-8be7-b74acedccd7c)


Release Notes:

- N/A
2024-04-11 15:38:47 +02:00
Piotr Osiewicz
2f616fe8eb
workspace: Add restore_on_startup setting that allows always opening an empty Zed instance (#10366)
Fixes #7694
The new setting accepts "last_workspace" (default) and "none" as
options.

In a follow-up PR I'll add a new option that re-launches all of the Zed
windows and not just the last one.

Release Notes:

- Added `restore_on_startup` option, accepting `last_workspace`
(default) and `none` options. With `none`, new Zed instances will not
restore workspaces that were open last.
2024-04-11 13:27:27 +02:00
Bennet Bo Fenner
fef0516f5b
markdown preview: Allow toggling checkbox by click (#10364)
Release Notes:

- Added support for toggling a checkbox in markdown preview by clicking
on it (cmd+click)
([#5226](https://github.com/zed-industries/zed/issues/5226)).

---------

Co-authored-by: Remco Smits <62463826+RemcoSmitsDev@users.noreply.github.com>
2024-04-11 13:09:21 +02:00
Joseph T. Lyons
eb6f7c1240
Remove if-not-else patterns (#10402) 2024-04-11 03:48:06 -04:00
Remco Smits
36a87d0f5c
Add allow to click on the reply preview to go to the message (#10357)
Release Notes:

- Added support for scrolling to the message you are replying to when
clicking on the reply preview
([#10028](https://github.com/zed-industries/zed/issues/10028)).

Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
2024-04-11 09:36:00 +02:00
Conrad Irwin
3b68665277
Update resvg to fix panic (#10393)
This bumps us up a *long* way on the resvg/usvg crate, to fix a panic

Release Notes:

- Fixed a panic when rendering certain malformed SVGs
2024-04-10 20:12:05 -06:00
Mehmet Efe Akça
339b29ef17
Add open vim keymap command (#9953)
Release Notes:

- Added a `vim: open default keymap` command to show the default Vim
keymap ([#8593](https://github.com/zed-industries/zed/issues/8593)).

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-10 19:03:13 -04:00
Kirill Bulatov
d1ad96782c
Rework task modal (#10341)
New list (used tasks are above the separator line, sorted by the usage
recency), then all language tasks, then project-local and global tasks
are listed.
Note that there are two test tasks (for `test_name_1` and `test_name_2`
functions) that are created from the same task template:
<img width="563" alt="Screenshot 2024-04-10 at 01 00 46"
src="https://github.com/zed-industries/zed/assets/2690773/7455a82f-2af2-47bf-99bd-d9c5a36e64ab">

Tasks are deduplicated by labels, with the used tasks left in case of
the conflict with the new tasks from the template:
<img width="555" alt="Screenshot 2024-04-10 at 01 01 06"
src="https://github.com/zed-industries/zed/assets/2690773/8f5a249e-abec-46ef-a991-08c6d0348648">

Regular recent tasks can be now removed too:
<img width="565" alt="Screenshot 2024-04-10 at 01 00 55"
src="https://github.com/zed-industries/zed/assets/2690773/0976b8fe-b5d7-4d2a-953d-1d8b1f216192">

When the caret is in the place where no function symbol could be
retrieved, no cargo tests for function are listed in tasks:
<img width="556" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/df30feba-fe27-4645-8be9-02afc70f02da">


Part of https://github.com/zed-industries/zed/issues/10132
Reworks the task code to simplify it and enable proper task labels.

* removes `trait Task`, renames `Definition` into `TaskTemplate` and use
that instead of `Arc<dyn Task>` everywhere
* implement more generic `TaskId` generation that depends on the
`TaskContext` and `TaskTemplate`
* remove `TaskId` out of the template and only create it after
"resolving" the template into the `ResolvedTask`: this way, task
templates, task state (`TaskContext`) and task "result" (resolved state)
are clearly separated and are not mixed
* implement the logic for filtering out non-related language tasks and
tasks that have non-resolved Zed task variables
* rework Zed template-vs-resolved-task display in modal: now all reruns
and recently used tasks are resolved tasks with "fixed" context (unless
configured otherwise in the task json) that are always shown, and Zed
can add on top tasks with different context that are derived from the
same template as the used, resolved tasks
* sort the tasks list better, showing more specific and least recently
used tasks higher
* shows a separator between used and unused tasks, allow removing the
used tasks same as the oneshot ones
* remote the Oneshot task source as redundant: all oneshot tasks are now
stored in the inventory's history
* when reusing the tasks as query in the modal, paste the expanded task
label now, show trimmed resolved label in the modal
* adjusts Rust and Elixir task labels to be more descriptive and closer
to bash scripts

Release Notes:

- Improved task modal ordering, run and deletion capabilities
2024-04-11 02:02:04 +03:00
Jonathan Green
b0eda77d73
Add a few tests to cover other folder names (#10356)
Added additional tests to cover other folder names in regards to
[#10193](https://github.com/zed-industries/zed/issues/10193) and
[#9729](https://github.com/zed-industries/zed/issues/9729).

I had a similar issue but with folder names like '2.5' and '2.5_backup'.
I didn't see test coverage for those kinds of file names, so wanted to
add them.

![2024-04-10 09 07
03](https://github.com/zed-industries/zed/assets/127535196/eef26ce2-b0c7-4b1f-98ed-426ce1df0af2)

Release Notes:

- N/A

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-10 18:47:53 -04:00
Kirill Bulatov
fd3ee5a9d0
Use proper Workspace references when querying for tasks by name (#10383)
Closes https://github.com/zed-industries/zed/issues/10380

Release Notes:

- Fixed Zed panicking when running tasks via a keybinding
([10380](https://github.com/zed-industries/zed/issues/10380))
2024-04-11 00:42:17 +03:00
Marshall Bowers
8cbdd9e0fa
Refactor workspace notifications to use explicit NotificationId type (#10342)
This PR reworks the way workspace notifications are identified to use a
new `NotificationId` type.

A `NotificationId` is bound to a given type that is used as a unique
identifier. Generally this will be a unit struct that can be used to
uniquely identify this notification.

A `NotificationId` can also accept an optional `ElementId` in order to
distinguish between different notifications of the same type.

This system avoids the issue we had previously of selecting `usize` IDs
somewhat arbitrarily and running the risk of having two independent
notifications collide (and thus interfere with each other).

This also fixes a bug where multiple suggestion notifications for the
same extension could be live at once

Fixes https://github.com/zed-industries/zed/issues/10320.

Release Notes:

- Fixed a bug where multiple extension suggestions for the same
extension could be shown at once
([#10320](https://github.com/zed-industries/zed/issues/10320)).

---------

Co-authored-by: Max <max@zed.dev>
2024-04-10 17:21:23 -04:00
Joel Selvaraj
322f68f3d6
linux: wayland: fix cursor set_icon (#10374)
Release Notes:

- Partially (Wayland implementation) Fixed
[#10124](https://github.com/zed-industries/zed/issues/10124)).

The recent refactor of the linux gpui implementation
(https://github.com/zed-industries/zed/pull/10227) broke the wayland
cursor update logic by setting the cursor icon as `None`. Fix it by
setting the `cursor_icon_name`.
2024-04-10 12:59:33 -07:00
张小白
fdddbfc179
Fix caret movement issue for some special characters (#10198)
Currently in Zed, certain characters require pressing the key twice to
move the caret through that character. For example: "❤️" and "y̆".

The reason for this is as follows:

Currently, Zed uses `chars` to distinguish different characters, and
calling `chars` on `y̆` will yield two `char` values: `y` and `\u{306}`,
and calling `chars` on `❤️` will yield two `char` values: `❤` and
`\u{fe0f}`.

Therefore, consider the following scenario (where ^ represents the
caret):

- what we see: ❤️ ^
- the actual buffer: ❤ \u{fe0f} ^

After pressing the left arrow key once:

- what we see: ❤️ ^
- the actual buffer: ❤ ^ \u{fe0f}

After pressing the left arrow key again:
- what we see: ^ ❤️
- the actual buffer: ^ ❤ \u{fe0f}

Thus, two left arrow key presses are needed to move the caret, and this
PR fixes this bug (or this is actually a feature?).

I have tried to keep the scope of code modifications as minimal as
possible. In this PR, Zed handles such characters as follows:

- what we see: ❤️ ^
- the actual buffer: ❤ \u{fe0f} ^

After pressing the left arrow key once:

- what we see: ^ ❤️
- the actual buffer: ^ ❤ \u{fe0f}

Or after pressing the delete key:

- what we see: ^
- the actual buffer: ^

Please note that currently, different platforms and software handle
these special characters differently, and even the same software may
handle these characters differently in different situations. For
example, in my testing on Chrome on macOS, GitHub treats `y̆` as a
single character, just like in this PR; however, in Rust Playground,
`y̆` is treated as two characters, and pressing the delete key does not
delete the entire `y̆` character, but instead deletes `\u{306}` to yield
the character `y`. And they both treat `❤️` as a single character,
pressing the delete key will delete the entire `❤️` character.

This PR is based on the principle of making changes with the smallest
impact on the code, and I think that deleting the entire character with
the delete key is more intuitive.

Release Notes:

- Fix caret movement issue for some special characters

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
2024-04-10 13:01:25 -06:00
张小白
3648d79ddb
Reduce the frequency writing window size and position information to the database (#10315)
Release Notes:

- N/A
2024-04-10 12:56:51 -06:00
Marshall Bowers
081e9b9a60
Fix panic when loading malformed Wasm files (#10370)
This PR fixes a potential panic that could occur when loading malformed
Wasm files.

We now use the `parse_wasm_extension_version` function that was
previously used just to extract the Zed extension API version from the
Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm
file here instead of returning as soon as we find the version, the
invalid Wasm bytes are now surfaced as an `Err` instead of a panic.

We were able to replicate the panic using the following test:

```rs
#[gpui::test]
async fn test_bad_wasm(cx: &mut TestAppContext) {
    init_test(cx);

    let wasm_host = cx.update(|cx| {
        WasmHost::new(
            FakeFs::new(cx.background_executor().clone()),
            FakeHttpClient::with_200_response(),
            FakeNodeRuntime::new(),
            Arc::new(LanguageRegistry::test(cx.background_executor().clone())),
            PathBuf::from("/the/work/dir".to_string()),
            cx,
        )
    });

    let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap();

    // This is the error message we were seeing in the stack trace:
    // range end index 267037 out of range for slice of length 253952

    dbg!(&wasm_bytes.len());

    // Truncate the bytes to the same point:
    wasm_bytes.truncate(253952);

    std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap();

    let manifest = Arc::new(ExtensionManifest {
        id: "the-extension".into(),
        name: "The Extension".into(),
        version: "0.0.1".into(),
        schema_version: SchemaVersion(1),
        description: Default::default(),
        repository: Default::default(),
        authors: Default::default(),
        lib: LibManifestEntry {
            kind: None,
            version: None,
        },
        themes: Default::default(),
        languages: Default::default(),
        grammars: Default::default(),
        language_servers: Default::default(),
    });

    // 💥
    let result = wasm_host
        .load_extension(wasm_bytes, manifest, cx.executor())
        .await;
    dbg!(result.map(|_| ()));
```



Release Notes:

- Fixed a crash that could occur when loading malformed Wasm extensions
([#10352](https://github.com/zed-industries/zed/issues/10352)).

---------

Co-authored-by: Max <max@zed.dev>
2024-04-10 14:13:43 -04:00
Nate Butler
03d853d344
Introduce TextField by adding the ui_text_field crate (#10361)
There hasn't been a componentized way to create inputs or text fields
thus far due to the innate circular dependency between the `ui` and
`editor` crates. To bypass this issue we are introducing a new
`ui_text_field` crate to specifically handle this component.

`TextField` provides the ability to add stacked or inline labels, as
well as applies a standard visual style to inputs.

Example:

![CleanShot - 2024-04-10 at 11 22
13@2x](https://github.com/zed-industries/zed/assets/1714999/9bf5fc40-5024-4d01-9a8b-fb76f67d7e6e)

We'll continue to evolve this component in the near future and start
using it in the app once we've built out the needed functionality.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-10 11:53:25 -04:00
Joseph T. Lyons
d03f1c4cab v0.132.x dev 2024-04-10 11:45:05 -04:00
Conrad Irwin
fc10201ce2
Remove occasionally incorrect expectation (#10358)
This panic has occured a handful of times, I think it must be the case
that:

1. Item is dropped outside of an update loop
2. The next update is this one

In that case no flush effects will have called the release observers
yet, but we cannot upgrade the WeakModel because the ref count is 0



Release Notes:

- Fixed a (rare) panic while collaborating
2024-04-10 11:34:54 -04:00
Nathan Sobo
7abb63cfda
Improve the ergonomics of creating local buffers (#10347)
This PR renames `language::Buffer::new` to `language::Buffer::local` and
simplifies its interface. Instead of taking a replica id (which should
always be 0 for the local case) and a `BufferId`, which was awkward and
verbose to construct, it simply takes text and a `cx`.

It uses the `cx` to derive a `BufferId` from the `EntityId` associated
with the `cx`, which should always be positive based on the following
analysis...

We convert the entity id to a u64 using this method on `EntityId`, which
is defined by macros in the `slotmap` crate:

```rust
    pub fn as_ffi(self) -> u64 {
        (u64::from(self.version.get()) << 32) | u64::from(self.idx)
    }
```

If you look at the type of `version` in `KeyData`, it is non-zero:

```rust
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KeyData {
    idx: u32,
    version: NonZeroU32,
}
```

This commit also adds `Context::reserve_model` and
`Context::insert_model` to determine a model's entity ID before it is
created, which we need in order to assign a `BufferId` in the background
when loading a buffer asynchronously.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-04-10 08:32:51 -06:00
Hans
664efef76b
Remove line breaks when displaying file names in the project panel (#10231)
- Fixed #8603 

For the label title of the project panel, I find that there is no place
to use to get the title of the label to do some operations, it should be
safe to modify it, but I'm not sure how we need to modify the problem, I
can think of two scenarios:
1. Modify every place where you don't want multiple lines to appear
2. Make the label only display a single line (e.g. provide a new
parameter, or a new label type?)
2024-04-10 08:30:13 -06:00
Bennet Bo Fenner
26299fb8c9
chat panel: Fix new messages indicator appearing when message was deleted (#10278)
Release Notes:

Fixed an issue where the "New messages" indicator in the channel chat
would be shown even if the message was deleted
2024-04-10 12:21:45 +02:00
Piotr Osiewicz
39e0e26d1d
Line numbers short mode (#10354)
Followup to #10327 
It can be enabled with the following setting:

"line_indicator_format": "short"

No release note, as the original change didn't go out to Preview yet.

/cc @bartekpacia @0x2CA

Release Notes:

- N/A
2024-04-10 12:08:07 +02:00
Kamal Ahmad
4151ba13a1
X11: Don't emit keypress events for modifiers (#10271)
This fixes certain shortcuts/motions on X11 like in vim mode "v i )",
where previously zed would interpret it as "v i SHIFT )" due to the x11
backend emitting key press events for modifier keys even though other
platforms like Wayland don't. This also adds support for
ModifiersChanged events to X11

Release Notes:

- Fixed vim motions like "v i )" not working on X11
([#10199](https://github.com/zed-industries/zed/issues/10199)).
2024-04-09 18:46:23 -07:00
CharlesChen0823
6ac343123d
Windows: Fix render resource not being released (#10233)
Release Notes:
- N/A
2024-04-09 18:46:09 -07:00
张小白
c763c8c64b
windows: Implement restart action (#10234)
Release Notes:

- N/A
2024-04-09 18:35:10 -07:00
Ezekiel Warren
bfd9bb8a7c
Use shared text system on Linux and Windows (#10098)
closes #10129
closes #10269

Release Notes:

- N/A
2024-04-09 17:25:16 -07:00
Dzmitry Malyshau
8f69eac402
Update blade to a version that can run GLES for Zed (#10243)
Release Notes:
- N/A

Picks up https://github.com/kvark/blade/pull/105,
https://github.com/kvark/blade/pull/97, and more

Switches the presentation to be non-blocking, which will improve the
latency slightly.

Allows to start playing with GLES backend, e.g.
```bash
cd crates/gpui
RUSTFLAGS="--cfg gles" CARGO_TARGET_DIR=./target-gl cargo run --example hello_world
```

It doesn't currently render properly due to an issue that needs
investigation, see
https://github.com/kvark/blade/pull/105#issuecomment-2041006542
But at least it's a start

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-04-09 17:16:35 -07:00
Mikayla Maki
3fc08a0610
Fix a bug from the Linux rewrite where Wayland windows would not render properly (#10343)
Release Notes:

- N/A
2024-04-09 17:16:09 -07:00
Piotr Osiewicz
fff197b227
Show lines selected & selection quantity in status bar (#10327)
Fixes #4204 

![image](https://github.com/zed-industries/zed/assets/24362066/dac093e7-d8ba-4bf9-8936-748a93dbcecf)

![image](https://github.com/zed-industries/zed/assets/24362066/f836948c-a4ad-455c-a343-8bb3ce62d467)

![image](https://github.com/zed-industries/zed/assets/24362066/54310b2a-db00-4b87-9f96-a55a81be99ed)

![image](https://github.com/zed-industries/zed/assets/24362066/dd6ef78c-2bde-4808-856b-adaa28dd00d2)

Release Notes:

- Line number indicator now shows number of lines selected and a number
of selections.
2024-04-09 23:40:19 +02:00
Max Brunsfeld
6b320b9efe
Fix cleanup of LSP request status messages (#10336)
This fixes a bug in https://github.com/zed-industries/zed/pull/9818,
where the status was not removed if the request failed. It also adds
replication of these new status messages to guests when collaborating.

Release Notes:

- Fixed an issue where the status of failed LSP actions was left in the
status bar

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-09 17:34:51 -04:00
Max Brunsfeld
a0ee29a806
Use first line comment prefix when toggling comments (#10335)
This fixed an issue introduced in
https://github.com/zed-industries/zed/pull/10126, where, when toggling
comments in a language with multiple line comment prefixes (e.g. Gleam,
Erlang) Zed would insert the *last* prefix instead of the first.

Release Notes:

- Fixed an issue where the `toggle comments` command inserted the wrong
line comment prefix in some languages (preview only).

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-09 17:22:47 -04:00
Kirill Bulatov
0331fdebd3
Parse human readable module name for Rust tasks (#10337)
Part of https://github.com/zed-industries/zed/issues/10132 extracted out
of a bigger PR that refactors tasks and shows labels that look more like
commands (ergo needs better readable package names)

Release Notes:

- N/A
2024-04-10 00:18:09 +03:00
Kirill Bulatov
7dfc7184b1
Use task icons for all kinds of tasks (#10333)
<img width="565" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/cbb59154-1153-459a-978c-8c125e879d27">
<img width="562" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/d3f65a09-2f75-4db8-85c2-1abb591e609c">


Release Notes:

- Added more icons to task modal
2024-04-09 23:51:59 +03:00
Conrad Irwin
759c65d4bd
Show errors when failing to create directories on startup (#10326)
Release Notes:

- Improved error reporting on startup
([#9036](https://github.com/zed-industries/zed/issues/9036)).
2024-04-09 13:26:16 -06:00
Thorsten Ball
0533923f91
Reduce memory usage to represent buffers by up to 50% (#10321)
This should help with some of the memory problems reported in
https://github.com/zed-industries/zed/issues/8436, especially the ones
related to large files (see:
https://github.com/zed-industries/zed/issues/8436#issuecomment2037442695),
by **reducing the memory required to represent a buffer in Zed by
~50%.**

### How?

Zed's memory consumption is dominated by the in-memory representation of
buffer contents.

On the lowest level, the buffer is represented as a
[Rope](https://en.wikipedia.org/wiki/Rope_(data_structure)) and that's
where the most memory is used. The layers above — buffer, syntax map,
fold map, display map, ... — basically use "no memory" compared to the
Rope.

Zed's `Rope` data structure is itself implemented as [a `SumTree` of
`Chunks`](8205c52d2b/crates/rope/src/rope.rs (L35-L38)).

An important constant at play here is `CHUNK_BASE`:

`CHUNK_BASE` is the maximum length of a single text `Chunk` in the
`SumTree` underlying the `Rope`. In other words: It determines into how
many pieces a given buffer is split up.

By changing `CHUNK_BASE` we can adjust the level of granularity
withwhich we index a given piece of text. Theoretical maximum is the
length of the text, theoretical minimum is 1. Sweet spot is somewhere
inbetween, where memory use and performance of write & read access are
optimal.

We started with `16` as the `CHUNK_BASE`, but that wasn't the result of
extensive benchmarks, more the first reasonable number that came to
mind.

### What

This changes `CHUNK_BASE` from `16` to `64`. That reduces the memory
usage, trading it in for slight reduction in performance in certain
benchmarks.

### Benchmarks

I added a benchmark suite for `Rope` to determine whether we'd regress
in performance as `CHUNK_BASE` goes up. I went from `16` to `32` and
then to `64`. While `32` increased performance and reduced memory usage,
`64` had one slight drop in performance, increases in other benchmarks
and substantial memory savings.

| `CHUNK_BASE` from `16` to `32` | `CHUNK_BASE` from `16` to `64` |
|-------------------|--------------------|
|
![chunk_base_16_to_32](https://github.com/zed-industries/zed/assets/1185253/fcf1f9c6-4f43-4e44-8ef5-29c1e5d8e2b9)
|
![chunk_base_16_to_64](https://github.com/zed-industries/zed/assets/1185253/d82a0478-eeef-43d0-9240-e0aa9df8d946)
|

### Real World Results

We tested this by loading a 138 MB `*.tex` file (parsed as plain text)
into Zed and measuring in `Instruments.app` the allocation.

#### standard allocator
Before, with `CHUNK_BASE: 16`, the memory usage was ~827MB after loading
the buffer.

| `CHUNK_BASE: 16` |
|---------------------|
|
![memory_consumption_chunk_base_16_std_alloc](https://github.com/zed-industries/zed/assets/1185253/c1e04c34-7d1a-49fa-bb3c-6ad10aec6e26)
|


After, with `CHUNK_BASE: 64`, the memory usage was ~396MB after loading
the buffer.

| `CHUNK_BASE: 64` |
|---------------------|
|
![memory_consumption_chunk_base_64_std_alloc](https://github.com/zed-industries/zed/assets/1185253/c728e134-1846-467f-b20f-114a582c7b5a)
|


#### `mimalloc`

`MiMalloc` by default and that seems to be pretty aggressive when it
comes to growing memory. Whereas the std allocator would go up to
~800mb, MiMalloc would jump straight to 1024MB.

I also can't get `MiMalloc` to work properly with `Instruments.app` (it
always shows 15MB of memory usage) so I had to use these `Activity
Monitor` screenshots:

| `CHUNK_BASE: 16` |
|---------------------|
|
![memory_consumption_chunk_base_16_mimalloc](https://github.com/zed-industries/zed/assets/1185253/1e6e05e9-80c2-4ec7-9b0e-8a6fa78836eb)
|

| `CHUNK_BASE: 64` |
|---------------------|
|
![memory_consumption_chunk_base_64_mimalloc](https://github.com/zed-industries/zed/assets/1185253/8a47e982-a675-4db0-b690-d60f1ff9acc8)
|

### Release Notes

Release Notes:

- Reduced memory usage for files by up to 50%.

---------

Co-authored-by: Antonio <antonio@zed.dev>
2024-04-09 18:07:53 +02:00
Marshall Bowers
132b8aa5c7
Improve extension API documentation (#10322)
This PR adds some more documentation to symbols exported from the
`zed_extension_api` crate.

Release Notes:

- N/A
2024-04-09 10:38:29 -04:00
Nathan Sobo
414058379b
Switch to the system UI font on macOS (#10317)
To reference the system font, use the special ".SystemUIFont" family
name.

/cc @PixelJanitor 

Release Notes:

- Switched to the system UI  font for user interface elements on macOS.

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
2024-04-09 07:44:57 -06:00
Marshall Bowers
8205c52d2b
Only apply host-side executable fix to binaries downloaded by the extension (#10318)
This PR makes it so our temporary host-side workaround for setting
certain language server binaries as executable only applies to binaries
that are downloaded by the extension.

Previously we would do this for any binary, including ones that could
have been sourced from the $PATH.

Release Notes:

- Fixed a file permissions issue when trying to use a Zig language
server (`zls`) present on the $PATH.
2024-04-09 09:13:36 -04:00
Piotr Osiewicz
4fb9f41e69
gpui/metal: Clamp max texture width/height to 16kB (#10314)
Fixed #10149
A user had Zed crash due to invalid font size in settings. It turned out
the width/height of glyphs does not pass validation in Metal texture
initialization with a large enough font size.

All modern Macs have a max texture width/height of 16kB (barring Apple
A8, used by iPhone 6 back in 2014, which uses 8kB). This commit clamps
texture size at 16kB. Note that while it fixes Zed crash, using a font
size that hits the limit is still pretty unusable - the users will still
have a pretty unusable editor, but at least it won't crash for them.



Release Notes:

- Fixed crashes with huge `buffer_font_size` values.
2024-04-09 14:09:09 +02:00
Andrew Lygin
935e0d547e
Improve Find/Replace shortcuts (#10297)
This PR changes ways the Find/Replace functionality in the
Buffer/Project Search is accessible via shortcuts. It makes those panels
work the same way as in VS Code and Sublime Text.

The details are described in the issue: [Make Find/Replace easier to
use](https://github.com/zed-industries/zed/issues/9142)

There's a difficulty with the Linux keybindings:

VS Code uses on MacOS (this PR replicates it):

| Action | Buffer Search | Project Search |
| --- | --- | --- |
| Find | `cmd-f` | `cmd-shift-f` |
| Replace | `cmd-alt-f` | `cmd-shift-h` |

VS Code uses on Linux (this PR replicates all but one):

| Action | Buffer Search | Project Search |
| --- | --- | --- |
| Find | `ctrl-f` | `ctrl-shift-f` |
| Replace | `ctrl-h`  | `ctrl-shift-h` |

The problem is that `ctrl-h` is already taken by the `editor::Backspace`
action in Zed on Linux.

There's two options here:

1. Change keybinding for `editor::Backspace` on Linux to something else,
and use `ctrl-h` for the "replace in buffer" action.
2. Use some other keybinding on Linux in Zed. This PR introduces
`ctrl-r` for this purpose, though I'm not sure it's the best choice.

What do you think?

fixes #9142

Release Notes:

- Improved access to "Find/Replace in Buffer" and "Find/Replace in
Files" via shortcuts (#9142).

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

- N/A
2024-04-08 22:07:59 -07:00
Max Brunsfeld
cc367d43d6
Sanitize ranges in code labels coming from extensions (#10307)
Without any sanitization, extensions would be able to crash zed, because
the editor code assumes these ranges are valid.

Release Notes:

- N/A
2024-04-08 19:53:25 -07:00
Marshall Bowers
843aad80c6
Flip the optionality of the auto_update setting (#10302)
This PR flips the optionality of the `AutoUpdateSettingContent` to make
it a bit easier to work with.

#### Before

```rs
struct AutoUpdateSettingContent(Option<bool>);

type FileContent = AutoUpdateSettingContent;
```

#### After

```rs
struct AutoUpdateSettingContent(bool);

type FileContent = Option<AutoUpdateSettingContent>;
```

Release Notes:

- N/A
2024-04-08 20:16:05 -04:00
Mikayla Maki
def87a8d76
WIP: Refactor Linux platform implementation (#10227)
This puts the Linux platform implementation at a similar code style and
quality to the macOS platform. The largest change is that I collapsed
the `LinuxPlatform` -> `[Backend]` -> `[Backend]State` ->
`[Backend]StateInner` to just `[Backend]` and `[Backend]State`, and in
the process removed most of the `Rc`s and `RefCell`s.

TODO:
- [x] Make sure that this is on-par with the existing implementation
- [x] Review in detail, now that the large changes are done.
- [ ] Update the roadmap

Release Notes:

- N/A
2024-04-08 16:40:35 -07:00
Marshall Bowers
ee1642a50f
Fix broken loading of auto_update setting (#10301)
This PR fixes a panic when attempting to load the `auto_update` setting.

This was leftover from #10296.

I'm going to see if there's a better way we can handle these cases so
they're more obviously correct.

Release Notes:

- N/A
2024-04-08 19:30:47 -04:00
Marshall Bowers
7c5bc3c26f
Add the ability for extensions to provide language settings (#10296)
This PR adds the ability for extensions to provide certain language
settings via the language `config.toml`.

These settings are then merged in with the rest of the settings when the
language is loaded from the extension.

The language settings that are available are:

- `tab_size`
- `hard_tabs`
- `soft_wrap`

Additionally, for bundled languages we moved these settings out of the
`settings/default.json` and into their respective `config.toml`s .

For languages currently provided by extensions, we are leaving the
values in the `settings/default.json` temporarily until all released
versions of Zed are able to load these settings from the extension.

---

Along the way we ended up refactoring the `Settings::load` method
slightly, introducing a new `SettingsSources` struct to better convey
where the settings are being loaded from.

This makes it easier to load settings from specific locations/sets of
locations in an explicit way.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-08 19:17:12 -04:00
Kirill Bulatov
4a3032c5e5
Append -- --nocapture to Rust function-level tests (#10299)
Release Notes:

- N/A
2024-04-09 01:36:24 +03:00
Conrad Irwin
f327118e06
vim: Allow search with operators & visual mode (#10226)
Fixes: #4346

Release Notes:

- vim: Add search motions (`/,?,n,N,*,#`) in visual modes and as targets
for operators like `d`,`c`,`y`
([#4346](https://github.com/zed-industries/zed/issues/4346)).
2024-04-08 15:20:14 -06:00
joaquin30
f9bf60f017
vim: Fix cgn backwards movement when there is no matches (#10237)
Release Notes:

- Fixed `cgn` backwards movement problem in #9982

There are two issues:

- When there are no more matches, the next repetition still moves the
cursor to the left. After that, the recording is cleared. For this I
simply move the cursor to the right, but it doesn't work when the cursor
is at the end of the line.
- If `cgn` is used when there are no matches, it cleans the previous
recorded actions. Maybe there should be a way to revert the recording.
This also happens when using `c` and `esc`

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-04-08 14:51:36 -06:00
Hans
0390df27d4
Fix block cursor does not render italic for vim (#10249)
Release Notes:

- Fixed #8799
2024-04-08 14:50:50 -06:00
Mikayla Maki
cf5a113751
Don't panic when multiple Zed instances are open (#10295)
This stops an annoying panic that can occur when developing Zed 

Release Notes:

- N/A
2024-04-08 12:26:38 -07:00
Bennet Bo Fenner
7dccbd8e3b
markdown preview: Improve live preview (#10205)
This PR contains various improvements for the markdown preview (some of
which were originally part of #7601).
Some improvements can be seen in the video (see also release notes down
below):


https://github.com/zed-industries/zed/assets/53836821/93324ee8-d366-464a-9728-981eddbfdaf7

Release Notes:
- Added action to open markdown preview in the same pane
- Added support for displaying channel notes in markdown preview
- Added support for displaying the current active editor when opening
markdown preview
- Added support for scrolling the editor to the corresponding block when
double clicking an element in markdown preview
- Improved pane creation handling when opening markdown preview
- Fixed markdown preview displaying non-markdown files
2024-04-08 21:17:40 +02:00
Marshall Bowers
d009d84ead
Add support for using a language server with multiple languages (#10293)
This PR updates the `extension.toml` to allow specifying multiple
languages for a language server to work with.

The `languages` field takes precedence over `language`. In the future
the `language` field will be removed.

As part of this, the Emmet extension has been extended with support for
PHP and ERB.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-04-08 14:24:56 -04:00
Hans
5e44748677
Adjust string splitting function (#10221)
- Fixed #9729 and #10193

This commit fixes an issue where the string splitting function was
handling characters in the input string improperly. We adjusted the use
of the `take_while` function to calculate the length of the numeric
prefix, rather than directly splitting the string, thus correctly
splitting the string into a numeric prefix part and the remaining part
2024-04-08 11:05:03 -07:00
Mikayla Maki
d2bf80ca3d
Make search context larger (#10289)
This increases search context from 1 above, 2 below, to 2 above and 2
below, matching the Sublime Text search results.

Release Notes:

- Increased search result context from 3 lines to 4 lines
2024-04-08 10:57:36 -07:00
Hans
44aed4a0cb
Add surrounds support for vim (#9400)
For #4965

There are still some minor issues: 
1. When change the surround and delete the surround, we should also
decide whether there are spaces inside after deleting/replacing
according to whether it is open parentheses, and replace them
accordingly, but at present, delete and change, haven't done this
adaptation for current pr, I'm not sure if I can fit it in the back or
if it needs to be fitted together.
2. In the selection mode, pressing s plus brackets should also trigger
the Add Surrounds function, but this MR has not adapted the selection
mode for the time being, I think we need to support different add
behaviors for the three selection modes.(Currently in select mode, s is
used for Substitute)
3. For the current change surrounds, if the user does not find the
bracket that needs to be matched after entering cs, but it is a valid
bracket, and will wait for the second input before failing, the better
practice here should be to return to normal mode if the first bracket is
not found
4. I reused BracketPair in language, but two of its properties weren't
used in this mr, so I'm not sure if I should create a new struct with
only start and end, which would have less code

I'm not sure which ones need to be changed in the first issue, and which
ones can be revised in the future, and it seems that they can be solved

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-04-08 11:41:06 -06:00
Conrad Irwin
e826ef83e2
Fix panic in visual line mode with folds (#10284)
Fixes: #10266



Release Notes:

- Added/Fixed/Improved ...
([#<public_issue_number_if_exists>](https://github.com/zed-industries/zed/issues/<public_issue_number_if_exists>)).

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

**or**

- N/A
2024-04-08 11:39:06 -06:00
Marshall Bowers
56c0345cf3
Respect language server's capabilities when calling GetReferences (#10285)
This PR makes Zed respect the language server's capabilities when
calling the `GetReferences` command (used in "Find All References",
etc.).

This fixes a crash that could occur when using Zed with Gleam v1.0.

Release Notes:

- Made "Find All References" respect the language server's capabilities.
This fixes some instances where certain language servers would stop
working after receiving a "Find All References" request.

---------

Co-authored-by: Max <max@zed.dev>
2024-04-08 13:38:32 -04:00
Andrew Lygin
f1428fea4e
Make scrollbar a bit wider (#10248)
At the moment, the editor scrollbar is 12px wide. One pixel is allocated
for the left border, so we have 11 pixels to display markers. It's not
enough to make three even marker columns (git, highlights, diagnostics)
that fully fill the scrollbar, so the current implementation allocates 3
pixels to each column.

As the result, we have 2 spare pixels on the right (before #10080 they
were occupied by the diagnostics column). Making the scrollbar just one
pixel wider allows us to give one additional pixel to each marker column
and make markers more pronounced ("as is" on the left, "to be" on the
right):

<img width="115" alt="zed-scrollbar-markers-1px"
src="https://github.com/zed-industries/zed/assets/2101250/4bdf0107-c0f1-4c9c-9063-d2ff461e1c32">

Other options:
- Remove scrollbar thumb border. That'll give us one missing pixel to
make markers wide and even. I, personally, prefer this option, but
themes now have `scrollbar.thumb.border` colors that differ from
`scrollbar.thumb.background` for some reason. This theme setting becomes
deprecated in this case. For the reference: VS Code doesn't have
scrollbar slider borders, IntelliJ IDEA does have them.
- Don't try to make markers evenly wide. For instance, IntelliJ uses
very narrow git-diff markers that are separated from other markers. But
it requires much wider scrollbar (it's 20px in IDEA).
- Use the spare two pixels to make diagnostic markers wider (it's the
pre #10080 approach), or split them between the highlight and diagnostic
markers (have 3px+4px+4px marker columns).
- Do nothing. It leaves us with two unused pixels :(

Release Notes:

- N/A

Related Issues:

- The previous discussion:
https://github.com/zed-industries/zed/pull/9080#issuecomment-1997979968
2024-04-08 10:32:09 -07:00
Conrad Irwin
9b88259b1f
Fix panic in drag entered (#10277)
Co-Authored-By: Kirill <kirill@zed.dev>

Release Notes:

- Fixed panic when dragging into Zed.

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

**or**

- N/A

Co-authored-by: Kirill <kirill@zed.dev>
2024-04-08 11:18:10 -06:00
Thorsten Ball
4d68bf2fa6
Fix panic when deleting just-generated text (#10282)
We ran into a panic when deleting text that was just generated by a code
action.

This fixes it by ensuring we don't run into a 0-minus-1 panic when a
buffer_range is empty.

Release Notes:

- Fixed panic that could occur when deleting generated-by-unsaved text.

Co-authored-by: Conrad <conrad@zed.dev>
2024-04-08 17:59:25 +02:00
Thorsten Ball
87c282d8f1
Send along diagnostics when requesting code actions (#10281)
This fixes #10177 by sending along the correct diagnostics when querying
the language server for diagnostics for a given cursor location.

Turns out that `gopls` takes the `range`, `source`, `message` of the
diagnostics sent along to check whether it has any code actions for the
given location.

Release Notes:

- Fixed "quickfix" code actions that were based on diagnostics not
showing up in Go files.
([#10177](https://github.com/zed-industries/zed/issues/10177)).

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
2024-04-08 17:54:06 +02:00
Marshall Bowers
134decb75e
Add compatibility table between Zed and zed_extension_api versions (#10279)
This PR updates the README of the `zed_extension_api` crate to show the
compatibility between different versions of `zed_extension_api` and Zed.

Release Notes:

- N/A
2024-04-08 11:15:35 -04:00
Piotr Osiewicz
f0d4d71e97
pane: Always notify status bar items on Pane::Focused events (#10275)
Due to peculiarities in handling of terminal panes (namely the fact that
they are not actually tracked by the Workspace::active_pane member), it
was possible to get into a state where status bar items "lost track" of
an active pane item; one way to reproduce it was to open a new terminal
via "workspace: new terminal" with a pane open in a central view; once a
new terminal is opened, the language selector and line number indicator
lose track of an active item. Focusing central view does nothing - it
will only go away after switching a tab in the central view.

To remedy this, we now always notify the status bar items of a pane
focus change, even if Workspace::active_pane points to the same pane.

Release Notes:

- Fixed status bar focus issues when spawning a terminal via `workspace:
new terminal` action.
2024-04-08 17:03:25 +02:00
Mike Sun
bcdae9fefa
Add settings to hide/show navigation history buttons (#10240)
This is another variant for this [original
PR](https://github.com/zed-industries/zed/pull/10091) to add settings to
show/hide navigation history buttons that puts the settings under a new
section called `tab_bar`:

```
  "tab_bar": {
    // Whether or not to show the navigation history buttons.
    "show_nav_history_buttons": true
  }
```

<img width="314" alt="Screenshot 2024-04-02 at 3 00 53 PM"
src="https://github.com/zed-industries/zed/assets/1253505/23c4fa19-5a63-4160-b3b7-1b5e976c36bf">
<img width="329" alt="Screenshot 2024-04-02 at 3 01 03 PM"
src="https://github.com/zed-industries/zed/assets/1253505/64c2ebd2-9311-4589-a4e8-bd149c6c4ece">
2024-04-08 10:46:36 -04:00
Max Brunsfeld
4bdfc12b79
Remove duplicated code for unchanged parts of different extension API versions (#10218)
Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-08 10:16:12 -04:00
Piotr Osiewicz
4ce5b22989
tasks: Add status indicator to the status bar (#10267)
Release Notes:

- Added task status indicator to the status bar.
2024-04-08 14:43:00 +02:00
Ben Hamment
ce5bc399df
Improve Ruby Syntax (#10255)
Release Notes:

fixes #9995  being able to target constants
<img width="336" alt="image"
src="https://github.com/zed-industries/zed/assets/7274458/9e8cc438-10c4-441f-9140-3f4b418bd3bd">

Adds highlighting for parameters In blocks
<img width="318" alt="image"
src="https://github.com/zed-industries/zed/assets/7274458/4fa45fbe-104b-4778-994b-3b6d6ba930d4">
2024-04-08 13:12:24 +02:00
Piotr Osiewicz
4f9ad300a7
tasks: Use icons instead of secondary text in a modal (#10264)
Before:

![image](https://github.com/zed-industries/zed/assets/24362066/feae9c98-37d4-437d-965a-047d2e089a7b)
After:

![image](https://github.com/zed-industries/zed/assets/24362066/43e48985-5aba-44d9-9128-cfafb9b61fd4)

Release Notes:

- N/A
2024-04-08 11:41:54 +02:00
Daniel Zhu
4944dc9d78
Show status of LSP actions (#9818)
Fixes #4380

Parts im still unsure about:
- [x] where exactly I should call `on_lsp_start`/`on_lsp_end`
- [x] how to handle things better than `let is_references =
TypeId::of::<R>() == TypeId::of::<GetReferences>();`, which feels very
janky
- [x] I want to have the message be something like `"Finding references
to [...]"` instead of just `textDocument/references`, but I'm not sure
how to retrieve the name of the symbol that's being queried
- [ ] I think the bulk of the runtime is occupied by `let result =
language_server.request::<R::LspRequest>(lsp_params).await;`, but since
`ModelContext` isn't passed into it, I'm not sure how to update progress
from within that function
- [x] A good way to disambiguate between multiple calls to the same lsp
function; im currently using the function name itself as the unique
identifier for that request, which could create issues if multiple
`textDocument/references` requests are sent in parallel

Any help with these would be deeply appreciated!

Release Notes:

- Adds a status indicator for LSP actions

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-04-06 19:48:11 -07:00
Kyle Kelley
c7961b9054
Implement ObjectFit::ScaleDown for images (#10063)
While working towards fixes for the image viewer, @mikayla-maki and I
discovered that we didn't have `object-fit: scale-down` implemented.
This doesn't _fully_ solve the image issues as there is some issue where
only the bounds width is updating on layout change that I haven't fully
chased down.

Co-Authored-By: @mikayla-maki 

Release Notes:

- N/A

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-04-06 15:20:30 -07:00
Conrad Irwin
0325bda89a
Improve lsp notifications (#10220)
1. They now will not go off-screen
2. You can scroll long messages.
3. Only one notification per language server is shown at a time
4. The title/text are now distinguished visually
5. You can copy the error message to the clipboard

Fixes: #10217
Fixes: #10190
Fixes: #10090

Release Notes:

- Fixed language server notifications being too large
([#10090](https://github.com/zed-industries/zed/issues/10090)).
2024-04-06 10:17:18 -06:00
Mikayla Maki
518cfdbd56
Adjust env parsing to account for multiline env values (#10216)
fixes https://github.com/zed-industries/zed/issues/6012

Release Notes:

- N/A
2024-04-05 19:24:46 -07:00
joaquin30
bf9b443b4a
vim: Support gn command and remap gn to gl (#9982)
Release Notes:

- Resolves #4273

@algora-pbc /claim #4273

This is a work-in-progress. The process for `gn` command is:

- maintain updated vim.workspace_state.search.initial_query
- modify editor.select_next_state with
vim.workspace_state.search.initial_query
- use editor.select_next()
- merge selections
- set editor.select_next_state to previous state

To make this possible, several private members and editor structures are
made public. `gN` is not yet implemented and the cursor still does not
jump to the next selection in the first use.

Maybe there is an better way to do this?

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-04-05 20:23:37 -06:00
Mikayla Maki
fe4b345603
Fix interpretation of \n in hovers (#10214)
I ran into this specifically when looking at the documentation of
https://crates.io/crates/wayland-client

Release Notes:

- Fixed a bug where some hover popovers would render `\n` instead of a
new line.
2024-04-05 15:59:37 -07:00
Kirill Bulatov
7b636d9774
Limit the extension tasks in the modal to current language only (#10207)
Release Notes:

- N/A
2024-04-06 00:18:32 +03:00
Marshall Bowers
c851e6edba
Add language_server_workspace_configuration to extension API (#10212)
This PR adds the ability for extensions to implement
`language_server_workspace_configuration` to provide workspace
configuration to the language server.

We've used the Dart extension as a motivating example for this, pulling
it out into an extension in the process.

Release Notes:

- Removed built-in support for Dart, in favor of making it available as
an extension. The Dart extension will be suggested for download when you
open a `.dart` file.

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-05 17:04:07 -04:00
Marshall Bowers
4aaf3459c4
Improve extension API documentation (#10210)
This PR adds more documentation for various constructs in the
`zed_extension_api` crate.

`wit_bindgen` is able to generate doc comments on the Rust constructs
using the the doc comments in the WIT files, so we're able to leverage
that for the majority of the constructs that we expose.

Release Notes:

- N/A
2024-04-05 13:00:24 -04:00
Thorsten Ball
b05aa381aa
Handle old versions of /usr/bin/env when loading shell env (#10202)
This fixes #9786 by using an invocation of `/usr/bin/env` that's
supported by macOS 12.

As it turns out, on macOS 12 (and maybe 13?) `/usr/bin/env` doesn't
support the `-0` flag. In our case it would silently fail, since we
`exit 0` in our shell invocation and because the program we run and
whose exit code we check is the `$SHELL` and not `/usr/bin/env`.

What this change does is to drop the `-0` and instead split the
environment on `\n`. This works even if an environment variable contains
a newline character because that would then be escaped.

Release Notes:

- Fixed Zed not picking up shell environments correctly when running on
macOS 12. ([#9786](https://github.com/zed-industries/zed/issues/9786)).

Co-authored-by: Dave Smith <davesmithsemail@gmail.com>
2024-04-05 15:46:56 +02:00
Hans
ec6efe262f
Fix crash when joining two consecutive lines (#10000)
Release notes:

- Fixed a crash when joining two consecutive lines
([#9692](https://github.com/zed-industries/zed/pull/9692)).


This crash is not caused by `vim` or `editor`'s code logic, `join_line`
logic is okay, I found that the crash is caused by a refresh of git
`diff` after every update, hhen git diff generates hunks, it will look
for the cursor to the beginning of a line, and judge that if the cursor
result column is greater than 0, that is, it is not the beginning of a
line, it will correct the row to the next line, I think before we forgot
here that I need to adjust the column to 0 at the same time, otherwise
it is easy to go out of bounds, I am not sure if I need to add more
tests for this method, I can add if I need to, but I feel that this case
is a bit extreme

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-04-05 15:45:29 +02:00
Andrew Lygin
3ae6463869
Fix scrollbar markers in large files (#10181)
#10080 introduced a minor change in how the min marker height is
enforced. Before the change, it was applied to the aggregated marker,
but after the change it's applied to each individual marker before
aggregation.

The difference is not noticeable on small files, where even single row
markers are higher than `MIN_MARKER_HEIGHT`, but it leads to visible
differences in large files with repeating blocks of highlighted and
not-highlighted blocks, like in [this
case](https://github.com/zed-industries/zed/pull/9080#issuecomment-2006796376).

This PR fixes how the `MIN_MARKER_HEIGHT` is applied.

Before the fix:

<img width="727" alt="zed-scroll-markers-before"
src="https://github.com/zed-industries/zed/assets/2101250/a1c34746-af4f-4054-8de2-edabf3db7cee">

After the fix:

<img width="736" alt="zed-scroll-markers-after"
src="https://github.com/zed-industries/zed/assets/2101250/b9ee843d-055e-42a6-af26-e7fd4f7729f8">


Release Notes:

- N/A

/cc @mrnugget
2024-04-05 10:17:39 +02:00
Drazen
cedbfac844
Fix typo (#10183)
Release Notes:

- N/A
2024-04-05 01:07:19 +02:00
Conrad Irwin
73d8a43c81
vim: Allow : in empty panes and screen shares (#10171)
Release Notes:

- vim: Fixed `:` when no files are open
2024-04-04 14:24:49 -06:00
Marshall Bowers
4a325614f0
Add label_for_symbol to extension API (#10179)
This PR adds `label_for_symbol` to the extension API.

As a motivating example, we implemented `label_for_symbol` for the
Haskell extension.

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
2024-04-04 15:38:38 -04:00
Bennet Bo Fenner
5d88d9c0d7
markdown preview: Add link tooltips (#10161)
Adds tooltips to the markdown preview, similar to how its done for
`RichText`


https://github.com/zed-industries/zed/assets/53836821/523519d4-e392-46ef-9fe0-6692871b317d

Release Notes:

- Added tooltips when hovering over links inside the markdown preview
2024-04-04 21:06:30 +02:00
Bennet Bo Fenner
dde87f6468
markdown preview: Auto detect raw links (#10162)
Similar to the work done in `rich_text`, raw links now get picked up in
the markdown preview.


https://github.com/zed-industries/zed/assets/53836821/3c5173fd-cf8b-4819-ad7f-3127c158acaa

Release Notes:

- Added support for detecting and highlighting links in markdown preview
2024-04-04 21:05:35 +02:00
Marshall Bowers
d306b531c7
Add label_for_completion to extension API (#10175)
This PR adds the ability for extensions to implement
`label_for_completion` to customize completions coming back from the
language server.

We've used the Gleam extension as a motivating example, adding
`label_for_completion` support to it.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-04 13:56:04 -04:00
Kirill Bulatov
0f1c2e6f2b
Return back the ability to save non-dirty singleton buffers (#10174) 2024-04-04 18:06:47 +02:00
Jason Lee
0861ceaac2
Add yield keyword highlight for Rust (#10104)
Release Notes:

- Added `yield` keyword highlight for Rust


Ref:

- https://github.com/rust-lang/rust-analyzer/pull/7209
-
https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide/src/syntax_highlighting/highlight.rs#L177
-
https://doc.rust-lang.org/reference/keywords.html?highlight=yield#reserved-keywords


In VS Code:
 

![SCR-20240403-hrb](https://github.com/zed-industries/zed/assets/5518/ec3e84ce-ea9d-4b2d-832d-ecdfec0def91)

docs.rs:
https://docs.rs/async-stream/latest/async_stream/macro.try_stream.html


![SCR-20240403-gpk](https://github.com/zed-industries/zed/assets/5518/07010c2c-341d-4ae2-ba80-5f4eab4dbf60)

## Before

<img width="644" alt="image"
src="https://github.com/zed-industries/zed/assets/5518/da349187-57e6-4cea-b3e3-f628ce6a99e8">


## After update in Zed

![SCR-20240403-hqk](https://github.com/zed-industries/zed/assets/5518/44f1687b-ec38-42c2-984d-15177bed7e5b)
2024-04-04 17:56:33 +02:00
Piotr Osiewicz
1c485a0d05
tasks: change placeholder text in a modal (#10166)
Related to: #10132

Release Notes:

- N/A
2024-04-04 15:37:53 +02:00
Bennet Bo Fenner
27165e9927
channel chat: Set first loaded message ID when sending a message (#10034)
Discovered while looking into #10024.

When clicking on a reply message text, the original message should be
highlighted accordingly. However this would not work when the channel
was just created and the user is the only one that sent messages.
 
Release Notes:

- Fixed highlighting of messages when clicking on the reply message text
in the chat and there were no other messages from other users
2024-04-04 15:12:35 +02:00
Kirill Bulatov
1085642c88
Stricten Zed Task variable API (#10163)
Introduce `VariableName` enum to simplify Zed task templating
management: now all the variables can be looked up statically and can be
checked/modified in a centralized way: e.g. `ZED_` prefix is now added
for all such custom vars.

Release Notes:

- N/A
2024-04-04 16:02:24 +03:00
Bennet Bo Fenner
5b4ff74dca
collab ui: Dismiss project shared notifications when leaving room (#10160)
When leaving a call/room in which a project was shared, the shared
project notification was not getting dismissed when the person that
shared the project left the room.
Although there was a `cx.emit(Event::Left)` call inside room, the event
was never received in the `project_shared_notification` module, because
the room is dropped before the event can be dispatched. Moving the
`cx.emit(Event::Left)` to the active call fixed the problem. Also
renamed `Event::Left` to `Event::RoomLeft` because the room join
equivalent is also called `Event::RoomJoined`.


Release Notes:

- Fixed project shared notification staying open, when the user that
shared the project left the room
2024-04-04 13:43:14 +02:00
Thorsten Ball
8e9543aefe
Improve handling of prettier errors on format (#10156)
When no formatter for a language is specified, Zed has the default
behaviour:

1. Attempt to format the buffer with `prettier`
2. If that doesn't work, use the language server.

The problem was that if `prettier` failed to format a buffer due to
legitimate syntax errors, we simply did a fallback to the language
server, which would then format over the syntax errors.

With JavaScript/React/TypeScript projects this could lead to a situation
where

1. Syntax error was introduced
2. Prettier fails
3. Zed ignores the error
4. typescript-language-server formats the buffer despite syntax errors

This would lead to some very weird formatting issues.

What this PR does is to fix the issue by handling `prettier` errors and
results in two user facing changes:

1. When no formatter is set (or set to `auto`) and if we attempted to
start a prettier instance to format, we will now display that error and
*not* fall back to language server formatting.
2. If the formatter is explicitly set to `prettier`, we will now show
errors if we failed to spawn prettier or failed to format with it.

This means that we now might show *more* errors than previously, but I
think that's better than not showing anything to the user at all.

And, of course, it also fixes the issue of invalid syntax being
formatted by the language server even though `prettier` failed with an
error.

Release Notes:

- Improved error handling when formatting buffers with `prettier`.
Previously `prettier` errors would be logged but ignored. Now `prettier`
errors are shown in the UI, just like language server errors when
formatting. And if no formatter is specified (or set to `"auto"`) and
Zed attempts to use `prettier` for formatting, then `prettier` errors
are no longer skipped. That fixes the issue of `prettier` not formatting
invalid syntax, but its error being skipped, leading to
`typescript-language-server` or another language server formatting
invalid syntax.
2024-04-04 11:41:55 +02:00
Remco Smits
c0d117182f
Fix clear reply to message and edit message state when you switch state (#10044)
This pull request fixes the following issue #10042.

Release Notes:
- Fixed clear chat state when switching edit/reply message state.
([#10042](https://github.com/zed-industries/zed/issues/10042)).
2024-04-04 08:36:27 +02:00
Hans
9cbde74274
Refactor selection expansion logic into a separate method (#10117)
Release Notes:

- N/A

This commit introduces a new method `range` to calculate the target
range for selection expansion based on the current selection, movement
times, and other parameters. The `expand_selection` method is refactored
to use this new `range` method, simplifying the logic for expanding a
selection and making the code more modular and reusable. The `range`
method encapsulates the logic for calculating the new selection range,
including handling linewise selection and adjustments for surrounding
newlines, making it easier to understand and maintain the selection
expansion functionality.

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-04-04 08:35:26 +02:00
Piotr Osiewicz
879f361966
tasks: fix panic in render_match (#10137)
Release Notes:

- Fixed panic in tasks modal (Preview only).
2024-04-03 22:09:36 +02:00
Conrad Irwin
ccb2d02ce0
Remove datadog (#10133)
Release Notes:

- N/A
2024-04-03 11:35:23 -06:00
Conrad Irwin
fc08ea9b0d
Fix undo in replace mode (#10086)
Fixes: #10031

Co-Authored-By: Petros <petros@amignosis.com>

Release Notes:

- vim: Fix undo grouping in Replace mode
([#10031](https://github.com/zed-industries/zed/issues/10031)).

---------

Co-authored-by: Petros <petros@amignosis.com>
2024-04-03 11:35:04 -06:00
Marshall Bowers
49c53bc0ec
Extract HTML support into an extension (#10130)
This PR extracts HTML support into an extension and removes the built-in
HTML support from Zed.

Release Notes:

- Removed built-in support for HTML, in favor of making it available as
an extension. The HTML extension will be suggested for download when you
open a `.html`, `.htm`, or `.shtml` file.
2024-04-03 12:42:36 -04:00
Max Brunsfeld
256b446bdf
Refactor LSP adapter methods to compute labels in batches (#10097)
Once we enable extensions to customize the labels of completions and
symbols, this new structure will allow this to be done with a single
WASM call, instead of one WASM call per completion / symbol.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
2024-04-03 09:22:56 -07:00
Joseph T. Lyons
ef3d04efe6 v0.131.x dev 2024-04-03 12:11:28 -04:00
Marshall Bowers
469be39a32
file_icons: Add license file (#10128)
This PR adds a missing license file to the `file_icons` crate.

Release Notes:

- N/A
2024-04-03 12:07:53 -04:00
Piotr Osiewicz
b118b76272
editor: Fix "Toggle comments" not respecting multiple line_comments in language config (#10126)
This does not try to heuristically pick a comment style based on
surroundings anyhow. It does improve our story around uncommenting
though.

Fixes #10113.

Release Notes:

- Fixed "Toggle comment" action not working in presence of non-default
line comments such as doc comments in Rust
([#10113](https://github.com/zed-industries/zed/issues/10113)).
2024-04-03 17:34:59 +02:00
Andrew Lygin
57a1b9b2cd
tab_switcher: Add tab close buttons (#9968)
Support for closing tabs from Tab Switcher:

- Close button color matches the indicator color to preserve the
information that the buffer is dirty (as in SublimeText).
- `ctrl-backspace` closes the currently selected item.


https://github.com/zed-industries/zed/assets/2101250/8ea33911-2f62-4199-826d-c17556db8e9a

Release Notes:

- N/A
2024-04-03 17:28:51 +02:00
Jason Lee
8eeecdafec
Add crate keyword to Rust (#10110)
Release Notes:

- Fixed `crate` keyword not being highlighted in Rust files.

Ref: #10104 

And I make a sort for them.
2024-04-03 17:27:22 +02:00
Thorsten Ball
eb231d0449
Add code_actions as formatter type (#10121)
This fixes #8992 and solves a problem that ESLint/Prettier/... users
have been running into:

They want to format _only_ with ESLint, which is *not* a primary
language server (so `formatter: language server` does not help) and it
is not a formatter.

What they want to use is what they get when they have configured
something like this:

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

BUT they don't want to run the formatter.

So what this PR does is to add a new formatter type: `code_actions`.

With that, users can only use code actions to format:

```json
{
  "languages": {
    "JavaScript": {
      "formatter": {
        "code_actions": {
          "source.fixAll.eslint": true
        }
      }
    }
  }
}
```

This means that when formatting (via `editor: format` or on-save) only
the code actions that are specified are being executed, no formatter.


Release Notes:

- Added a new `formatter`/`format_on_save` option: `code_actions`. When
configured, this uses language server code actions to format a buffer.
This can be used if one wants to, for example, format a buffer with
ESLint and *not* run prettier or another formatter afterwards. Example
configuration: `{"languages": {"JavaScript": {"formatter":
{"code_actions": {"source.fixAll.eslint": true}}}}}`
([#8992](https://github.com/zed-industries/zed/issues/8992)).

---------

Co-authored-by: JH Chabran <jh@chabran.fr>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-03 16:16:03 +02:00
Marshall Bowers
654504d5ee
Remove basic.conf (#10120)
This PR removes the `basic.conf` file.

In #10099 we suppressed some typo warnings that had cropped up in this
file, but it turns out we don't need the file at all.

Release Notes:

- N/A
2024-04-03 09:38:36 -04:00
Kirill Bulatov
027897e003
Do not spawn oneshot tasks from blank prompts (#10115) 2024-04-03 13:54:16 +02:00
Thorsten Ball
c4ceeb715a
Fix git blame not working correctly with submodules (#10114)
This fixes #9958 by using the correct working directory in which to run
`git blame`.

This wasn't an issue for a single repository, because we could go from
`.git` one directory up, but it doesn't work for submodules.

Luckily there's a `workdir()` method on `self.repository` that does
exactly what we need.

In submodule:

![screenshot-2024-04-03-12 37
18@2x](https://github.com/zed-industries/zed/assets/1185253/67e89abb-d04c-4e9d-802f-5b8468e0962e)

Not in submodule:

![screenshot-2024-04-03-12 37
36@2x](https://github.com/zed-industries/zed/assets/1185253/cfe59f59-798b-43e1-980d-2225db4c0302)

Release Notes:

- N/A
2024-04-03 13:49:12 +02:00
Kirill Bulatov
58aec1de75
Do not push invisible local worktrees into recent documents (#10112)
Follow-up of https://github.com/zed-industries/zed/pull/9919 that
removes invisible worktrees from the list, to avoid things like

![image](https://github.com/zed-industries/zed/assets/2690773/90ce1c29-a1dd-4a03-b09a-effdba620c8f)

Release Notes:

- N/A
2024-04-03 13:47:01 +03:00
Kirill Bulatov
9aad30a559
Query code actions and hovers from all related local language servers (from remote clients) (#10111)
Supersedes https://github.com/zed-industries/zed/pull/8634
Fixes https://github.com/zed-industries/zed/issues/7947 by continuing
https://github.com/zed-industries/zed/pull/9943 with the remote part.

Now, clients are able to issue collab requests, that query all related
language servers, not only the primary one.
Such mode is enabled for GetHover and GetCodeActions LSP requests only.

Release Notes:

- Added Tailwind CSS hover popovers for Zed in multi player mode
([7947](https://github.com/zed-industries/zed/issues/7947))
2024-04-03 13:34:56 +03:00
Thorsten Ball
3a0d3cee87
Compute scrollbar markers asynchronously (#10080)
Refs #9647
Fixes https://github.com/zed-industries/zed/issues/9792

This pull request moves the computation of scrollbar markers off the
main thread, to prevent them from grinding the editor to a halt when we
have a lot of them (e.g., when there are lots of search results on a
large file). With these changes we also avoid generating multiple quads
for adjacent markers, thus fixing an issue where we stop drawing other
primitives because we've drawn too many quads in the scrollbar.

Release Notes:

- Improved editor performance when displaying lots of search results,
diagnostics, or symbol highlights in the scrollbar
([#9792](https://github.com/zed-industries/zed/issues/9792)).

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan <nathan@zed.dev>
2024-04-03 12:21:17 +02:00
Thorsten Ball
7dbcace839
Fix accidentally dropping shell environment variable (#10105)
Previously this code would run the changed commend, take its output,
remove the `marker` from the front and then split on `0` byte.

Problem was that `echo` adds a newline, which we did *NOT* skip. So
whatever `env` printed as the first environment variable would have a
`\n` in front of it.

Instead of setting, say, `HOME`, Zed would set `\nHOME`.

This change fixes the issue by switching to `printf '%s' marker`, which
is more portable than using `echo -n`.

This is related to https://github.com/zed-industries/zed/issues/9786 but
I'm not sure yet whether that fixes it.

Release Notes:

- Fixed Zed sometimes missing environment variables from shell in case
they were the first environment variable listed by `/usr/bin/env`.
2024-04-03 09:34:17 +02:00
William Villeneuve
463c16a402
Allow users to configure ESLint's problems settings (#9981)
Presently the only available setting under `problems` is
`shortenToSingleLine`, which defaults to `false`.

Example Zed `settings.json` to shorten eslint error squiggles to only
show on the first line of the problem:
```json
{
    "lsp": {
        "eslint": {
            "settings": {
                "problems": {
                    "shortenToSingleLine": true
                }
            }
        }
    }
}
```


Release Notes:

- Added support for configuring ESLint `problems` settings, ie. `{"lsp":
{"eslint": {"settings": {"problems": {"shortenToSingleLine": true}}}}}`

Demo:



https://github.com/zed-industries/zed/assets/2072378/379faa75-1f37-4fd1-85da-1510f1397d07
2024-04-03 09:29:07 +02:00
Conrad Irwin
5a2a85a7db
Fix vim code working on display map chars (#10103)
Release Notes:

- vim: Fixed motion bugs when softwrap, folds or inlay hints were used.
2024-04-02 22:16:52 -06:00
Remco Smits
754547f349
Fix mention notifications are not updated after message change and not removed after a message is deleted (#9847)
@ConradIrwin This is a followup for #9035 as agreed.

Release Notes:

- Fixed mention notifications are updated when channel message is
updated. And mention notifications are removed when message is removed.

---------

Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
2024-04-02 20:40:00 -06:00
Conrad Irwin
fe7b12c444
fix rejoin after quit (#10100)
Release Notes:

- collab: Fixed rejoining channels quickly after a restart
2024-04-02 20:35:14 -06:00
Max Brunsfeld
7d5048e909
Revert PR #6924 - go to reference when there's only one (#10094)
This PR reverts #6924, for the reasons stated in
https://github.com/zed-industries/zed/pull/6924#issuecomment-2033076300.

It also fixes an issue were the `find_all_references_task_sources`
wasn't cleaned up in all cases.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-02 14:31:58 -07:00
Conrad Irwin
65cde17063
Fix collab logging (#10095)
span! statically determines which fields are available, and record
silently fails if you write to a field that is not available :/

Release Notes:

- N/A
2024-04-02 15:31:30 -06:00
Conrad Irwin
9317fe46af Revert "Revert "Revert dependency updates in #9836 (#10089)""
This reverts commit c8b14ee2cb.
2024-04-02 13:12:38 -06:00
Conrad Irwin
c8b14ee2cb Revert "Revert dependency updates in #9836 (#10089)"
This reverts commit 55c897d993.
2024-04-02 12:59:10 -06:00
Mikayla Maki
55c897d993
Revert dependency updates in #9836 (#10089)
Due to: https://github.com/zed-industries/zed/issues/9985 and an
abundance of caution, I'm reverting the image and svg rendering updates
for now until we can debug the issue. cc: @niklaswimmer

Release Notes:

- N/A
2024-04-02 12:27:48 -06:00
Marshall Bowers
6121bfc5a4
Extract Clojure support into an extension (#10088)
This PR extracts Clojure support into an extension and removes the
built-in Clojure support from Zed.

Release Notes:

- Removed built-in support for Clojure, in favor of making it available
as an extension. The Clojure extension will be suggested for download
when you open a `.clj` or other Clojure-related files.

---------

Co-authored-by: Max <max@zed.dev>
2024-04-02 13:47:03 -04:00
Max Brunsfeld
46544d7354
Revert PR #8327 - Fix autocomplete completions being cut in half (#10084)
This reverts https://github.com/zed-industries/zed/pull/8327

That PR introduced a regression where completions' syntax highlighting
would be corrupted in a non-deterministic way, such that it varied from
frame to frame:

In the screenshot below, many of the field names (e.g. `cursor`,
`depth`) are incorrectly colored as types instead of fields. The
`finished_states` field has highlighting that changes at the wrong
offset. All of these values changed from frame to frame, creating a
strange flickering effect:

<img width="599" alt="Screenshot 2024-04-01 at 5 56 36 PM"
src="https://github.com/zed-industries/zed/assets/326587/b6a48f02-f146-4f76-92e6-32fb417d86c0">

Release Notes:

- N/A
2024-04-02 09:24:55 -07:00
Piotr Osiewicz
8df888e5b1
task: Add "remove" button next to oneshot tasks (#10083)
Release Notes:

- Added a "remove" button next to oneshot tasks in tasks modal.
2024-04-02 17:59:22 +02:00
Marshall Bowers
a1cb6772bf
Make conversions to wasmtime::Result postfix-friendly (#10082)
This PR refactors the conversions to `wasmtime::Result` to use a trait
so that we can perform the conversions in a postfix-friendly way.

Release Notes:

- N/A
2024-04-02 11:38:15 -04:00