This removes around 900 unnecessary clones, ranging from cloning a few
ints all the way to large data structures and images.
A lot of these were fixed using `cargo clippy --fix --workspace
--all-targets`, however it often breaks other lints and needs to be run
again. This was then followed up with some manual fixing.
I understand this is a large diff, but all the changes are pretty
trivial. Rust is doing some heavy lifting here for us. Once I get it up
to speed with main, I'd appreciate this getting merged rather sooner
than later.
Release Notes:
- N/A
Follow-up to https://github.com/zed-industries/zed/pull/36233
The above PR simplified the handling but introduced some bugs: The
replace buttons were no longer clickable, some buttons also lost their
toggle states, some buttons shared their element id and, lastly, some
buttons were clickable but would not trigger the right action. This PR
fixes all that.
Release Notes:
- N/A
- project search query string now turns red when no results are found
matching buffer search behavior
- General code deduplication as well as more consistent layout between
the two bars, as some minor details have drifted apart
- Tab cycling in buffer search now ends up in editor focus when cycling
backwards, matching forward cycling
- Report parse errors in filter include and exclude editors
Release Notes:
- N/A
I'm not sure when we've lost that notify, but it's causing the time to
first search result equal to the time to run the whole search, which is
not great.
Co-authored-by: Remco <djsmits12@gmail.com>
This discussion has originally started in #35444
Release Notes:
- Improved project search speed.
Co-authored-by: Remco <djsmits12@gmail.com>
Currently if you type `\(`, it auto-closes to `\()` which is broken.
It's arguably nice that if you type `(` it auto-closes to `()`, but I am
much more likely to be looking for a function call `name\(` than to be
starting a group in search.
Release Notes:
- search: Regex search will no longer try to close parenthesis
automatically.
Closes #ISSUE
Adds a new `documentation` method to actions, that is extracted from doc
comments when using the `actions!` or derive macros.
Additionally, this PR adds doc comments to as many action definitions in
Zed as possible.
Release Notes:
- N/A *or* Added/Fixed/Improved ...
Closes#17223
Release Notes:
- Show regex parsing errors under the search bar for buffer and project
search.
---------
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
In #32656 I generalized the argument to change selections to allow
controling both the scroll and the nav history (and the completion
trigger).
To avoid conflicting with ongoing debugger cherry-picks I left the
argument as an `impl Into<>`, but I think it's clearer to make callers
specify what they want here.
I converted a lot of `None` arguments to `SelectionEffects::no_scroll()`
to be exactly compatible; but I think many people used none as an "i
don't care" value in which case Default::default() might be more
appropraite
Closes #ISSUE
Release Notes:
- N/A
In #32656 I generalized the argument to change selections to allow
controling both the scroll and the nav history (and the completion
trigger).
To avoid conflicting with ongoing debugger cherry-picks I left the
argument as an `impl Into<>`, but I think it's clearer to make callers
specify what they want here.
I converted a lot of `None` arguments to `SelectionEffects::no_scroll()`
to be exactly compatible; but I think many people used none as an "i
don't care" value in which case Default::default() might be more
appropraite
Instead of a menagerie of macros for implementing `Action`, now there
are just two:
* `actions!(editor, [MoveLeft, MoveRight])`
* `#[derive(..., Action)]` with `#[action(namespace = editor)]`
In both contexts, `///` doc comments can be provided and will be used in
`JsonSchema`.
In both contexts, parameters can provided in `#[action(...)]`:
- `namespace = some_namespace` sets the namespace. In Zed this is
required.
- `name = "ActionName"` overrides the action's name. This must not
contain "::".
- `no_json` causes the `build` method to always error and
`action_json_schema` to return `None`
and allows actions not implement `serde::Serialize` and
`schemars::JsonSchema`.
- `no_register` skips registering the action. This is useful for
implementing the `Action` trait
while not supporting invocation by name or JSON deserialization.
- `deprecated_aliases = ["editor::SomeAction"]` specifies deprecated old
names for the action.
These action names should *not* correspond to any actions that are
registered. These old names
can then still be used to refer to invoke this action. In Zed, the
keymap JSON schema will
accept these old names and provide warnings.
- `deprecated = "Message about why this action is deprecation"`
specifies a deprecation message.
In Zed, the keymap JSON schema will cause this to be displayed as a
warning. This is a new feature.
Also makes the following changes since this seems like a good time to
make breaking changes:
* In `zed.rs` tests adds a test with an explicit list of namespaces. The
rationale for this is that there is otherwise no checking of `namespace
= ...` attributes.
* `Action::debug_name` renamed to `name_for_type`, since its only
difference with `name` was that it
* `Action::name` now returns `&'static str` instead of `&str` to match
the return of `name_for_type`. This makes the action trait more limited,
but the code was already assuming that `name_for_type` is the same as
`name`, and it requires `&'static`. So really this just makes the trait
harder to misuse.
* Various action reflection methods now use `&'static str` instead of
`SharedString`.
Release Notes:
- N/A
- [x] foreground highlights
- [x] background highlights
- [x] advertise support in DAP capabilities
Closes#31372
Release Notes:
- Debugger Beta: added basic support for highlighting in the console
based on ANSI escape codes.
This PR replaces some `update()` calls with either `read()` or
`read_with()` when the `update()` call performed read-only operations on
the entity.
Many more likely exist, will follow-up with more PRs.
Release Notes:
- N/A
The panic occurred when querying a second search in the project search
multibuffer while there were dirty buffers.
The panic only happened in Nightly so there's no release notes
Release Notes:
- N/A
Currently, `search::ReplaceNext` works only first time it is executed
because Zed switches the focus to the editor. It seems
`self.editor_focus` call is unnecessary.
Closes#17466
Release Notes:
- Fixed `Replace Next Match` command. Previously it worked once, then
Zed incorrectly switched the focus to the editor
https://github.com/user-attachments/assets/66ef61d6-1efe-43ca-8d8c-6b40540a9930
In accordance with #30327, I saw no reason for included files to get
special treatment, and I actually get use out of prefilling excluded
files because I like not to search symlinked files which, in my
workflow, use a naming convention.
This is simply implementing the same exact changes, but for excluded. It
was tested with `"space /": ["pane::DeploySearch", { "excluded_files":
"**/_*.tf" }]` and works just fine.
Release Notes:
- Added `excluded_files` to `pane::DeploySearch`.
Closes#30820
Release Notes:
- Fixed an issue where entering a new search in the project search would
drop unsaved edits in the project search buffer
---------
Co-authored-by: Mark Janssen <20283+praseodym@users.noreply.github.com>
* project search button in the status bar
```jsonc
"search": {
"button": false
},
```
* project diagnostics button in the status bar
```jsonc
"diagnostics": {
"button": false
}
```
* project name and host buttons in the title bar
```jsonc
"title_bar": {
"show_project_items": false
}
```
* git branch button in the title bar
```jsonc
"title_bar": {
"show_branch_name": false
}
```
Before:
<img width="1728" alt="before"
src="https://github.com/user-attachments/assets/4b13b431-3ac1-43b3-8ac7-469e5a9ccf7e"
/>
After:
<img width="1728" alt="after"
src="https://github.com/user-attachments/assets/baf2765a-e27b-47a3-8897-89152b7a7c95"
/>
Release Notes:
- Added more settings to hide buttons from Zed UI
Useful for large monorepos with many subdirectories, users can keybind a
filter to their commonly used directories.
Release Notes:
- Added a new `included_files` field to the `DeploySearch` action to
automatically pre-fill which files to include in the search. This lets
you use a keybinding to search in a particular folder or for a certain
set of files.
---------
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Closes#30134
This PR ensures that path filters are only applied to searches when the
filters are actually enabled (and visible).
Release Notes:
- Fixed the project search considering included and excluded filters
after toggling them off.
Closes#29858
This PR fixes the alignment-issue for the project saerch for cases where
the horizontally available space is large.
The issue arose because the two smaller editors within one line were
allowed to grow as much as the other editors on separate lines, up to
1200 pixels. However, these two editors should together only take up
1200 pixels at maximum, including the gap between them. To fix this, the
editors now live within one container element that grows at the same
rate as the other editors whilst allowing both editors to flex grow as
needed in the available space.
Current main:
https://github.com/user-attachments/assets/622016dc-70e5-455f-a7ba-5b69405d7e1e
This PR:
https://github.com/user-attachments/assets/5244abf7-f0c0-4781-acb7-b774638d8a17
Release Notes:
- Improved project search input field alignment.
resolves#24655resolves#23945
I haven't yet added a default binding for the new command. #27797 added `:ls` and
`:buffers` which in my opinion should use the global searchable version
given that that matches the vim semantics of those commands better than
just showing the tabs in the local pane.
There's also a question of what to do when you select a tab from another
pane, should the focus jump to that pane or should that tab move to the
currently focused pane? For now I've implemented the former.
Release Notes:
- Added `tab_switcher::ToggleAll` to search open tabs from all panes and focus the selected one.
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This PR renames the `regex_search` tool to `grep` because I think it
conveys more meaning to the model, the idea of searching the filesystem
with a regular expression. It's also one word and the model seems to be
using it effectively after some additional prompt tuning.
It also takes an include pattern to filter on the specific files we try
to search. I'd like to encourage the model to scope its searches more
aggressively, as in my testing, I'm only seeing it filter on file
extension.
Release Notes:
- N/A
Closes#29000
When buffer search is already deployed:
1. If find dialog is enabled, change it to find-and-replace dialog and
focuses to it
2. If find-and-replace is enabled, focuses to it
Release Notes:
- Fixed an issue where invoking `DeployReplace` while the Find dialog
was open did not switch to the Find & Replace dialog.
- Fixed an issue where invoking `DeployReplace` while the Find & Replace
dialog was already open did not focus it.
Update the `Vim::replace_command` method so as to reset the range in the
`BufferSearchBar` after running the replacement in order to fix the
issue where the number of matches in the search bar would be incorrect
after the replacement was done, as it would only take into consideration
the range in which the replacement happened, instead of the whole
buffer.
In order to get this working a new
`BufferSearchBar::clear_search_within_ranges` method is introduced in
these changes.
Release Notes:
- Fixed the number of matches displayed in the search bar after running
vim's substitute command.
This Pull Request updates the default behavior of the substitute (`s`)
command in vim mode to only replace the next match by default, instead
of all, and replace all matches only when the `g` flag is provided,
making it more similar to NeoVim's behavior.
In order to achieve this, the following changes were introduced:
- Update `BufferSearchBar::replace_next` to be a public method, so it
can be called from `Vim::replace_command` .
- Update the `Replacement::parse` to set the `should_replace_all` field
to `false` by default, and only set it to `true` if the `'g'` flag is
present in the query.
- Add support for when the `Replacement.should_replace_all` is set to
`false` in `Vim::replace_command`, so as to have it only replace the
next occurrence instead of all occurrences in the line.
- Introduce `BufferSearchBar::select_first_match` so as to activate the
first match on the line under the cursor.
Closes#24450
Release Notes:
- Improved vim's substitute command so as to only replace the first
match by default, and replace all matches if the `'g'` flag is provided
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Was chatting with @wilhelmklopp, he pointed out that our current
UI-accessible way to access the project search was pretty obscure.
<img width="393" alt="Screenshot 2025-04-08 at 6 57 51 PM"
src="https://github.com/user-attachments/assets/636053cd-5a88-4a5e-8155-6d41d189b7db"
/>
Release Notes:
- Added a button to open the project search to the status bar