Allow buffer search in project search (#23819)

Closes #13437
Closes #19993

Release Notes:

- Allow searching within the results of a project search
- vim: Fix `/`/`?`, `n`/`N`, `gn`/`gN`,`*`/`#` in project search results

---------

Co-authored-by: Nico <nico.lehmann@gmail.com>
This commit is contained in:
Conrad Irwin
2025-01-31 00:13:46 -07:00
committed by GitHub
co-authored by Nico
parent e1af35aa15
commit f2b3f3a9ab
10 changed files with 191 additions and 105 deletions
+6
View File
@@ -728,6 +728,7 @@ pub struct Editor {
expect_bounds_change: Option<Bounds<Pixels>>,
tasks: BTreeMap<(BufferId, BufferRow), RunnableTasks>,
tasks_update_task: Option<Task<()>>,
in_project_search: bool,
previous_search_ranges: Option<Arc<[Range<Anchor>]>>,
breadcrumb_header: Option<String>,
focused_block: Option<FocusedBlock>,
@@ -1426,6 +1427,7 @@ impl Editor {
],
tasks_update_task: None,
linked_edit_ranges: Default::default(),
in_project_search: false,
previous_search_ranges: None,
breadcrumb_header: None,
focused_block: None,
@@ -1703,6 +1705,10 @@ impl Editor {
self.collaboration_hub = Some(hub);
}
pub fn set_in_project_search(&mut self, in_project_search: bool) {
self.in_project_search = in_project_search;
}
pub fn set_custom_context_menu(
&mut self,
f: impl 'static
+26 -1
View File
@@ -38,8 +38,11 @@ use text::{BufferId, Selection};
use theme::{Theme, ThemeSettings};
use ui::{h_flex, prelude::*, IconDecorationKind, Label};
use util::{paths::PathExt, ResultExt, TryFutureExt};
use workspace::item::{BreadcrumbText, FollowEvent};
use workspace::item::{Dedup, ItemSettings, SerializableItem, TabContentParams};
use workspace::{
item::{BreadcrumbText, FollowEvent},
searchable::SearchOptions,
};
use workspace::{
item::{FollowableItem, Item, ItemEvent, ProjectItem},
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
@@ -1324,6 +1327,28 @@ impl SearchableItem for Editor {
}
}
fn supported_options(&self) -> SearchOptions {
if self.in_project_search {
SearchOptions {
case: true,
word: true,
regex: true,
replacement: false,
selection: false,
find_in_results: true,
}
} else {
SearchOptions {
case: true,
word: true,
regex: true,
replacement: true,
selection: true,
find_in_results: false,
}
}
}
fn query_suggestion(&mut self, window: &mut Window, cx: &mut Context<Self>) -> String {
let setting = EditorSettings::get_global(cx).seed_search_query_from_cursor;
let snapshot = &self.snapshot(window, cx).buffer_snapshot;