Merge branch 'main' into add-setting-to-automatically-enable-virtual-environment

This commit is contained in:
Joseph T. Lyons 2023-08-25 01:50:57 -04:00
commit 0801e5e437
185 changed files with 17623 additions and 2022 deletions

View file

@ -11,7 +11,7 @@ mod project_tests;
mod worktree_tests;
use anyhow::{anyhow, Context, Result};
use client::{proto, Client, TypedEnvelope, UserStore};
use client::{proto, Client, TypedEnvelope, UserId, UserStore};
use clock::ReplicaId;
use collections::{hash_map, BTreeMap, HashMap, HashSet};
use copilot::Copilot;
@ -250,6 +250,7 @@ enum ProjectClientState {
pub struct Collaborator {
pub peer_id: proto::PeerId,
pub replica_id: ReplicaId,
pub user_id: UserId,
}
#[derive(Clone, Debug, PartialEq)]
@ -281,6 +282,7 @@ pub enum Event {
old_peer_id: proto::PeerId,
new_peer_id: proto::PeerId,
},
CollaboratorJoined(proto::PeerId),
CollaboratorLeft(proto::PeerId),
RefreshInlayHints,
}
@ -5180,7 +5182,7 @@ impl Project {
snapshot.file().map(|file| file.path().as_ref()),
) {
query
.search(snapshot.as_rope())
.search(&snapshot, None)
.await
.iter()
.map(|range| {
@ -5930,6 +5932,7 @@ impl Project {
let collaborator = Collaborator::from_proto(collaborator)?;
this.update(&mut cx, |this, cx| {
this.shared_buffers.remove(&collaborator.peer_id);
cx.emit(Event::CollaboratorJoined(collaborator.peer_id));
this.collaborators
.insert(collaborator.peer_id, collaborator);
cx.notify();
@ -7756,6 +7759,7 @@ impl Collaborator {
Ok(Self {
peer_id: message.peer_id.ok_or_else(|| anyhow!("invalid peer id"))?,
replica_id: message.replica_id as ReplicaId,
user_id: message.user_id as UserId,
})
}
}

View file

@ -3,7 +3,7 @@ use anyhow::{Context, Result};
use client::proto;
use globset::{Glob, GlobMatcher};
use itertools::Itertools;
use language::{char_kind, Rope};
use language::{char_kind, BufferSnapshot};
use regex::{Regex, RegexBuilder};
use smol::future::yield_now;
use std::{
@ -39,6 +39,7 @@ pub enum SearchQuery {
case_sensitive: bool,
inner: SearchInputs,
},
Regex {
regex: Regex,
@ -214,12 +215,24 @@ impl SearchQuery {
}
}
pub async fn search(&self, rope: &Rope) -> Vec<Range<usize>> {
pub async fn search(
&self,
buffer: &BufferSnapshot,
subrange: Option<Range<usize>>,
) -> Vec<Range<usize>> {
const YIELD_INTERVAL: usize = 20000;
if self.as_str().is_empty() {
return Default::default();
}
let language = buffer.language_at(0);
let rope = if let Some(range) = subrange {
buffer.as_rope().slice(range)
} else {
buffer.as_rope().clone()
};
let kind = |c| char_kind(language, c);
let mut matches = Vec::new();
match self {
@ -236,10 +249,10 @@ impl SearchQuery {
let mat = mat.unwrap();
if *whole_word {
let prev_kind = rope.reversed_chars_at(mat.start()).next().map(char_kind);
let start_kind = char_kind(rope.chars_at(mat.start()).next().unwrap());
let end_kind = char_kind(rope.reversed_chars_at(mat.end()).next().unwrap());
let next_kind = rope.chars_at(mat.end()).next().map(char_kind);
let prev_kind = rope.reversed_chars_at(mat.start()).next().map(kind);
let start_kind = kind(rope.chars_at(mat.start()).next().unwrap());
let end_kind = kind(rope.reversed_chars_at(mat.end()).next().unwrap());
let next_kind = rope.chars_at(mat.end()).next().map(kind);
if Some(start_kind) == prev_kind || Some(end_kind) == next_kind {
continue;
}
@ -247,6 +260,7 @@ impl SearchQuery {
matches.push(mat.start()..mat.end())
}
}
Self::Regex {
regex, multiline, ..
} => {
@ -284,6 +298,7 @@ impl SearchQuery {
}
}
}
matches
}