WIP
This commit is contained in:
parent
23308e17a9
commit
171dd0c243
4 changed files with 54 additions and 52 deletions
|
@ -1259,7 +1259,7 @@ mod tests {
|
||||||
fn test_selection_with_mouse() {
|
fn test_selection_with_mouse() {
|
||||||
App::test(|mut app| async move {
|
App::test(|mut app| async move {
|
||||||
let buffer = app.add_model(|_| Buffer::new(0, "aaaaaa\nbbbbbb\ncccccc\ndddddd\n"));
|
let buffer = app.add_model(|_| Buffer::new(0, "aaaaaa\nbbbbbb\ncccccc\ndddddd\n"));
|
||||||
let settings = settings::channel(&FontCache::new()).1;
|
let settings = settings::channel(&FontCache::new()).unwrap().1;
|
||||||
let (_, buffer_view) =
|
let (_, buffer_view) =
|
||||||
app.add_window(|ctx| BufferView::for_buffer(buffer, settings, ctx));
|
app.add_window(|ctx| BufferView::for_buffer(buffer, settings, ctx));
|
||||||
|
|
||||||
|
@ -1470,7 +1470,7 @@ mod tests {
|
||||||
fn test_move_cursor() -> Result<()> {
|
fn test_move_cursor() -> Result<()> {
|
||||||
let mut app = App::new().unwrap();
|
let mut app = App::new().unwrap();
|
||||||
let buffer = app.add_model(|_| Buffer::new(0, sample_text(6, 6)));
|
let buffer = app.add_model(|_| Buffer::new(0, sample_text(6, 6)));
|
||||||
let settings = settings::channel(&FontCache::new()).1;
|
let settings = settings::channel(&FontCache::new()).unwrap().1;
|
||||||
let (_, view) = app.add_window(|ctx| BufferView::for_buffer(buffer.clone(), settings, ctx));
|
let (_, view) = app.add_window(|ctx| BufferView::for_buffer(buffer.clone(), settings, ctx));
|
||||||
|
|
||||||
buffer.update(&mut app, |buffer, ctx| {
|
buffer.update(&mut app, |buffer, ctx| {
|
||||||
|
|
|
@ -52,8 +52,8 @@ impl<T: Clone> Network<T> {
|
||||||
|
|
||||||
// Insert one or more duplicates of this message *after* the previous
|
// Insert one or more duplicates of this message *after* the previous
|
||||||
// message delivered by this replica.
|
// message delivered by this replica.
|
||||||
for _ in 0..rng.gen_range(1, 4) {
|
for _ in 0..rng.gen_range(1..4) {
|
||||||
let insertion_index = rng.gen_range(min_index, inbox.len() + 1);
|
let insertion_index = rng.gen_range(min_index..inbox.len() + 1);
|
||||||
inbox.insert(
|
inbox.insert(
|
||||||
insertion_index,
|
insertion_index,
|
||||||
Envelope {
|
Envelope {
|
||||||
|
@ -77,7 +77,7 @@ impl<T: Clone> Network<T> {
|
||||||
R: Rng,
|
R: Rng,
|
||||||
{
|
{
|
||||||
let inbox = self.inboxes.get_mut(&receiver).unwrap();
|
let inbox = self.inboxes.get_mut(&receiver).unwrap();
|
||||||
let count = rng.gen_range(0, inbox.len() + 1);
|
let count = rng.gen_range(0..inbox.len() + 1);
|
||||||
inbox
|
inbox
|
||||||
.drain(0..count)
|
.drain(0..count)
|
||||||
.map(|envelope| envelope.message)
|
.map(|envelope| envelope.message)
|
||||||
|
|
|
@ -68,54 +68,56 @@ pub fn match_paths(
|
||||||
let segment_size = (path_count + cpus - 1) / cpus;
|
let segment_size = (path_count + cpus - 1) / cpus;
|
||||||
let mut segment_results = (0..cpus).map(|_| BinaryHeap::new()).collect::<Vec<_>>();
|
let mut segment_results = (0..cpus).map(|_| BinaryHeap::new()).collect::<Vec<_>>();
|
||||||
|
|
||||||
Parallel::new().each(
|
Parallel::new()
|
||||||
segment_results.iter_mut().enumerate(),
|
.each(
|
||||||
|(segment_idx, results)| {
|
segment_results.iter_mut().enumerate(),
|
||||||
let segment_start = segment_idx * segment_size;
|
|(segment_idx, results)| {
|
||||||
let segment_end = segment_start + segment_size;
|
let segment_start = segment_idx * segment_size;
|
||||||
|
let segment_end = segment_start + segment_size;
|
||||||
|
|
||||||
let mut min_score = 0.0;
|
let mut min_score = 0.0;
|
||||||
let mut last_positions = Vec::new();
|
let mut last_positions = Vec::new();
|
||||||
last_positions.resize(query.len(), 0);
|
last_positions.resize(query.len(), 0);
|
||||||
let mut match_positions = Vec::new();
|
let mut match_positions = Vec::new();
|
||||||
match_positions.resize(query.len(), 0);
|
match_positions.resize(query.len(), 0);
|
||||||
let mut score_matrix = Vec::new();
|
let mut score_matrix = Vec::new();
|
||||||
let mut best_position_matrix = Vec::new();
|
let mut best_position_matrix = Vec::new();
|
||||||
|
|
||||||
let mut tree_start = 0;
|
let mut tree_start = 0;
|
||||||
for (tree_id, skipped_prefix_len, paths) in paths_by_tree_id {
|
for (tree_id, skipped_prefix_len, paths) in paths_by_tree_id {
|
||||||
let tree_end = tree_start + paths.len();
|
let tree_end = tree_start + paths.len();
|
||||||
if tree_start < segment_end && segment_start < tree_end {
|
if tree_start < segment_end && segment_start < tree_end {
|
||||||
let start = max(tree_start, segment_start) - tree_start;
|
let start = max(tree_start, segment_start) - tree_start;
|
||||||
let end = min(tree_end, segment_end) - tree_start;
|
let end = min(tree_end, segment_end) - tree_start;
|
||||||
|
|
||||||
match_single_tree_paths(
|
match_single_tree_paths(
|
||||||
*tree_id,
|
*tree_id,
|
||||||
*skipped_prefix_len,
|
*skipped_prefix_len,
|
||||||
paths,
|
paths,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
query,
|
query,
|
||||||
lowercase_query,
|
lowercase_query,
|
||||||
query_chars,
|
query_chars,
|
||||||
include_ignored,
|
include_ignored,
|
||||||
smart_case,
|
smart_case,
|
||||||
results,
|
results,
|
||||||
max_results,
|
max_results,
|
||||||
&mut min_score,
|
&mut min_score,
|
||||||
&mut match_positions,
|
&mut match_positions,
|
||||||
&mut last_positions,
|
&mut last_positions,
|
||||||
&mut score_matrix,
|
&mut score_matrix,
|
||||||
&mut best_position_matrix,
|
&mut best_position_matrix,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if tree_end >= segment_end {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tree_start = tree_end;
|
||||||
}
|
}
|
||||||
if tree_end >= segment_end {
|
},
|
||||||
break;
|
)
|
||||||
}
|
.run();
|
||||||
tree_start = tree_end;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut results = segment_results
|
let mut results = segment_results
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -5,7 +5,7 @@ use super::{
|
||||||
};
|
};
|
||||||
use crate::{editor::History, timer, util::post_inc};
|
use crate::{editor::History, timer, util::post_inc};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use crossbeam_queue::ArrayQueue;
|
use crossbeam_queue::SegQueue;
|
||||||
use easy_parallel::Parallel;
|
use easy_parallel::Parallel;
|
||||||
use gpui::{AppContext, Entity, ModelContext, ModelHandle};
|
use gpui::{AppContext, Entity, ModelContext, ModelHandle};
|
||||||
use ignore::dir::{Ignore, IgnoreBuilder};
|
use ignore::dir::{Ignore, IgnoreBuilder};
|
||||||
|
@ -39,7 +39,7 @@ struct DirToScan {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
relative_path: PathBuf,
|
relative_path: PathBuf,
|
||||||
ignore: Option<Ignore>,
|
ignore: Option<Ignore>,
|
||||||
dirs_to_scan: Arc<ArrayQueue<io::Result<DirToScan>>>,
|
dirs_to_scan: Arc<SegQueue<io::Result<DirToScan>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Worktree {
|
impl Worktree {
|
||||||
|
@ -95,7 +95,7 @@ impl Worktree {
|
||||||
if metadata.file_type().is_dir() {
|
if metadata.file_type().is_dir() {
|
||||||
let is_ignored = is_ignored || name == ".git";
|
let is_ignored = is_ignored || name == ".git";
|
||||||
let id = self.push_dir(None, name, ino, is_symlink, is_ignored);
|
let id = self.push_dir(None, name, ino, is_symlink, is_ignored);
|
||||||
let queue = Arc::new(ArrayQueue::new(1000));
|
let queue = Arc::new(SegQueue::new());
|
||||||
|
|
||||||
queue.push(Ok(DirToScan {
|
queue.push(Ok(DirToScan {
|
||||||
id,
|
id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue