Commit graph

487 commits

Author SHA1 Message Date
dinocosta
c69f4f49f0 refactor: implement case sensitive pattern items in search query
In order to simplify the implementation of pattern items in search
queries, this commit updates the `project::search::SearchQuery::regex`
function so as to support both `\\c` and `\\C` in the provided query.

This means that we no longer need to have both `BufferSearchBar` and
`ProjectSearchView` handling pattern items, so the
`search::pattern_items` module can now safely be removed.

It's worth noting that, since these are now handled at the `SearchQuery`
level, this removes the updates to the UI regarding search options, that
were being triggered by the pattern items being processed and applied to
the search options.

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-08-26 19:09:06 +01:00
dinocosta
d28e52d9e7 feat: add pattern items to project search
Update the `search::project_search::ProjectSearchView` implementation in
order to allow users to leverage pattern items in the search query.

Add a very basic `test_pattern_items` test to `search::project_search`
in order to test how the `apply_pattern_items` method affects the
`ProjectSearchView.search_options` value depending on the query editor's
text. Unfortunately I wasn't having much luck adding a text similar to
the one for `BufferSearchBar` where we actually simulate the user's
input and keystrokes, so definitely something that can be improved upon.
2025-08-26 16:49:54 +01:00
Finn Evers
e6267c42f7
Ensure pane: swap item right does not panic (#36765)
This fixes a panic I randomly ran into whilst mistyping in the command
palette: I accidentally ran `pane: swap item right`in a state where no
items were opened in my active pane. We were checking for `index + 1 ==
self.items.len()` there when it really should be `>=`, as otherwise in
the case of no items this panics.

This PR fixes the bug, adds a test for both the panic as well as the
actions themselves (they were untested previously). Lastly (and mostly),
this also cleans up a bit around existing actions to update them with
how we generally handle actions now.

Release Notes:

- Fixed a panic that could occur with the `pane: swap item right`
action.
2025-08-22 23:28:55 +02:00
tidely
7bdc99abc1
Fix clippy::redundant_clone lint violations (#36558)
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
2025-08-20 12:20:13 +02:00
Piotr Osiewicz
6825715503
Another batch of lint fixes (#36521)
- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
2025-08-19 20:33:44 +00:00
Piotr Osiewicz
c4083b9b63
Fix unnecessary-mut-passed lint (#36490)
Release Notes:

- N/A
2025-08-19 14:20:01 +00:00
Piotr Osiewicz
8f567383e4
Auto-fix clippy::collapsible_if violations (#36428)
Release Notes:

- N/A
2025-08-19 13:27:24 +00:00
Lukas Wirth
5df9c7c1c2
search: Fix project search query flickering (#36470)
Release Notes:

- N/A

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2025-08-19 10:16:49 +00:00
Finn Evers
65f64aa513
search: Fix recently introduced issues with the search bars (#36271)
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
2025-08-15 22:21:21 +02:00
Lukas Wirth
846ed6adf9
search: Fix project search not rendering matches count (#36238)
Follow up to https://github.com/zed-industries/zed/pull/36103/

Release Notes:

- N/A
2025-08-15 12:54:05 +00:00
Lukas Wirth
d891348442
search: Simplify search options handling (#36233)
Release Notes:

- N/A
2025-08-15 10:34:54 +00:00
Lukas Wirth
8d6982e78f
search: Fix some inconsistencies between project and buffer search bars (#36103)
- 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
2025-08-15 09:56:47 +02:00
Danilo Leal
2cde6da5ff
Redesign and clean up all icons across Zed (#35856)
- [x] Clean up unused and old icons
- [x] Swap SVG for all in-use icons with the redesigned version
- [x] Document guidelines

Release Notes:

- N/A
2025-08-08 15:34:36 -03:00
Piotr Osiewicz
bf361c316d
search: Update results multi-buffer before search is finished (#35470)
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>
2025-08-04 18:25:42 +02:00
Peter Tripp
fab450e39d
Fix invalid regular expressions highlighting all search fields (#35001)
Closes https://github.com/zed-industries/zed/issues/34969
Closes https://github.com/zed-industries/zed/issues/34970

Only highlight the search field on regex error (buffer search and
project search).
Clear errors when the buffer search hidden so stale errors aren't shown
on next search.

Before (all fields highlighted red): 
<img width="631" height="180" alt="Screenshot 2025-07-23 at 22 59 45"
src="https://github.com/user-attachments/assets/a91d3090-1bae-4718-a1f5-0a1237559ff2"
/>

After (only query field highlighted red): 
<img width="632" height="187" alt="Screenshot 2025-07-23 at 23 10 49"
src="https://github.com/user-attachments/assets/6ae72c84-9333-4cdb-907b-afb7a0a6e808"
/>

Release Notes:

- Improved highlighting of regex errors in search dialogs
2025-07-24 09:20:25 -04:00
Ben Kunkle
6cd4dbdea1
gpui: Store action documentation (#33809)
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 ...
2025-07-02 21:14:33 -04:00
Mikal Sande
59e88ce82b
Show regex query error under the search bar (#33638)
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>
2025-06-30 11:05:33 -03:00
Conrad Irwin
a675ca7a1e
Remove into SelectionEffects from .change_selections (#33554)
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
2025-06-27 14:31:31 -06:00
Conrad Irwin
6e762d9c05 Revert "Remove into SelectionEffects from .change_selections"
This reverts commit 28380d714d.
2025-06-27 14:06:17 -06:00
Conrad Irwin
28380d714d Remove into SelectionEffects from .change_selections
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
2025-06-27 14:03:45 -06:00
Piotr Osiewicz
985dcf7523
chore: Bump Rust version to 1.88 (#33439)
Goodies in this version:
- if-let chains 🎉
- Better compiler perf for Zed
(https://github.com/rust-lang/rust/pull/138522)

For more, see: https://releases.rs/docs/1.88.0/

Release Notes:

- N/A

---------

Co-authored-by: Junkui Zhang <364772080@qq.com>
2025-06-26 20:54:19 +02:00
Cole Miller
bfffc293a3
debugger: Parse and highlight text with ANSI escape sequences (#32915)
Relanding #32817 with an improved approach, bugs fixed, and a test.

Release Notes:

- N/A
2025-06-17 23:39:31 -04:00
Cole Miller
2f1d25d7f3
Revert "debugger: Process ANSI color escape codes in console" (#32906)
Reverts zed-industries/zed#32817

Release Notes:
- N/A
2025-06-17 22:13:12 +00:00
Ben Kunkle
0cda28f786
Fix release notes appearing in project search (#32898)
Closes #28829

Release Notes:

- Fixed an issue where release notes would appear in project search
results when opened locally
2025-06-17 20:56:41 +00:00
Cole Miller
ffc6218349
debugger: Process ANSI color escape codes in console (#32817)
- [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.
2025-06-16 17:39:53 -04:00
Kirill Bulatov
cef0c415f6
Don't autosave unmodified buffers (#32626)
Closes https://github.com/zed-industries/zed/issues/12091

Proper redo of https://github.com/zed-industries/zed/pull/32603

Release Notes:

- Fixed formatting effects not triggered when saving unmodified
singleton buffers

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Cole Miller <m@cole-miller.net>
2025-06-12 22:12:14 +00:00
Joseph T. Lyons
c208532693
Use read-only access methods for read-only entity operations (#31479)
Another follow-up to #31254

Release Notes:

- N/A
2025-05-26 23:04:31 -04:00
Remco Smits
dce22a965e
project search: Reduce clones and allocations (#31133)
Release Notes:

- N/A
2025-05-21 22:11:00 -04:00
Anthony Eid
0c03519393
Fix project search panic (#31089)
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
2025-05-21 12:42:20 +00:00
Adam Sherwood
8061bacee3
Add excluded_files to pane::DeploySearch (#30699)
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`.
2025-05-21 13:03:39 +03:00
Ben Kunkle
36ae564b61
Project Search: Don't prompt to save edited buffers in project search results if buffers open elsewhere (#31026)
Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-05-20 15:34:42 +00:00
Ben Kunkle
f56960ab5b
Fix project search unsaved edits (#30864)
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>
2025-05-17 05:59:51 -04:00
tidely
bc99a86bb7
Reduce allocations (#30693)
Removes a unnecessary string conversion and some clones

Release Notes:

- N/A
2025-05-14 18:29:28 +02:00
Kirill Bulatov
01488c4f91
Fix project search focus not toggling between query and results on ESC (#30613)
Before:


https://github.com/user-attachments/assets/dc5b7ab3-b9bc-4aa3-9f0c-1694c41ec7e7

After:


https://github.com/user-attachments/assets/8087004e-c1fd-4390-9f79-b667e8ba874b


Release Notes:

- Fixed project search focus not toggling between query and results on
ESC
2025-05-13 08:36:18 +00:00
Tristan Hume
11b6ce46e2
Add ability to keybind search filter (#30327)
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>
2025-05-09 12:29:03 +00:00
Finn Evers
299a0bcbaa
search: Ensure inputs located in the toolbar match the background color of the toolbar (#30355)
Closes #30267

This ensures they do not differ in color as described in the issue.

Currently: 
<img width="1182" alt="grafik"
src="https://github.com/user-attachments/assets/7ccc5116-f6b4-4ffc-80fc-b5b51c49a8f2"
/>

This PR: 
<img width="1182" alt="grafik"
src="https://github.com/user-attachments/assets/dcff631a-c1a8-423e-847c-8678a77e7a8e"
/>

Alternatively, we could potentially color the surrounding containers
with the editor background, but I think this way around is more
reasonable for the toolbar.

Release Notes:

- Improved background coloring for search inputs located in the toolbar.
2025-05-09 12:47:26 +03:00
Finn Evers
a127ff4a4f
search: Do not consider filters if they are toggled off (#30162)
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.
2025-05-08 09:42:40 +03:00
Finn Evers
0119b66426
project_search: Ensure filter row aligns with other search rows (#29886)
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.
2025-05-05 09:35:48 +03:00
Julia Ryan
4dff47ae20
Add searchable global tab switcher (#28047)
resolves #24655
resolves #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>
2025-04-28 09:21:27 +00:00
Nathan Sobo
107d8ca483
Rename regex search tool to grep and accept an include glob pattern (#29100)
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
2025-04-20 00:53:30 +00:00
Dino
af5318df98
Update default vim substitute command behavior and add support for 'g' flag (#28138)
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>
2025-04-09 14:34:51 -06:00
Kirill Bulatov
8a6ed4a2ca
Use new multibuffer excerpts in project search (#27893)
Follow-up of https://github.com/zed-industries/zed/pull/27876
Closes https://github.com/zed-industries/zed/issues/13513

Release Notes:

- Improved multi buffer excerpts to merge when expanded

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-04-02 22:57:40 +00:00
Piotr Osiewicz
dc64ec9cc8
chore: Bump Rust edition to 2024 (#27800)
Follow-up to https://github.com/zed-industries/zed/pull/27791

Release Notes:

- N/A
2025-03-31 20:55:27 +02:00
Mikayla Maki
1aefa5178b
Move "async move" a few characters to the left in cx.spawn() (#26758)
This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
2025-03-19 02:09:02 +00:00
Conrad Irwin
e3c0f56a96
New excerpt controls (#24428)
Release Notes:

- Multibuffers now use less vertical space for excerpt boundaries.
Additionally the expand up/down arrows are hidden at the start and end
of the buffers

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Zed AI <claude-3.5-sonnet@zed.dev>
2025-03-13 15:52:47 -06:00
Nico Lehmann
229e853874
Make buffer search aware of search direction (#24974)
This solves a couple of issues with Vim search by making the search
buffer and `SearchableItem` aware of the direction of the search. If
`SearchOptions::BACKWARDS` is set, all operations will be reversed. By
making `SearchableItem` aware of the direction, the correct active match
can be selected when searching backward.

Fixes #22506. This PR does not fix the last problem in that issue, but
that one is also tracked in #8049.

Release Notes:

- Fixes incorrect behavior of backward search in Vim mode
2025-03-04 19:27:37 -07:00
Ben Kunkle
ed13e05855
project search: Fix text cutoff in options help text (#26098)
Closes #25495

Release Notes:

- N/A
2025-03-05 01:15:11 +00:00
feeiyu
6b16a5555e
Fix lost focus when navigating back in project search result (#22483)
Closes #22447

When navigate forward/back, the focus moves from the ProjectSearchView's
result editor to the Pane, and then move to the ProjectSearchView, but
the event `on_focus_in` not triggered for ProjectSearchView, causing the
result editor to lose focus eventually.


f6dabadaf7/crates/workspace/src/workspace.rs (L1372)


f6dabadaf7/crates/workspace/src/workspace.rs (L1385)

Considering that the navigation might be triggered again in the next
frame, so use `on_next_frame` in `on_focus` event to move focus to
result editor.

Next frame:
- the blur event triggered for result editor.
- focus move from ProjectSearchView to result editor in `on_focus` event
for ProjectSearchView
- navigate again, focus moves from result editor to Pane then move back
to ProjectSearchView
- the focus not change during this frame, so no focus event happened for
ProjectSearchView.

![fix lost
focus1229](https://github.com/user-attachments/assets/bfaac839-7bcf-40e7-b3b4-1423d0510594)

Release Notes:

- Fix lost focus when navigate back in project search result

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2025-03-04 13:06:44 +00:00
smit
593f3dc1d5
keymap: Update Prev to Previous for consistency (#25909)
Closes #10167

This is take 2 on https://github.com/zed-industries/zed/pull/2341 which
was closed due to lack of migrator.

This PR contains rename of following keymap actions: 
```sh
1. ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }]
2. "editor::GoToPrevDiagnostic" -> "editor::GoToPreviousDiagnostic"
3. "editor::ContextMenuPrev" -> "editor::ContextMenuPrevious"
4. "search::SelectPrevMatch" -> "search::SelectPreviousMatch"
5. "file_finder::SelectPrev" -> "file_finder::SelectPrevious"
6. "menu::SelectPrev" -> "menu::SelectPrevious"
7. "editor::TabPrev" -> "editor::Backtab"
```

Release Notes:

- Renamed several keymap actions for consistency (e.g., `GoToPrevHunk` →
`GoToPreviousHunk`, `TabPrev` → `Backtab`). Your existing configured
keybindings will still work. You can click **"Backup and Update"** at
the top of your keymap file to easily update to the new actions.


Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
2025-03-03 17:44:49 +05:30
Kirill Bulatov
5740fec9d5
Ensure search input always has regex language synced with search_options state (#25811)
Follow-up to https://github.com/zed-industries/zed/pull/25797

Release Notes:

- N/A
2025-02-28 13:15:25 +00:00