Start on project-wide find

This commit is contained in:
Antonio Scandurra 2022-02-23 12:38:36 +01:00
parent 39ebaebd83
commit fed6f708c0
6 changed files with 275 additions and 2 deletions

View file

@ -10,6 +10,7 @@ path = "src/find.rs"
collections = { path = "../collections" }
editor = { path = "../editor" }
gpui = { path = "../gpui" }
project = { path = "../project" }
theme = { path = "../theme" }
workspace = { path = "../workspace" }
aho-corasick = "0.7"

View file

@ -1,3 +1,5 @@
mod project_find;
use aho_corasick::AhoCorasickBuilder;
use anyhow::Result;
use collections::HashMap;

View file

@ -0,0 +1,46 @@
use crate::SearchMode;
use editor::MultiBuffer;
use gpui::{Entity, ModelContext, ModelHandle, Task};
use project::Project;
struct ProjectFind {
last_search: SearchParams,
project: ModelHandle<Project>,
excerpts: ModelHandle<MultiBuffer>,
pending_search: Task<Option<()>>,
}
#[derive(Default)]
struct SearchParams {
query: String,
regex: bool,
whole_word: bool,
case_sensitive: bool,
}
struct ProjectFindView {
model: ModelHandle<ProjectFind>,
}
impl Entity for ProjectFind {
type Event = ();
}
impl ProjectFind {
fn new(project: ModelHandle<Project>, cx: &mut ModelContext<Self>) -> Self {
let replica_id = project.read(cx).replica_id();
Self {
project,
last_search: Default::default(),
excerpts: cx.add_model(|_| MultiBuffer::new(replica_id)),
pending_search: Task::ready(None),
}
}
fn search(&mut self, params: SearchParams, cx: &mut ModelContext<Self>) {
self.pending_search = cx.spawn_weak(|this, cx| async move {
//
None
});
}
}