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
This commit is contained in:
tidely 2025-08-20 13:20:13 +03:00 committed by GitHub
parent cf7c64d77f
commit 7bdc99abc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
306 changed files with 805 additions and 1102 deletions

View file

@ -840,6 +840,7 @@ match_like_matches_macro = "warn"
module_inception = { level = "deny" } module_inception = { level = "deny" }
question_mark = { level = "deny" } question_mark = { level = "deny" }
single_match = "warn" single_match = "warn"
redundant_clone = "warn"
redundant_closure = { level = "deny" } redundant_closure = { level = "deny" }
redundant_static_lifetimes = { level = "warn" } redundant_static_lifetimes = { level = "warn" }
redundant_pattern_matching = "warn" redundant_pattern_matching = "warn"

View file

@ -471,7 +471,7 @@ impl ContentBlock {
fn block_string_contents(&self, block: acp::ContentBlock) -> String { fn block_string_contents(&self, block: acp::ContentBlock) -> String {
match block { match block {
acp::ContentBlock::Text(text_content) => text_content.text.clone(), acp::ContentBlock::Text(text_content) => text_content.text,
acp::ContentBlock::ResourceLink(resource_link) => { acp::ContentBlock::ResourceLink(resource_link) => {
Self::resource_link_md(&resource_link.uri) Self::resource_link_md(&resource_link.uri)
} }
@ -1020,7 +1020,7 @@ impl AcpThread {
let location_updated = update.fields.locations.is_some(); let location_updated = update.fields.locations.is_some();
current_call.update_fields(update.fields, languages, cx); current_call.update_fields(update.fields, languages, cx);
if location_updated { if location_updated {
self.resolve_locations(update.id.clone(), cx); self.resolve_locations(update.id, cx);
} }
} }
ToolCallUpdate::UpdateDiff(update) => { ToolCallUpdate::UpdateDiff(update) => {

View file

@ -222,7 +222,7 @@ impl PendingDiff {
fn finalize(&self, cx: &mut Context<Diff>) -> FinalizedDiff { fn finalize(&self, cx: &mut Context<Diff>) -> FinalizedDiff {
let ranges = self.excerpt_ranges(cx); let ranges = self.excerpt_ranges(cx);
let base_text = self.base_text.clone(); let base_text = self.base_text.clone();
let language_registry = self.buffer.read(cx).language_registry().clone(); let language_registry = self.buffer.read(cx).language_registry();
let path = self let path = self
.buffer .buffer
@ -248,7 +248,6 @@ impl PendingDiff {
let buffer_diff = cx.spawn({ let buffer_diff = cx.spawn({
let buffer = buffer.clone(); let buffer = buffer.clone();
let language_registry = language_registry.clone();
async move |_this, cx| { async move |_this, cx| {
build_buffer_diff(base_text, &buffer, language_registry, cx).await build_buffer_diff(base_text, &buffer, language_registry, cx).await
} }

View file

@ -161,7 +161,7 @@ impl ActionLog {
diff_base, diff_base,
last_seen_base, last_seen_base,
unreviewed_edits, unreviewed_edits,
snapshot: text_snapshot.clone(), snapshot: text_snapshot,
status, status,
version: buffer.read(cx).version(), version: buffer.read(cx).version(),
diff, diff,
@ -461,7 +461,7 @@ impl ActionLog {
anyhow::Ok(( anyhow::Ok((
tracked_buffer.diff.clone(), tracked_buffer.diff.clone(),
buffer.read(cx).language().cloned(), buffer.read(cx).language().cloned(),
buffer.read(cx).language_registry().clone(), buffer.read(cx).language_registry(),
)) ))
})??; })??;
let diff_snapshot = BufferDiff::update_diff( let diff_snapshot = BufferDiff::update_diff(
@ -529,12 +529,12 @@ impl ActionLog {
/// Mark a buffer as created by agent, so we can refresh it in the context /// Mark a buffer as created by agent, so we can refresh it in the context
pub fn buffer_created(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) { pub fn buffer_created(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) {
self.track_buffer_internal(buffer.clone(), true, cx); self.track_buffer_internal(buffer, true, cx);
} }
/// Mark a buffer as edited by agent, so we can refresh it in the context /// Mark a buffer as edited by agent, so we can refresh it in the context
pub fn buffer_edited(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) { pub fn buffer_edited(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) {
let tracked_buffer = self.track_buffer_internal(buffer.clone(), false, cx); let tracked_buffer = self.track_buffer_internal(buffer, false, cx);
if let TrackedBufferStatus::Deleted = tracked_buffer.status { if let TrackedBufferStatus::Deleted = tracked_buffer.status {
tracked_buffer.status = TrackedBufferStatus::Modified; tracked_buffer.status = TrackedBufferStatus::Modified;
} }
@ -2425,7 +2425,7 @@ mod tests {
assert_eq!( assert_eq!(
unreviewed_hunks(&action_log, cx), unreviewed_hunks(&action_log, cx),
vec![( vec![(
buffer.clone(), buffer,
vec![ vec![
HunkStatus { HunkStatus {
range: Point::new(6, 0)..Point::new(7, 0), range: Point::new(6, 0)..Point::new(7, 0),

View file

@ -132,7 +132,7 @@ mod tests {
}); });
let tool_set = default_tool_set(cx); let tool_set = default_tool_set(cx);
let profile = AgentProfile::new(id.clone(), tool_set); let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx)) .read(|cx| profile.enabled_tools(cx))
@ -169,7 +169,7 @@ mod tests {
}); });
let tool_set = default_tool_set(cx); let tool_set = default_tool_set(cx);
let profile = AgentProfile::new(id.clone(), tool_set); let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx)) .read(|cx| profile.enabled_tools(cx))
@ -202,7 +202,7 @@ mod tests {
}); });
let tool_set = default_tool_set(cx); let tool_set = default_tool_set(cx);
let profile = AgentProfile::new(id.clone(), tool_set); let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx)) .read(|cx| profile.enabled_tools(cx))

View file

@ -86,15 +86,13 @@ impl Tool for ContextServerTool {
) -> ToolResult { ) -> ToolResult {
if let Some(server) = self.store.read(cx).get_running_server(&self.server_id) { if let Some(server) = self.store.read(cx).get_running_server(&self.server_id) {
let tool_name = self.tool.name.clone(); let tool_name = self.tool.name.clone();
let server_clone = server.clone();
let input_clone = input.clone();
cx.spawn(async move |_cx| { cx.spawn(async move |_cx| {
let Some(protocol) = server_clone.client() else { let Some(protocol) = server.client() else {
bail!("Context server not initialized"); bail!("Context server not initialized");
}; };
let arguments = if let serde_json::Value::Object(map) = input_clone { let arguments = if let serde_json::Value::Object(map) = input {
Some(map.into_iter().collect()) Some(map.into_iter().collect())
} else { } else {
None None

View file

@ -494,7 +494,7 @@ impl Thread {
last_received_chunk_at: None, last_received_chunk_at: None,
request_callback: None, request_callback: None,
remaining_turns: u32::MAX, remaining_turns: u32::MAX,
configured_model: configured_model.clone(), configured_model,
profile: AgentProfile::new(profile_id, tools), profile: AgentProfile::new(profile_id, tools),
} }
} }
@ -532,7 +532,7 @@ impl Thread {
.and_then(|model| { .and_then(|model| {
let model = SelectedModel { let model = SelectedModel {
provider: model.provider.clone().into(), provider: model.provider.clone().into(),
model: model.model.clone().into(), model: model.model.into(),
}; };
registry.select_model(&model, cx) registry.select_model(&model, cx)
}) })
@ -1646,10 +1646,10 @@ impl Thread {
}; };
self.tool_use self.tool_use
.request_tool_use(tool_message_id, tool_use, tool_use_metadata.clone(), cx); .request_tool_use(tool_message_id, tool_use, tool_use_metadata, cx);
self.tool_use.insert_tool_output( self.tool_use.insert_tool_output(
tool_use_id.clone(), tool_use_id,
tool_name, tool_name,
tool_output, tool_output,
self.configured_model.as_ref(), self.configured_model.as_ref(),
@ -3241,7 +3241,7 @@ impl Thread {
self.configured_model.as_ref(), self.configured_model.as_ref(),
self.completion_mode, self.completion_mode,
); );
self.tool_finished(tool_use_id.clone(), None, true, window, cx); self.tool_finished(tool_use_id, None, true, window, cx);
} }
} }
@ -3873,7 +3873,7 @@ fn main() {{
AgentSettings { AgentSettings {
model_parameters: vec![LanguageModelParameters { model_parameters: vec![LanguageModelParameters {
provider: Some(model.provider_id().0.to_string().into()), provider: Some(model.provider_id().0.to_string().into()),
model: Some(model.id().0.clone()), model: Some(model.id().0),
temperature: Some(0.66), temperature: Some(0.66),
}], }],
..AgentSettings::get_global(cx).clone() ..AgentSettings::get_global(cx).clone()
@ -3893,7 +3893,7 @@ fn main() {{
AgentSettings { AgentSettings {
model_parameters: vec![LanguageModelParameters { model_parameters: vec![LanguageModelParameters {
provider: None, provider: None,
model: Some(model.id().0.clone()), model: Some(model.id().0),
temperature: Some(0.66), temperature: Some(0.66),
}], }],
..AgentSettings::get_global(cx).clone() ..AgentSettings::get_global(cx).clone()
@ -3933,7 +3933,7 @@ fn main() {{
AgentSettings { AgentSettings {
model_parameters: vec![LanguageModelParameters { model_parameters: vec![LanguageModelParameters {
provider: Some("anthropic".into()), provider: Some("anthropic".into()),
model: Some(model.id().0.clone()), model: Some(model.id().0),
temperature: Some(0.66), temperature: Some(0.66),
}], }],
..AgentSettings::get_global(cx).clone() ..AgentSettings::get_global(cx).clone()

View file

@ -255,7 +255,7 @@ impl NativeAgent {
}), }),
cx.subscribe(&thread_handle, Self::handle_thread_token_usage_updated), cx.subscribe(&thread_handle, Self::handle_thread_token_usage_updated),
cx.observe(&thread_handle, move |this, thread, cx| { cx.observe(&thread_handle, move |this, thread, cx| {
this.save_thread(thread.clone(), cx) this.save_thread(thread, cx)
}), }),
]; ];
@ -499,8 +499,8 @@ impl NativeAgent {
self.models.refresh_list(cx); self.models.refresh_list(cx);
let registry = LanguageModelRegistry::read_global(cx); let registry = LanguageModelRegistry::read_global(cx);
let default_model = registry.default_model().map(|m| m.model.clone()); let default_model = registry.default_model().map(|m| m.model);
let summarization_model = registry.thread_summary_model().map(|m| m.model.clone()); let summarization_model = registry.thread_summary_model().map(|m| m.model);
for session in self.sessions.values_mut() { for session in self.sessions.values_mut() {
session.thread.update(cx, |thread, cx| { session.thread.update(cx, |thread, cx| {

View file

@ -287,7 +287,7 @@ impl ThreadsDatabase {
.map_err(|e| anyhow!("Failed to create threads table: {}", e))?; .map_err(|e| anyhow!("Failed to create threads table: {}", e))?;
let db = Self { let db = Self {
executor: executor.clone(), executor,
connection: Arc::new(Mutex::new(connection)), connection: Arc::new(Mutex::new(connection)),
}; };
@ -325,7 +325,7 @@ impl ThreadsDatabase {
INSERT OR REPLACE INTO threads (id, summary, updated_at, data_type, data) VALUES (?, ?, ?, ?, ?) INSERT OR REPLACE INTO threads (id, summary, updated_at, data_type, data) VALUES (?, ?, ?, ?, ?)
"})?; "})?;
insert((id.0.clone(), title, updated_at, data_type, data))?; insert((id.0, title, updated_at, data_type, data))?;
Ok(()) Ok(())
} }
@ -434,7 +434,7 @@ mod tests {
let client = Client::new(clock, http_client, cx); let client = Client::new(clock, http_client, cx);
agent::init(cx); agent::init(cx);
agent_settings::init(cx); agent_settings::init(cx);
language_model::init(client.clone(), cx); language_model::init(client, cx);
}); });
} }

View file

@ -1401,7 +1401,7 @@ async fn test_agent_connection(cx: &mut TestAppContext) {
let client = Client::new(clock, http_client, cx); let client = Client::new(clock, http_client, cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
language_model::init(client.clone(), cx); language_model::init(client.clone(), cx);
language_models::init(user_store.clone(), client.clone(), cx); language_models::init(user_store, client.clone(), cx);
Project::init_settings(cx); Project::init_settings(cx);
LanguageModelRegistry::test(cx); LanguageModelRegistry::test(cx);
agent_settings::init(cx); agent_settings::init(cx);
@ -1854,7 +1854,7 @@ async fn setup(cx: &mut TestAppContext, model: TestModel) -> ThreadTest {
let client = Client::production(cx); let client = Client::production(cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
language_model::init(client.clone(), cx); language_model::init(client.clone(), cx);
language_models::init(user_store.clone(), client.clone(), cx); language_models::init(user_store, client.clone(), cx);
watch_settings(fs.clone(), cx); watch_settings(fs.clone(), cx);
}); });

View file

@ -679,7 +679,7 @@ impl Thread {
.and_then(|model| { .and_then(|model| {
let model = SelectedModel { let model = SelectedModel {
provider: model.provider.clone().into(), provider: model.provider.clone().into(),
model: model.model.clone().into(), model: model.model.into(),
}; };
registry.select_model(&model, cx) registry.select_model(&model, cx)
}) })

View file

@ -176,15 +176,13 @@ impl AnyAgentTool for ContextServerTool {
return Task::ready(Err(anyhow!("Context server not found"))); return Task::ready(Err(anyhow!("Context server not found")));
}; };
let tool_name = self.tool.name.clone(); let tool_name = self.tool.name.clone();
let server_clone = server.clone();
let input_clone = input.clone();
cx.spawn(async move |_cx| { cx.spawn(async move |_cx| {
let Some(protocol) = server_clone.client() else { let Some(protocol) = server.client() else {
bail!("Context server not initialized"); bail!("Context server not initialized");
}; };
let arguments = if let serde_json::Value::Object(map) = input_clone { let arguments = if let serde_json::Value::Object(map) = input {
Some(map.into_iter().collect()) Some(map.into_iter().collect())
} else { } else {
None None

View file

@ -427,7 +427,7 @@ impl AgentTool for EditFileTool {
Ok(EditFileToolOutput { Ok(EditFileToolOutput {
input_path: input.path, input_path: input.path,
new_text: new_text.clone(), new_text,
old_text, old_text,
diff: unified_diff, diff: unified_diff,
edit_agent_output, edit_agent_output,

View file

@ -318,7 +318,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
fs.insert_tree( fs.insert_tree(
path!("/root"), path!("/root"),
serde_json::json!({ serde_json::json!({
@ -403,7 +403,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
fs.insert_tree( fs.insert_tree(
path!("/root"), path!("/root"),
serde_json::json!({ serde_json::json!({
@ -478,7 +478,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
// Create test file with syntax structures // Create test file with syntax structures
fs.insert_tree( fs.insert_tree(
@ -763,7 +763,7 @@ mod tests {
if cfg!(windows) { if cfg!(windows) {
result.replace("root\\", "root/") result.replace("root\\", "root/")
} else { } else {
result.to_string() result
} }
} }
Err(e) => panic!("Failed to run grep tool: {}", e), Err(e) => panic!("Failed to run grep tool: {}", e),

View file

@ -234,7 +234,7 @@ fn process_content(
if is_empty { if is_empty {
"Command executed successfully.".to_string() "Command executed successfully.".to_string()
} else { } else {
content.to_string() content
} }
} }
Some(exit_status) => { Some(exit_status) => {

View file

@ -787,7 +787,7 @@ impl Content {
pub fn chunks(self) -> impl Iterator<Item = ContentChunk> { pub fn chunks(self) -> impl Iterator<Item = ContentChunk> {
match self { match self {
Self::Chunks(chunks) => chunks.into_iter(), Self::Chunks(chunks) => chunks.into_iter(),
Self::UntaggedText(text) => vec![ContentChunk::Text { text: text.clone() }].into_iter(), Self::UntaggedText(text) => vec![ContentChunk::Text { text }].into_iter(),
} }
} }
} }

View file

@ -58,7 +58,7 @@ impl ClaudeTool {
Self::Terminal(None) Self::Terminal(None)
} else { } else {
Self::Other { Self::Other {
name: tool_name.to_string(), name: tool_name,
input, input,
} }
} }

View file

@ -89,7 +89,7 @@ impl ContextPickerCompletionProvider {
) -> Option<Completion> { ) -> Option<Completion> {
match entry { match entry {
ContextPickerEntry::Mode(mode) => Some(Completion { ContextPickerEntry::Mode(mode) => Some(Completion {
replace_range: source_range.clone(), replace_range: source_range,
new_text: format!("@{} ", mode.keyword()), new_text: format!("@{} ", mode.keyword()),
label: CodeLabel::plain(mode.label().to_string(), None), label: CodeLabel::plain(mode.label().to_string(), None),
icon_path: Some(mode.icon().path().into()), icon_path: Some(mode.icon().path().into()),
@ -146,7 +146,7 @@ impl ContextPickerCompletionProvider {
}; };
Some(Completion { Some(Completion {
replace_range: source_range.clone(), replace_range: source_range,
new_text, new_text,
label: CodeLabel::plain(action.label().to_string(), None), label: CodeLabel::plain(action.label().to_string(), None),
icon_path: Some(action.icon().path().into()), icon_path: Some(action.icon().path().into()),
@ -187,7 +187,7 @@ impl ContextPickerCompletionProvider {
documentation: None, documentation: None,
insert_text_mode: None, insert_text_mode: None,
source: project::CompletionSource::Custom, source: project::CompletionSource::Custom,
icon_path: Some(icon_for_completion.clone()), icon_path: Some(icon_for_completion),
confirm: Some(confirm_completion_callback( confirm: Some(confirm_completion_callback(
thread_entry.title().clone(), thread_entry.title().clone(),
source_range.start, source_range.start,
@ -218,9 +218,9 @@ impl ContextPickerCompletionProvider {
documentation: None, documentation: None,
insert_text_mode: None, insert_text_mode: None,
source: project::CompletionSource::Custom, source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()), icon_path: Some(icon_path),
confirm: Some(confirm_completion_callback( confirm: Some(confirm_completion_callback(
rule.title.clone(), rule.title,
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
editor, editor,
@ -260,7 +260,7 @@ impl ContextPickerCompletionProvider {
let completion_icon_path = if is_recent { let completion_icon_path = if is_recent {
IconName::HistoryRerun.path().into() IconName::HistoryRerun.path().into()
} else { } else {
crease_icon_path.clone() crease_icon_path
}; };
let new_text = format!("{} ", uri.as_link()); let new_text = format!("{} ", uri.as_link());
@ -309,10 +309,10 @@ impl ContextPickerCompletionProvider {
label, label,
documentation: None, documentation: None,
source: project::CompletionSource::Custom, source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()), icon_path: Some(icon_path),
insert_text_mode: None, insert_text_mode: None,
confirm: Some(confirm_completion_callback( confirm: Some(confirm_completion_callback(
symbol.name.clone().into(), symbol.name.into(),
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
message_editor, message_editor,
@ -327,7 +327,7 @@ impl ContextPickerCompletionProvider {
message_editor: WeakEntity<MessageEditor>, message_editor: WeakEntity<MessageEditor>,
cx: &mut App, cx: &mut App,
) -> Option<Completion> { ) -> Option<Completion> {
let new_text = format!("@fetch {} ", url_to_fetch.clone()); let new_text = format!("@fetch {} ", url_to_fetch);
let url_to_fetch = url::Url::parse(url_to_fetch.as_ref()) let url_to_fetch = url::Url::parse(url_to_fetch.as_ref())
.or_else(|_| url::Url::parse(&format!("https://{url_to_fetch}"))) .or_else(|_| url::Url::parse(&format!("https://{url_to_fetch}")))
.ok()?; .ok()?;
@ -341,7 +341,7 @@ impl ContextPickerCompletionProvider {
label: CodeLabel::plain(url_to_fetch.to_string(), None), label: CodeLabel::plain(url_to_fetch.to_string(), None),
documentation: None, documentation: None,
source: project::CompletionSource::Custom, source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()), icon_path: Some(icon_path),
insert_text_mode: None, insert_text_mode: None,
confirm: Some(confirm_completion_callback( confirm: Some(confirm_completion_callback(
url_to_fetch.to_string().into(), url_to_fetch.to_string().into(),
@ -365,8 +365,7 @@ impl ContextPickerCompletionProvider {
}; };
match mode { match mode {
Some(ContextPickerMode::File) => { Some(ContextPickerMode::File) => {
let search_files_task = let search_files_task = search_files(query, cancellation_flag, &workspace, cx);
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_files_task search_files_task
.await .await
@ -377,8 +376,7 @@ impl ContextPickerCompletionProvider {
} }
Some(ContextPickerMode::Symbol) => { Some(ContextPickerMode::Symbol) => {
let search_symbols_task = let search_symbols_task = search_symbols(query, cancellation_flag, &workspace, cx);
search_symbols(query.clone(), cancellation_flag.clone(), &workspace, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_symbols_task search_symbols_task
.await .await
@ -389,12 +387,8 @@ impl ContextPickerCompletionProvider {
} }
Some(ContextPickerMode::Thread) => { Some(ContextPickerMode::Thread) => {
let search_threads_task = search_threads( let search_threads_task =
query.clone(), search_threads(query, cancellation_flag, &self.history_store, cx);
cancellation_flag.clone(),
&self.history_store,
cx,
);
cx.background_spawn(async move { cx.background_spawn(async move {
search_threads_task search_threads_task
.await .await
@ -415,7 +409,7 @@ impl ContextPickerCompletionProvider {
Some(ContextPickerMode::Rules) => { Some(ContextPickerMode::Rules) => {
if let Some(prompt_store) = self.prompt_store.as_ref() { if let Some(prompt_store) = self.prompt_store.as_ref() {
let search_rules_task = let search_rules_task =
search_rules(query.clone(), cancellation_flag.clone(), prompt_store, cx); search_rules(query, cancellation_flag, prompt_store, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_rules_task search_rules_task
.await .await
@ -448,7 +442,7 @@ impl ContextPickerCompletionProvider {
let executor = cx.background_executor().clone(); let executor = cx.background_executor().clone();
let search_files_task = let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx); search_files(query.clone(), cancellation_flag, &workspace, cx);
let entries = self.available_context_picker_entries(&workspace, cx); let entries = self.available_context_picker_entries(&workspace, cx);
let entry_candidates = entries let entry_candidates = entries

View file

@ -260,7 +260,7 @@ impl MessageEditor {
*excerpt_id, *excerpt_id,
start, start,
content_len, content_len,
crease_text.clone(), crease_text,
mention_uri.icon_path(cx), mention_uri.icon_path(cx),
self.editor.clone(), self.editor.clone(),
window, window,
@ -883,7 +883,7 @@ impl MessageEditor {
.spawn_in(window, { .spawn_in(window, {
let abs_path = abs_path.clone(); let abs_path = abs_path.clone();
async move |_, cx| { async move |_, cx| {
let image = image.await.map_err(|e| e.to_string())?; let image = image.await?;
let format = image.format; let format = image.format;
let image = cx let image = cx
.update(|_, cx| LanguageModelImage::from_image(image, cx)) .update(|_, cx| LanguageModelImage::from_image(image, cx))
@ -1231,7 +1231,6 @@ fn render_image_fold_icon_button(
editor: WeakEntity<Editor>, editor: WeakEntity<Editor>,
) -> Arc<dyn Send + Sync + Fn(FoldId, Range<Anchor>, &mut App) -> AnyElement> { ) -> Arc<dyn Send + Sync + Fn(FoldId, Range<Anchor>, &mut App) -> AnyElement> {
Arc::new({ Arc::new({
let image_task = image_task.clone();
move |fold_id, fold_range, cx| { move |fold_id, fold_range, cx| {
let is_in_text_selection = editor let is_in_text_selection = editor
.update(cx, |editor, cx| editor.is_range_selected(&fold_range, cx)) .update(cx, |editor, cx| editor.is_range_selected(&fold_range, cx))
@ -1408,10 +1407,7 @@ impl MentionSet {
crease_id, crease_id,
Mention::Text { Mention::Text {
uri, uri,
content: content content: content.await.map_err(|e| anyhow::anyhow!("{e}"))?,
.await
.map_err(|e| anyhow::anyhow!("{e}"))?
.to_string(),
}, },
)) ))
}) })
@ -1478,10 +1474,7 @@ impl MentionSet {
crease_id, crease_id,
Mention::Text { Mention::Text {
uri, uri,
content: content content: content.await.map_err(|e| anyhow::anyhow!("{e}"))?,
.await
.map_err(|e| anyhow::anyhow!("{e}"))?
.to_string(),
}, },
)) ))
}) })
@ -1821,7 +1814,7 @@ mod tests {
impl Focusable for MessageEditorItem { impl Focusable for MessageEditorItem {
fn focus_handle(&self, cx: &App) -> FocusHandle { fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone() self.0.read(cx).focus_handle(cx)
} }
} }
@ -2219,7 +2212,7 @@ mod tests {
let completions = editor.current_completions().expect("Missing completions"); let completions = editor.current_completions().expect("Missing completions");
completions completions
.into_iter() .into_iter()
.map(|completion| completion.label.text.to_string()) .map(|completion| completion.label.text)
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }
} }

View file

@ -1534,7 +1534,7 @@ impl AcpThreadView {
window: &Window, window: &Window,
cx: &Context<Self>, cx: &Context<Self>,
) -> AnyElement { ) -> AnyElement {
let button_id = SharedString::from(format!("tool_output-{:?}", tool_call_id.clone())); let button_id = SharedString::from(format!("tool_output-{:?}", tool_call_id));
v_flex() v_flex()
.mt_1p5() .mt_1p5()
@ -1555,9 +1555,8 @@ impl AcpThreadView {
.icon_color(Color::Muted) .icon_color(Color::Muted)
.icon_position(IconPosition::Start) .icon_position(IconPosition::Start)
.on_click(cx.listener({ .on_click(cx.listener({
let id = tool_call_id.clone();
move |this: &mut Self, _, _, cx: &mut Context<Self>| { move |this: &mut Self, _, _, cx: &mut Context<Self>| {
this.expanded_tool_calls.remove(&id); this.expanded_tool_calls.remove(&tool_call_id);
cx.notify(); cx.notify();
} }
})), })),
@ -1578,7 +1577,7 @@ impl AcpThreadView {
uri.clone() uri.clone()
}; };
let button_id = SharedString::from(format!("item-{}", uri.clone())); let button_id = SharedString::from(format!("item-{}", uri));
div() div()
.ml(px(7.)) .ml(px(7.))
@ -1724,7 +1723,7 @@ impl AcpThreadView {
&& let Some(editor) = entry.editor_for_diff(diff) && let Some(editor) = entry.editor_for_diff(diff)
&& diff.read(cx).has_revealed_range(cx) && diff.read(cx).has_revealed_range(cx)
{ {
editor.clone().into_any_element() editor.into_any_element()
} else if tool_progress { } else if tool_progress {
self.render_diff_loading(cx) self.render_diff_loading(cx)
} else { } else {
@ -2888,7 +2887,6 @@ impl AcpThreadView {
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
.icon_color(Color::Muted) .icon_color(Color::Muted)
.tooltip({ .tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
expand_tooltip, expand_tooltip,
@ -4372,7 +4370,7 @@ pub(crate) mod tests {
impl Focusable for ThreadViewItem { impl Focusable for ThreadViewItem {
fn focus_handle(&self, cx: &App) -> FocusHandle { fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone() self.0.read(cx).focus_handle(cx)
} }
} }

View file

@ -491,7 +491,7 @@ fn render_markdown_code_block(
.on_click({ .on_click({
let active_thread = active_thread.clone(); let active_thread = active_thread.clone();
let parsed_markdown = parsed_markdown.clone(); let parsed_markdown = parsed_markdown.clone();
let code_block_range = metadata.content_range.clone(); let code_block_range = metadata.content_range;
move |_event, _window, cx| { move |_event, _window, cx| {
active_thread.update(cx, |this, cx| { active_thread.update(cx, |this, cx| {
this.copied_code_block_ids.insert((message_id, ix)); this.copied_code_block_ids.insert((message_id, ix));
@ -532,7 +532,6 @@ fn render_markdown_code_block(
"Expand Code" "Expand Code"
})) }))
.on_click({ .on_click({
let active_thread = active_thread.clone();
move |_event, _window, cx| { move |_event, _window, cx| {
active_thread.update(cx, |this, cx| { active_thread.update(cx, |this, cx| {
this.toggle_codeblock_expanded(message_id, ix); this.toggle_codeblock_expanded(message_id, ix);
@ -916,7 +915,7 @@ impl ActiveThread {
) { ) {
let rendered = self let rendered = self
.rendered_tool_uses .rendered_tool_uses
.entry(tool_use_id.clone()) .entry(tool_use_id)
.or_insert_with(|| RenderedToolUse { .or_insert_with(|| RenderedToolUse {
label: cx.new(|cx| { label: cx.new(|cx| {
Markdown::new("".into(), Some(self.language_registry.clone()), None, cx) Markdown::new("".into(), Some(self.language_registry.clone()), None, cx)
@ -1218,7 +1217,7 @@ impl ActiveThread {
match AgentSettings::get_global(cx).notify_when_agent_waiting { match AgentSettings::get_global(cx).notify_when_agent_waiting {
NotifyWhenAgentWaiting::PrimaryScreen => { NotifyWhenAgentWaiting::PrimaryScreen => {
if let Some(primary) = cx.primary_display() { if let Some(primary) = cx.primary_display() {
self.pop_up(icon, caption.into(), title.clone(), window, primary, cx); self.pop_up(icon, caption.into(), title, window, primary, cx);
} }
} }
NotifyWhenAgentWaiting::AllScreens => { NotifyWhenAgentWaiting::AllScreens => {
@ -2112,7 +2111,7 @@ impl ActiveThread {
.gap_1() .gap_1()
.children(message_content) .children(message_content)
.when_some(editing_message_state, |this, state| { .when_some(editing_message_state, |this, state| {
let focus_handle = state.editor.focus_handle(cx).clone(); let focus_handle = state.editor.focus_handle(cx);
this.child( this.child(
h_flex() h_flex()
@ -2173,7 +2172,6 @@ impl ActiveThread {
.icon_color(Color::Muted) .icon_color(Color::Muted)
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
.tooltip({ .tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
"Regenerate", "Regenerate",
@ -2312,7 +2310,7 @@ impl ActiveThread {
.into_any_element() .into_any_element()
} else if let Some(error) = error { } else if let Some(error) = error {
restore_checkpoint_button restore_checkpoint_button
.tooltip(Tooltip::text(error.to_string())) .tooltip(Tooltip::text(error))
.into_any_element() .into_any_element()
} else { } else {
restore_checkpoint_button.into_any_element() restore_checkpoint_button.into_any_element()

View file

@ -165,8 +165,8 @@ impl AgentConfiguration {
provider: &Arc<dyn LanguageModelProvider>, provider: &Arc<dyn LanguageModelProvider>,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> impl IntoElement + use<> { ) -> impl IntoElement + use<> {
let provider_id = provider.id().0.clone(); let provider_id = provider.id().0;
let provider_name = provider.name().0.clone(); let provider_name = provider.name().0;
let provider_id_string = SharedString::from(format!("provider-disclosure-{provider_id}")); let provider_id_string = SharedString::from(format!("provider-disclosure-{provider_id}"));
let configuration_view = self let configuration_view = self
@ -269,7 +269,7 @@ impl AgentConfiguration {
.closed_icon(IconName::ChevronDown), .closed_icon(IconName::ChevronDown),
) )
.on_click(cx.listener({ .on_click(cx.listener({
let provider_id = provider.id().clone(); let provider_id = provider.id();
move |this, _event, _window, _cx| { move |this, _event, _window, _cx| {
let is_expanded = this let is_expanded = this
.expanded_provider_configurations .expanded_provider_configurations
@ -665,7 +665,7 @@ impl AgentConfiguration {
.size(IconSize::XSmall) .size(IconSize::XSmall)
.color(Color::Accent) .color(Color::Accent)
.with_animation( .with_animation(
SharedString::from(format!("{}-starting", context_server_id.0.clone(),)), SharedString::from(format!("{}-starting", context_server_id.0,)),
Animation::new(Duration::from_secs(3)).repeat(), Animation::new(Duration::from_secs(3)).repeat(),
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))), |icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
) )
@ -865,7 +865,6 @@ impl AgentConfiguration {
.on_click({ .on_click({
let context_server_manager = let context_server_manager =
self.context_server_store.clone(); self.context_server_store.clone();
let context_server_id = context_server_id.clone();
let fs = self.fs.clone(); let fs = self.fs.clone();
move |state, _window, cx| { move |state, _window, cx| {
@ -1075,7 +1074,6 @@ fn show_unable_to_uninstall_extension_with_context_server(
cx, cx,
move |this, _cx| { move |this, _cx| {
let workspace_handle = workspace_handle.clone(); let workspace_handle = workspace_handle.clone();
let context_server_id = context_server_id.clone();
this.icon(ToastIcon::new(IconName::Warning).color(Color::Warning)) this.icon(ToastIcon::new(IconName::Warning).color(Color::Warning))
.dismiss_button(true) .dismiss_button(true)

View file

@ -261,7 +261,6 @@ impl ConfigureContextServerModal {
_cx: &mut Context<Workspace>, _cx: &mut Context<Workspace>,
) { ) {
workspace.register_action({ workspace.register_action({
let language_registry = language_registry.clone();
move |_workspace, _: &AddContextServer, window, cx| { move |_workspace, _: &AddContextServer, window, cx| {
let workspace_handle = cx.weak_entity(); let workspace_handle = cx.weak_entity();
let language_registry = language_registry.clone(); let language_registry = language_registry.clone();

View file

@ -464,7 +464,7 @@ impl ManageProfilesModal {
}, },
)) ))
.child(ListSeparator) .child(ListSeparator)
.child(h_flex().p_2().child(mode.name_editor.clone())) .child(h_flex().p_2().child(mode.name_editor))
} }
fn render_view_profile( fn render_view_profile(

View file

@ -185,7 +185,7 @@ impl AgentDiffPane {
let focus_handle = cx.focus_handle(); let focus_handle = cx.focus_handle();
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite)); let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
let project = thread.project(cx).clone(); let project = thread.project(cx);
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let mut editor = let mut editor =
Editor::for_multibuffer(multibuffer.clone(), Some(project.clone()), window, cx); Editor::for_multibuffer(multibuffer.clone(), Some(project.clone()), window, cx);
@ -196,7 +196,7 @@ impl AgentDiffPane {
editor editor
}); });
let action_log = thread.action_log(cx).clone(); let action_log = thread.action_log(cx);
let mut this = Self { let mut this = Self {
_subscriptions: vec![ _subscriptions: vec![
@ -1312,7 +1312,7 @@ impl AgentDiff {
let entity = cx.new(|_cx| Self::default()); let entity = cx.new(|_cx| Self::default());
let global = AgentDiffGlobal(entity.clone()); let global = AgentDiffGlobal(entity.clone());
cx.set_global(global); cx.set_global(global);
entity.clone() entity
}) })
} }
@ -1334,7 +1334,7 @@ impl AgentDiff {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let action_log = thread.action_log(cx).clone(); let action_log = thread.action_log(cx);
let action_log_subscription = cx.observe_in(&action_log, window, { let action_log_subscription = cx.observe_in(&action_log, window, {
let workspace = workspace.clone(); let workspace = workspace.clone();
@ -1544,7 +1544,7 @@ impl AgentDiff {
&& let Some(editor) = item.downcast::<Editor>() && let Some(editor) = item.downcast::<Editor>()
&& let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) && let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx)
{ {
self.register_editor(workspace.downgrade(), buffer.clone(), editor, window, cx); self.register_editor(workspace.downgrade(), buffer, editor, window, cx);
} }
} }

View file

@ -66,10 +66,8 @@ impl AgentModelSelector {
fs.clone(), fs.clone(),
cx, cx,
move |settings, _cx| { move |settings, _cx| {
settings.set_inline_assistant_model( settings
provider.clone(), .set_inline_assistant_model(provider.clone(), model_id);
model_id.clone(),
);
}, },
); );
} }

View file

@ -956,7 +956,7 @@ impl AgentPanel {
message_editor.focus_handle(cx).focus(window); message_editor.focus_handle(cx).focus(window);
let thread_view = ActiveView::thread(active_thread.clone(), message_editor, window, cx); let thread_view = ActiveView::thread(active_thread, message_editor, window, cx);
self.set_active_view(thread_view, window, cx); self.set_active_view(thread_view, window, cx);
AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx); AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx);
@ -1163,7 +1163,7 @@ impl AgentPanel {
}); });
self.set_active_view( self.set_active_view(
ActiveView::prompt_editor( ActiveView::prompt_editor(
editor.clone(), editor,
self.history_store.clone(), self.history_store.clone(),
self.acp_history_store.clone(), self.acp_history_store.clone(),
self.language_registry.clone(), self.language_registry.clone(),
@ -1236,7 +1236,7 @@ impl AgentPanel {
}); });
message_editor.focus_handle(cx).focus(window); message_editor.focus_handle(cx).focus(window);
let thread_view = ActiveView::thread(active_thread.clone(), message_editor, window, cx); let thread_view = ActiveView::thread(active_thread, message_editor, window, cx);
self.set_active_view(thread_view, window, cx); self.set_active_view(thread_view, window, cx);
AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx); AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx);
} }
@ -1525,7 +1525,7 @@ impl AgentPanel {
return; return;
} }
let model = thread_state.configured_model().map(|cm| cm.model.clone()); let model = thread_state.configured_model().map(|cm| cm.model);
if let Some(model) = model { if let Some(model) = model {
thread.update(cx, |active_thread, cx| { thread.update(cx, |active_thread, cx| {
active_thread.thread().update(cx, |thread, cx| { active_thread.thread().update(cx, |thread, cx| {
@ -1680,7 +1680,7 @@ impl AgentPanel {
.open_thread_by_id(&id, window, cx) .open_thread_by_id(&id, window, cx)
.detach_and_log_err(cx), .detach_and_log_err(cx),
HistoryEntryId::Context(path) => this HistoryEntryId::Context(path) => this
.open_saved_prompt_editor(path.clone(), window, cx) .open_saved_prompt_editor(path, window, cx)
.detach_and_log_err(cx), .detach_and_log_err(cx),
}) })
.ok(); .ok();
@ -1966,7 +1966,7 @@ impl AgentPanel {
}; };
match state { match state {
ThreadSummary::Pending => Label::new(ThreadSummary::DEFAULT.clone()) ThreadSummary::Pending => Label::new(ThreadSummary::DEFAULT)
.truncate() .truncate()
.into_any_element(), .into_any_element(),
ThreadSummary::Generating => Label::new(LOADING_SUMMARY_PLACEHOLDER) ThreadSummary::Generating => Label::new(LOADING_SUMMARY_PLACEHOLDER)
@ -2106,7 +2106,6 @@ impl AgentPanel {
.anchor(Corner::TopRight) .anchor(Corner::TopRight)
.with_handle(self.agent_panel_menu_handle.clone()) .with_handle(self.agent_panel_menu_handle.clone())
.menu({ .menu({
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Some(ContextMenu::build(window, cx, |mut menu, _window, _| { Some(ContextMenu::build(window, cx, |mut menu, _window, _| {
menu = menu.context(focus_handle.clone()); menu = menu.context(focus_handle.clone());
@ -2184,7 +2183,6 @@ impl AgentPanel {
.trigger_with_tooltip( .trigger_with_tooltip(
IconButton::new("agent-nav-menu", icon).icon_size(IconSize::Small), IconButton::new("agent-nav-menu", icon).icon_size(IconSize::Small),
{ {
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
"Toggle Recent Threads", "Toggle Recent Threads",
@ -2222,8 +2220,6 @@ impl AgentPanel {
this.go_back(&workspace::GoBack, window, cx); this.go_back(&workspace::GoBack, window, cx);
})) }))
.tooltip({ .tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Tooltip::for_action_in("Go Back", &workspace::GoBack, &focus_handle, window, cx) Tooltip::for_action_in("Go Back", &workspace::GoBack, &focus_handle, window, cx)
} }
@ -2249,7 +2245,6 @@ impl AgentPanel {
.anchor(Corner::TopRight) .anchor(Corner::TopRight)
.with_handle(self.new_thread_menu_handle.clone()) .with_handle(self.new_thread_menu_handle.clone())
.menu({ .menu({
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
let active_thread = active_thread.clone(); let active_thread = active_thread.clone();
Some(ContextMenu::build(window, cx, |mut menu, _window, cx| { Some(ContextMenu::build(window, cx, |mut menu, _window, cx| {
@ -2377,7 +2372,6 @@ impl AgentPanel {
.anchor(Corner::TopLeft) .anchor(Corner::TopLeft)
.with_handle(self.new_thread_menu_handle.clone()) .with_handle(self.new_thread_menu_handle.clone())
.menu({ .menu({
let focus_handle = focus_handle.clone();
let workspace = self.workspace.clone(); let workspace = self.workspace.clone();
move |window, cx| { move |window, cx| {
@ -3015,7 +3009,7 @@ impl AgentPanel {
// TODO: Add keyboard navigation. // TODO: Add keyboard navigation.
let is_hovered = let is_hovered =
self.hovered_recent_history_item == Some(index); self.hovered_recent_history_item == Some(index);
HistoryEntryElement::new(entry.clone(), cx.entity().downgrade()) HistoryEntryElement::new(entry, cx.entity().downgrade())
.hovered(is_hovered) .hovered(is_hovered)
.on_hover(cx.listener( .on_hover(cx.listener(
move |this, is_hovered, _window, cx| { move |this, is_hovered, _window, cx| {
@ -3339,7 +3333,7 @@ impl AgentPanel {
.severity(Severity::Error) .severity(Severity::Error)
.icon(IconName::XCircle) .icon(IconName::XCircle)
.title(header) .title(header)
.description(message.clone()) .description(message)
.actions_slot( .actions_slot(
h_flex() h_flex()
.gap_0p5() .gap_0p5()
@ -3359,7 +3353,7 @@ impl AgentPanel {
Callout::new() Callout::new()
.severity(Severity::Error) .severity(Severity::Error)
.title("Error") .title("Error")
.description(message.clone()) .description(message)
.actions_slot( .actions_slot(
h_flex() h_flex()
.gap_0p5() .gap_0p5()

View file

@ -240,12 +240,7 @@ pub fn init(
client.telemetry().clone(), client.telemetry().clone(),
cx, cx,
); );
terminal_inline_assistant::init( terminal_inline_assistant::init(fs.clone(), prompt_builder, client.telemetry().clone(), cx);
fs.clone(),
prompt_builder.clone(),
client.telemetry().clone(),
cx,
);
cx.observe_new(move |workspace, window, cx| { cx.observe_new(move |workspace, window, cx| {
ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx) ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx)
}) })
@ -391,7 +386,6 @@ fn register_slash_commands(cx: &mut App) {
slash_command_registry.register_command(assistant_slash_commands::FetchSlashCommand, true); slash_command_registry.register_command(assistant_slash_commands::FetchSlashCommand, true);
cx.observe_flag::<assistant_slash_commands::StreamingExampleSlashCommandFeatureFlag, _>({ cx.observe_flag::<assistant_slash_commands::StreamingExampleSlashCommandFeatureFlag, _>({
let slash_command_registry = slash_command_registry.clone();
move |is_enabled, _cx| { move |is_enabled, _cx| {
if is_enabled { if is_enabled {
slash_command_registry.register_command( slash_command_registry.register_command(

View file

@ -1129,7 +1129,7 @@ mod tests {
) )
}); });
let chunks_tx = simulate_response_stream(codegen.clone(), cx); let chunks_tx = simulate_response_stream(&codegen, cx);
let mut new_text = concat!( let mut new_text = concat!(
" let mut x = 0;\n", " let mut x = 0;\n",
@ -1196,7 +1196,7 @@ mod tests {
) )
}); });
let chunks_tx = simulate_response_stream(codegen.clone(), cx); let chunks_tx = simulate_response_stream(&codegen, cx);
cx.background_executor.run_until_parked(); cx.background_executor.run_until_parked();
@ -1265,7 +1265,7 @@ mod tests {
) )
}); });
let chunks_tx = simulate_response_stream(codegen.clone(), cx); let chunks_tx = simulate_response_stream(&codegen, cx);
cx.background_executor.run_until_parked(); cx.background_executor.run_until_parked();
@ -1334,7 +1334,7 @@ mod tests {
) )
}); });
let chunks_tx = simulate_response_stream(codegen.clone(), cx); let chunks_tx = simulate_response_stream(&codegen, cx);
let new_text = concat!( let new_text = concat!(
"func main() {\n", "func main() {\n",
"\tx := 0\n", "\tx := 0\n",
@ -1391,7 +1391,7 @@ mod tests {
) )
}); });
let chunks_tx = simulate_response_stream(codegen.clone(), cx); let chunks_tx = simulate_response_stream(&codegen, cx);
chunks_tx chunks_tx
.unbounded_send("let mut x = 0;\nx += 1;".to_string()) .unbounded_send("let mut x = 0;\nx += 1;".to_string())
.unwrap(); .unwrap();
@ -1473,7 +1473,7 @@ mod tests {
} }
fn simulate_response_stream( fn simulate_response_stream(
codegen: Entity<CodegenAlternative>, codegen: &Entity<CodegenAlternative>,
cx: &mut TestAppContext, cx: &mut TestAppContext,
) -> mpsc::UnboundedSender<String> { ) -> mpsc::UnboundedSender<String> {
let (chunks_tx, chunks_rx) = mpsc::unbounded(); let (chunks_tx, chunks_rx) = mpsc::unbounded();

View file

@ -818,13 +818,8 @@ pub fn crease_for_mention(
let render_trailer = move |_row, _unfold, _window: &mut Window, _cx: &mut App| Empty.into_any(); let render_trailer = move |_row, _unfold, _window: &mut Window, _cx: &mut App| Empty.into_any();
Crease::inline( Crease::inline(range, placeholder, fold_toggle("mention"), render_trailer)
range, .with_metadata(CreaseMetadata { icon_path, label })
placeholder.clone(),
fold_toggle("mention"),
render_trailer,
)
.with_metadata(CreaseMetadata { icon_path, label })
} }
fn render_fold_icon_button( fn render_fold_icon_button(

View file

@ -79,8 +79,7 @@ fn search(
) -> Task<Vec<Match>> { ) -> Task<Vec<Match>> {
match mode { match mode {
Some(ContextPickerMode::File) => { Some(ContextPickerMode::File) => {
let search_files_task = let search_files_task = search_files(query, cancellation_flag, &workspace, cx);
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_files_task search_files_task
.await .await
@ -91,8 +90,7 @@ fn search(
} }
Some(ContextPickerMode::Symbol) => { Some(ContextPickerMode::Symbol) => {
let search_symbols_task = let search_symbols_task = search_symbols(query, cancellation_flag, &workspace, cx);
search_symbols(query.clone(), cancellation_flag.clone(), &workspace, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_symbols_task search_symbols_task
.await .await
@ -108,13 +106,8 @@ fn search(
.and_then(|t| t.upgrade()) .and_then(|t| t.upgrade())
.zip(text_thread_context_store.as_ref().and_then(|t| t.upgrade())) .zip(text_thread_context_store.as_ref().and_then(|t| t.upgrade()))
{ {
let search_threads_task = search_threads( let search_threads_task =
query.clone(), search_threads(query, cancellation_flag, thread_store, context_store, cx);
cancellation_flag.clone(),
thread_store,
context_store,
cx,
);
cx.background_spawn(async move { cx.background_spawn(async move {
search_threads_task search_threads_task
.await .await
@ -137,8 +130,7 @@ fn search(
Some(ContextPickerMode::Rules) => { Some(ContextPickerMode::Rules) => {
if let Some(prompt_store) = prompt_store.as_ref() { if let Some(prompt_store) = prompt_store.as_ref() {
let search_rules_task = let search_rules_task = search_rules(query, cancellation_flag, prompt_store, cx);
search_rules(query.clone(), cancellation_flag.clone(), prompt_store, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
search_rules_task search_rules_task
.await .await
@ -196,7 +188,7 @@ fn search(
let executor = cx.background_executor().clone(); let executor = cx.background_executor().clone();
let search_files_task = let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx); search_files(query.clone(), cancellation_flag, &workspace, cx);
let entries = let entries =
available_context_picker_entries(&prompt_store, &thread_store, &workspace, cx); available_context_picker_entries(&prompt_store, &thread_store, &workspace, cx);
@ -283,7 +275,7 @@ impl ContextPickerCompletionProvider {
) -> Option<Completion> { ) -> Option<Completion> {
match entry { match entry {
ContextPickerEntry::Mode(mode) => Some(Completion { ContextPickerEntry::Mode(mode) => Some(Completion {
replace_range: source_range.clone(), replace_range: source_range,
new_text: format!("@{} ", mode.keyword()), new_text: format!("@{} ", mode.keyword()),
label: CodeLabel::plain(mode.label().to_string(), None), label: CodeLabel::plain(mode.label().to_string(), None),
icon_path: Some(mode.icon().path().into()), icon_path: Some(mode.icon().path().into()),
@ -330,9 +322,6 @@ impl ContextPickerCompletionProvider {
); );
let callback = Arc::new({ let callback = Arc::new({
let context_store = context_store.clone();
let selections = selections.clone();
let selection_infos = selection_infos.clone();
move |_, window: &mut Window, cx: &mut App| { move |_, window: &mut Window, cx: &mut App| {
context_store.update(cx, |context_store, cx| { context_store.update(cx, |context_store, cx| {
for (buffer, range) in &selections { for (buffer, range) in &selections {
@ -441,7 +430,7 @@ impl ContextPickerCompletionProvider {
excerpt_id, excerpt_id,
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
editor.clone(), editor,
context_store.clone(), context_store.clone(),
move |window, cx| match &thread_entry { move |window, cx| match &thread_entry {
ThreadContextEntry::Thread { id, .. } => { ThreadContextEntry::Thread { id, .. } => {
@ -510,7 +499,7 @@ impl ContextPickerCompletionProvider {
excerpt_id, excerpt_id,
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
editor.clone(), editor,
context_store.clone(), context_store.clone(),
move |_, cx| { move |_, cx| {
let user_prompt_id = rules.prompt_id; let user_prompt_id = rules.prompt_id;
@ -547,7 +536,7 @@ impl ContextPickerCompletionProvider {
excerpt_id, excerpt_id,
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
editor.clone(), editor,
context_store.clone(), context_store.clone(),
move |_, cx| { move |_, cx| {
let context_store = context_store.clone(); let context_store = context_store.clone();
@ -704,16 +693,16 @@ impl ContextPickerCompletionProvider {
excerpt_id, excerpt_id,
source_range.start, source_range.start,
new_text_len - 1, new_text_len - 1,
editor.clone(), editor,
context_store.clone(), context_store.clone(),
move |_, cx| { move |_, cx| {
let symbol = symbol.clone(); let symbol = symbol.clone();
let context_store = context_store.clone(); let context_store = context_store.clone();
let workspace = workspace.clone(); let workspace = workspace.clone();
let result = super::symbol_context_picker::add_symbol( let result = super::symbol_context_picker::add_symbol(
symbol.clone(), symbol,
false, false,
workspace.clone(), workspace,
context_store.downgrade(), context_store.downgrade(),
cx, cx,
); );
@ -1162,7 +1151,7 @@ mod tests {
impl Focusable for AtMentionEditor { impl Focusable for AtMentionEditor {
fn focus_handle(&self, cx: &App) -> FocusHandle { fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone() self.0.read(cx).focus_handle(cx)
} }
} }
@ -1480,7 +1469,7 @@ mod tests {
let completions = editor.current_completions().expect("Missing completions"); let completions = editor.current_completions().expect("Missing completions");
completions completions
.into_iter() .into_iter()
.map(|completion| completion.label.text.to_string()) .map(|completion| completion.label.text)
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }

View file

@ -1693,7 +1693,7 @@ impl InlineAssist {
}), }),
range, range,
codegen: codegen.clone(), codegen: codegen.clone(),
workspace: workspace.clone(), workspace,
_subscriptions: vec![ _subscriptions: vec![
window.on_focus_in(&prompt_editor_focus_handle, cx, move |_, cx| { window.on_focus_in(&prompt_editor_focus_handle, cx, move |_, cx| {
InlineAssistant::update_global(cx, |this, cx| { InlineAssistant::update_global(cx, |this, cx| {

View file

@ -93,7 +93,7 @@ impl LanguageModelPickerDelegate {
let entries = models.entries(); let entries = models.entries();
Self { Self {
on_model_changed: on_model_changed.clone(), on_model_changed,
all_models: Arc::new(models), all_models: Arc::new(models),
selected_index: Self::get_active_model_index(&entries, get_active_model(cx)), selected_index: Self::get_active_model_index(&entries, get_active_model(cx)),
filtered_entries: entries, filtered_entries: entries,
@ -514,7 +514,7 @@ impl PickerDelegate for LanguageModelPickerDelegate {
.pl_0p5() .pl_0p5()
.gap_1p5() .gap_1p5()
.w(px(240.)) .w(px(240.))
.child(Label::new(model_info.model.name().0.clone()).truncate()), .child(Label::new(model_info.model.name().0).truncate()),
) )
.end_slot(div().pr_3().when(is_selected, |this| { .end_slot(div().pr_3().when(is_selected, |this| {
this.child( this.child(

View file

@ -248,7 +248,7 @@ impl MessageEditor {
editor: editor.clone(), editor: editor.clone(),
project: thread.read(cx).project().clone(), project: thread.read(cx).project().clone(),
thread, thread,
incompatible_tools_state: incompatible_tools.clone(), incompatible_tools_state: incompatible_tools,
workspace, workspace,
context_store, context_store,
prompt_store, prompt_store,
@ -839,7 +839,6 @@ impl MessageEditor {
.child(self.profile_selector.clone()) .child(self.profile_selector.clone())
.child(self.model_selector.clone()) .child(self.model_selector.clone())
.map({ .map({
let focus_handle = focus_handle.clone();
move |parent| { move |parent| {
if is_generating { if is_generating {
parent parent
@ -1801,7 +1800,7 @@ impl AgentPreview for MessageEditor {
.bg(cx.theme().colors().panel_background) .bg(cx.theme().colors().panel_background)
.border_1() .border_1()
.border_color(cx.theme().colors().border) .border_color(cx.theme().colors().border)
.child(default_message_editor.clone()) .child(default_message_editor)
.into_any_element(), .into_any_element(),
)]) )])
.into_any_element(), .into_any_element(),

View file

@ -137,12 +137,11 @@ impl ProfileSelector {
entry.handler({ entry.handler({
let fs = self.fs.clone(); let fs = self.fs.clone();
let provider = self.provider.clone(); let provider = self.provider.clone();
let profile_id = profile_id.clone();
move |_window, cx| { move |_window, cx| {
update_settings_file::<AgentSettings>(fs.clone(), cx, { update_settings_file::<AgentSettings>(fs.clone(), cx, {
let profile_id = profile_id.clone(); let profile_id = profile_id.clone();
move |settings, _cx| { move |settings, _cx| {
settings.set_profile(profile_id.clone()); settings.set_profile(profile_id);
} }
}); });
@ -175,7 +174,6 @@ impl Render for ProfileSelector {
PopoverMenu::new("profile-selector") PopoverMenu::new("profile-selector")
.trigger_with_tooltip(trigger_button, { .trigger_with_tooltip(trigger_button, {
let focus_handle = focus_handle.clone();
move |window, cx| { move |window, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
"Toggle Profile Menu", "Toggle Profile Menu",

View file

@ -88,8 +88,6 @@ impl SlashCommandCompletionProvider {
.map(|(editor, workspace)| { .map(|(editor, workspace)| {
let command_name = mat.string.clone(); let command_name = mat.string.clone();
let command_range = command_range.clone(); let command_range = command_range.clone();
let editor = editor.clone();
let workspace = workspace.clone();
Arc::new( Arc::new(
move |intent: CompletionIntent, move |intent: CompletionIntent,
window: &mut Window, window: &mut Window,
@ -158,7 +156,7 @@ impl SlashCommandCompletionProvider {
if let Some(command) = self.slash_commands.command(command_name, cx) { if let Some(command) = self.slash_commands.command(command_name, cx) {
let completions = command.complete_argument( let completions = command.complete_argument(
arguments, arguments,
new_cancel_flag.clone(), new_cancel_flag,
self.workspace.clone(), self.workspace.clone(),
window, window,
cx, cx,

View file

@ -432,7 +432,7 @@ impl TerminalInlineAssist {
terminal: terminal.downgrade(), terminal: terminal.downgrade(),
prompt_editor: Some(prompt_editor.clone()), prompt_editor: Some(prompt_editor.clone()),
codegen: codegen.clone(), codegen: codegen.clone(),
workspace: workspace.clone(), workspace,
context_store, context_store,
prompt_store, prompt_store,
_subscriptions: vec![ _subscriptions: vec![

View file

@ -1739,7 +1739,7 @@ impl TextThreadEditor {
render_slash_command_output_toggle, render_slash_command_output_toggle,
|_, _, _, _| Empty.into_any(), |_, _, _, _| Empty.into_any(),
) )
.with_metadata(metadata.crease.clone()) .with_metadata(metadata.crease)
}), }),
cx, cx,
); );
@ -1810,7 +1810,7 @@ impl TextThreadEditor {
.filter_map(|(anchor, render_image)| { .filter_map(|(anchor, render_image)| {
const MAX_HEIGHT_IN_LINES: u32 = 8; const MAX_HEIGHT_IN_LINES: u32 = 8;
let anchor = buffer.anchor_in_excerpt(excerpt_id, anchor).unwrap(); let anchor = buffer.anchor_in_excerpt(excerpt_id, anchor).unwrap();
let image = render_image.clone(); let image = render_image;
anchor.is_valid(&buffer).then(|| BlockProperties { anchor.is_valid(&buffer).then(|| BlockProperties {
placement: BlockPlacement::Above(anchor), placement: BlockPlacement::Above(anchor),
height: Some(MAX_HEIGHT_IN_LINES), height: Some(MAX_HEIGHT_IN_LINES),
@ -1873,7 +1873,7 @@ impl TextThreadEditor {
} }
fn render_send_button(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render_send_button(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let focus_handle = self.focus_handle(cx).clone(); let focus_handle = self.focus_handle(cx);
let (style, tooltip) = match token_state(&self.context, cx) { let (style, tooltip) = match token_state(&self.context, cx) {
Some(TokenState::NoTokensLeft { .. }) => ( Some(TokenState::NoTokensLeft { .. }) => (
@ -2015,7 +2015,7 @@ impl TextThreadEditor {
None => IconName::Ai, None => IconName::Ai,
}; };
let focus_handle = self.editor().focus_handle(cx).clone(); let focus_handle = self.editor().focus_handle(cx);
PickerPopoverMenu::new( PickerPopoverMenu::new(
self.language_model_selector.clone(), self.language_model_selector.clone(),

View file

@ -499,7 +499,7 @@ impl AddedContext {
let thread = handle.thread.clone(); let thread = handle.thread.clone();
Some(Rc::new(move |_, cx| { Some(Rc::new(move |_, cx| {
let text = thread.read(cx).latest_detailed_summary_or_text(); let text = thread.read(cx).latest_detailed_summary_or_text();
ContextPillHover::new_text(text.clone(), cx).into() ContextPillHover::new_text(text, cx).into()
})) }))
}, },
handle: AgentContextHandle::Thread(handle), handle: AgentContextHandle::Thread(handle),
@ -574,7 +574,7 @@ impl AddedContext {
.unwrap_or_else(|| "Unnamed Rule".into()); .unwrap_or_else(|| "Unnamed Rule".into());
Some(AddedContext { Some(AddedContext {
kind: ContextKind::Rules, kind: ContextKind::Rules,
name: title.clone(), name: title,
parent: None, parent: None,
tooltip: None, tooltip: None,
icon_path: None, icon_path: None,

View file

@ -33,7 +33,7 @@ impl ApiKeysWithProviders {
.filter(|provider| { .filter(|provider| {
provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID
}) })
.map(|provider| (provider.icon(), provider.name().0.clone())) .map(|provider| (provider.icon(), provider.name().0))
.collect() .collect()
} }
} }

View file

@ -50,7 +50,7 @@ impl AgentPanelOnboarding {
.filter(|provider| { .filter(|provider| {
provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID
}) })
.map(|provider| (provider.icon(), provider.name().0.clone())) .map(|provider| (provider.icon(), provider.name().0))
.collect() .collect()
} }
} }

View file

@ -2282,7 +2282,7 @@ impl AssistantContext {
let mut contents = self.contents(cx).peekable(); let mut contents = self.contents(cx).peekable();
fn collect_text_content(buffer: &Buffer, range: Range<usize>) -> Option<String> { fn collect_text_content(buffer: &Buffer, range: Range<usize>) -> Option<String> {
let text: String = buffer.text_for_range(range.clone()).collect(); let text: String = buffer.text_for_range(range).collect();
if text.trim().is_empty() { if text.trim().is_empty() {
None None
} else { } else {

View file

@ -1321,7 +1321,7 @@ fn test_summarize_error(
fn setup_context_editor_with_fake_model( fn setup_context_editor_with_fake_model(
cx: &mut TestAppContext, cx: &mut TestAppContext,
) -> (Entity<AssistantContext>, Arc<FakeLanguageModel>) { ) -> (Entity<AssistantContext>, Arc<FakeLanguageModel>) {
let registry = Arc::new(LanguageRegistry::test(cx.executor().clone())); let registry = Arc::new(LanguageRegistry::test(cx.executor()));
let fake_provider = Arc::new(FakeLanguageModelProvider::default()); let fake_provider = Arc::new(FakeLanguageModelProvider::default());
let fake_model = Arc::new(fake_provider.test_model()); let fake_model = Arc::new(fake_provider.test_model());
@ -1376,7 +1376,7 @@ fn messages_cache(
context context
.read(cx) .read(cx)
.messages(cx) .messages(cx)
.map(|message| (message.id, message.cache.clone())) .map(|message| (message.id, message.cache))
.collect() .collect()
} }

View file

@ -862,7 +862,7 @@ impl ContextStore {
ContextServerStatus::Running => { ContextServerStatus::Running => {
self.load_context_server_slash_commands( self.load_context_server_slash_commands(
server_id.clone(), server_id.clone(),
context_server_store.clone(), context_server_store,
cx, cx,
); );
} }

View file

@ -44,7 +44,7 @@ impl DiagnosticsSlashCommand {
score: 0., score: 0.,
positions: Vec::new(), positions: Vec::new(),
worktree_id: entry.worktree_id.to_usize(), worktree_id: entry.worktree_id.to_usize(),
path: entry.path.clone(), path: entry.path,
path_prefix: path_prefix.clone(), path_prefix: path_prefix.clone(),
is_dir: false, // Diagnostics can't be produced for directories is_dir: false, // Diagnostics can't be produced for directories
distance_to_relative_ancestor: 0, distance_to_relative_ancestor: 0,

View file

@ -80,7 +80,7 @@ impl SlashCommand for PromptSlashCommand {
}; };
let store = PromptStore::global(cx); let store = PromptStore::global(cx);
let title = SharedString::from(title.clone()); let title = SharedString::from(title);
let prompt = cx.spawn({ let prompt = cx.spawn({
let title = title.clone(); let title = title.clone();
async move |cx| { async move |cx| {

View file

@ -1153,8 +1153,7 @@ impl EvalInput {
.expect("Conversation must end with an edit_file tool use") .expect("Conversation must end with an edit_file tool use")
.clone(); .clone();
let edit_file_input: EditFileToolInput = let edit_file_input: EditFileToolInput = serde_json::from_value(tool_use.input).unwrap();
serde_json::from_value(tool_use.input.clone()).unwrap();
EvalInput { EvalInput {
conversation, conversation,
@ -1460,7 +1459,7 @@ impl EditAgentTest {
async fn new(cx: &mut TestAppContext) -> Self { async fn new(cx: &mut TestAppContext) -> Self {
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
cx.update(|cx| { cx.update(|cx| {
settings::init(cx); settings::init(cx);
gpui_tokio::init(cx); gpui_tokio::init(cx);
@ -1475,7 +1474,7 @@ impl EditAgentTest {
Project::init_settings(cx); Project::init_settings(cx);
language::init(cx); language::init(cx);
language_model::init(client.clone(), cx); language_model::init(client.clone(), cx);
language_models::init(user_store.clone(), client.clone(), cx); language_models::init(user_store, client.clone(), cx);
crate::init(client.http_client(), cx); crate::init(client.http_client(), cx);
}); });

View file

@ -319,7 +319,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
assert_eq!(push(&mut finder, ""), None); assert_eq!(push(&mut finder, ""), None);
assert_eq!(finish(finder), None); assert_eq!(finish(finder), None);
} }
@ -333,7 +333,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push partial query // Push partial query
assert_eq!(push(&mut finder, "This"), None); assert_eq!(push(&mut finder, "This"), None);
@ -365,7 +365,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push a fuzzy query that should match the first function // Push a fuzzy query that should match the first function
assert_eq!( assert_eq!(
@ -391,7 +391,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
// No match initially // No match initially
assert_eq!(push(&mut finder, "Lin"), None); assert_eq!(push(&mut finder, "Lin"), None);
@ -420,7 +420,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push text in small chunks across line boundaries // Push text in small chunks across line boundaries
assert_eq!(push(&mut finder, "jumps "), None); // No newline yet assert_eq!(push(&mut finder, "jumps "), None); // No newline yet
@ -458,7 +458,7 @@ mod tests {
); );
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut finder = StreamingFuzzyMatcher::new(snapshot.clone()); let mut finder = StreamingFuzzyMatcher::new(snapshot);
assert_eq!( assert_eq!(
push(&mut finder, "impl Debug for User {\n"), push(&mut finder, "impl Debug for User {\n"),
@ -711,7 +711,7 @@ mod tests {
"Expected to match `second_function` based on the line hint" "Expected to match `second_function` based on the line hint"
); );
let mut matcher = StreamingFuzzyMatcher::new(snapshot.clone()); let mut matcher = StreamingFuzzyMatcher::new(snapshot);
matcher.push(query, None); matcher.push(query, None);
matcher.finish(); matcher.finish();
let best_match = matcher.select_best_match(); let best_match = matcher.select_best_match();
@ -727,7 +727,7 @@ mod tests {
let buffer = TextBuffer::new(0, BufferId::new(1).unwrap(), text.clone()); let buffer = TextBuffer::new(0, BufferId::new(1).unwrap(), text.clone());
let snapshot = buffer.snapshot(); let snapshot = buffer.snapshot();
let mut matcher = StreamingFuzzyMatcher::new(snapshot.clone()); let mut matcher = StreamingFuzzyMatcher::new(snapshot);
// Split query into random chunks // Split query into random chunks
let chunks = to_random_chunks(rng, query); let chunks = to_random_chunks(rng, query);

View file

@ -376,7 +376,7 @@ impl Tool for EditFileTool {
let output = EditFileToolOutput { let output = EditFileToolOutput {
original_path: project_path.path.to_path_buf(), original_path: project_path.path.to_path_buf(),
new_text: new_text.clone(), new_text,
old_text, old_text,
raw_output: Some(agent_output), raw_output: Some(agent_output),
}; };
@ -643,7 +643,7 @@ impl EditFileToolCard {
diff diff
}); });
self.buffer = Some(buffer.clone()); self.buffer = Some(buffer);
self.base_text = Some(base_text.into()); self.base_text = Some(base_text.into());
self.buffer_diff = Some(buffer_diff.clone()); self.buffer_diff = Some(buffer_diff.clone());
@ -776,7 +776,6 @@ impl EditFileToolCard {
let buffer_diff = cx.spawn({ let buffer_diff = cx.spawn({
let buffer = buffer.clone(); let buffer = buffer.clone();
let language_registry = language_registry.clone();
async move |_this, cx| { async move |_this, cx| {
build_buffer_diff(base_text, &buffer, &language_registry, cx).await build_buffer_diff(base_text, &buffer, &language_registry, cx).await
} }
@ -863,7 +862,6 @@ impl ToolCard for EditFileToolCard {
) )
.on_click({ .on_click({
let path = self.path.clone(); let path = self.path.clone();
let workspace = workspace.clone();
move |_, window, cx| { move |_, window, cx| {
workspace workspace
.update(cx, { .update(cx, {

View file

@ -327,7 +327,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
fs.insert_tree( fs.insert_tree(
path!("/root"), path!("/root"),
serde_json::json!({ serde_json::json!({
@ -415,7 +415,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
fs.insert_tree( fs.insert_tree(
path!("/root"), path!("/root"),
serde_json::json!({ serde_json::json!({
@ -494,7 +494,7 @@ mod tests {
init_test(cx); init_test(cx);
cx.executor().allow_parking(); cx.executor().allow_parking();
let fs = FakeFs::new(cx.executor().clone()); let fs = FakeFs::new(cx.executor());
// Create test file with syntax structures // Create test file with syntax structures
fs.insert_tree( fs.insert_tree(

View file

@ -350,7 +350,7 @@ fn process_content(
if is_empty { if is_empty {
"Command executed successfully.".to_string() "Command executed successfully.".to_string()
} else { } else {
content.to_string() content
} }
} }
Some(exit_status) => { Some(exit_status) => {

View file

@ -101,14 +101,11 @@ impl RenderOnce for ToolCallCardHeader {
}) })
.when_some(secondary_text, |this, secondary_text| { .when_some(secondary_text, |this, secondary_text| {
this.child(bullet_divider()) this.child(bullet_divider())
.child(div().text_size(font_size).child(secondary_text.clone())) .child(div().text_size(font_size).child(secondary_text))
}) })
.when_some(code_path, |this, code_path| { .when_some(code_path, |this, code_path| {
this.child(bullet_divider()).child( this.child(bullet_divider())
Label::new(code_path.clone()) .child(Label::new(code_path).size(LabelSize::Small).inline_code(cx))
.size(LabelSize::Small)
.inline_code(cx),
)
}) })
.with_animation( .with_animation(
"loading-label", "loading-label",

View file

@ -193,10 +193,7 @@ impl ToolCard for WebSearchToolCard {
) )
} }
}) })
.on_click({ .on_click(move |_, _, cx| cx.open_url(&url))
let url = url.clone();
move |_, _, cx| cx.open_url(&url)
})
})) }))
.into_any(), .into_any(),
), ),

View file

@ -114,7 +114,7 @@ fn view_release_notes_locally(
cx, cx,
); );
workspace.add_item_to_active_pane( workspace.add_item_to_active_pane(
Box::new(markdown_preview.clone()), Box::new(markdown_preview),
None, None,
true, true,
window, window,

View file

@ -175,12 +175,8 @@ impl BufferDiffSnapshot {
if let Some(text) = &base_text { if let Some(text) = &base_text {
let base_text_rope = Rope::from(text.as_str()); let base_text_rope = Rope::from(text.as_str());
base_text_pair = Some((text.clone(), base_text_rope.clone())); base_text_pair = Some((text.clone(), base_text_rope.clone()));
let snapshot = language::Buffer::build_snapshot( let snapshot =
base_text_rope, language::Buffer::build_snapshot(base_text_rope, language, language_registry, cx);
language.clone(),
language_registry.clone(),
cx,
);
base_text_snapshot = cx.background_spawn(snapshot); base_text_snapshot = cx.background_spawn(snapshot);
base_text_exists = true; base_text_exists = true;
} else { } else {
@ -957,7 +953,7 @@ impl BufferDiff {
.buffer_range .buffer_range
.start; .start;
let end = self let end = self
.hunks_intersecting_range_rev(range.clone(), buffer) .hunks_intersecting_range_rev(range, buffer)
.next()? .next()?
.buffer_range .buffer_range
.end; .end;
@ -1441,7 +1437,7 @@ mod tests {
.unindent(); .unindent();
let buffer = Buffer::new(0, BufferId::new(1).unwrap(), buffer_text); let buffer = Buffer::new(0, BufferId::new(1).unwrap(), buffer_text);
let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text.clone(), cx); let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text, cx);
let mut uncommitted_diff = let mut uncommitted_diff =
BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx); BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx);
uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff)); uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff));

View file

@ -438,7 +438,7 @@ fn init_test(cx: &mut App) -> Entity<ChannelStore> {
let clock = Arc::new(FakeSystemClock::new()); let clock = Arc::new(FakeSystemClock::new());
let http = FakeHttpClient::with_404_response(); let http = FakeHttpClient::with_404_response();
let client = Client::new(clock, http.clone(), cx); let client = Client::new(clock, http, cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
client::init(&client, cx); client::init(&client, cx);

View file

@ -926,7 +926,7 @@ mod mac_os {
fn path(&self) -> PathBuf { fn path(&self) -> PathBuf {
match self { match self {
Bundle::App { app_bundle, .. } => app_bundle.join("Contents/MacOS/zed").clone(), Bundle::App { app_bundle, .. } => app_bundle.join("Contents/MacOS/zed"),
Bundle::LocalPath { executable, .. } => executable.clone(), Bundle::LocalPath { executable, .. } => executable.clone(),
} }
} }

View file

@ -181,7 +181,7 @@ pub fn init(client: &Arc<Client>, cx: &mut App) {
}); });
cx.on_action({ cx.on_action({
let client = client.clone(); let client = client;
move |_: &Reconnect, cx| { move |_: &Reconnect, cx| {
if let Some(client) = client.upgrade() { if let Some(client) = client.upgrade() {
cx.spawn(async move |cx| { cx.spawn(async move |cx| {
@ -791,7 +791,7 @@ impl Client {
Arc::new(move |subscriber, envelope, client, cx| { Arc::new(move |subscriber, envelope, client, cx| {
let subscriber = subscriber.downcast::<E>().unwrap(); let subscriber = subscriber.downcast::<E>().unwrap();
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap(); let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
handler(subscriber, *envelope, client.clone(), cx).boxed_local() handler(subscriber, *envelope, client, cx).boxed_local()
}), }),
); );
if prev_handler.is_some() { if prev_handler.is_some() {
@ -2048,10 +2048,7 @@ mod tests {
assert_eq!(*auth_count.lock(), 1); assert_eq!(*auth_count.lock(), 1);
assert_eq!(*dropped_auth_count.lock(), 0); assert_eq!(*dropped_auth_count.lock(), 0);
let _authenticate = cx.spawn({ let _authenticate = cx.spawn(|cx| async move { client.connect(false, &cx).await });
let client = client.clone();
|cx| async move { client.connect(false, &cx).await }
});
executor.run_until_parked(); executor.run_until_parked();
assert_eq!(*auth_count.lock(), 2); assert_eq!(*auth_count.lock(), 2);
assert_eq!(*dropped_auth_count.lock(), 1); assert_eq!(*dropped_auth_count.lock(), 1);

View file

@ -739,7 +739,7 @@ mod tests {
); );
// Third scan of worktree does not double report, as we already reported // Third scan of worktree does not double report, as we already reported
test_project_discovery_helper(telemetry.clone(), vec!["package.json"], None, worktree_id); test_project_discovery_helper(telemetry, vec!["package.json"], None, worktree_id);
} }
#[gpui::test] #[gpui::test]
@ -751,7 +751,7 @@ mod tests {
let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx)); let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx));
test_project_discovery_helper( test_project_discovery_helper(
telemetry.clone(), telemetry,
vec!["package.json", "pnpm-lock.yaml"], vec!["package.json", "pnpm-lock.yaml"],
Some(vec!["node", "pnpm"]), Some(vec!["node", "pnpm"]),
1, 1,
@ -767,7 +767,7 @@ mod tests {
let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx)); let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx));
test_project_discovery_helper( test_project_discovery_helper(
telemetry.clone(), telemetry,
vec!["package.json", "yarn.lock"], vec!["package.json", "yarn.lock"],
Some(vec!["node", "yarn"]), Some(vec!["node", "yarn"]),
1, 1,
@ -786,7 +786,7 @@ mod tests {
// project type for the same worktree multiple times // project type for the same worktree multiple times
test_project_discovery_helper( test_project_discovery_helper(
telemetry.clone().clone(), telemetry.clone(),
vec!["global.json"], vec!["global.json"],
Some(vec!["dotnet"]), Some(vec!["dotnet"]),
1, 1,

View file

@ -280,7 +280,7 @@ pub async fn post_hang(
service = "client", service = "client",
version = %report.app_version.unwrap_or_default().to_string(), version = %report.app_version.unwrap_or_default().to_string(),
os_name = %report.os_name, os_name = %report.os_name,
os_version = report.os_version.unwrap_or_default().to_string(), os_version = report.os_version.unwrap_or_default(),
incident_id = %incident_id, incident_id = %incident_id,
installation_id = %report.installation_id.unwrap_or_default(), installation_id = %report.installation_id.unwrap_or_default(),
backtrace = %backtrace, backtrace = %backtrace,

View file

@ -236,7 +236,7 @@ mod test {
#[gpui::test] #[gpui::test]
async fn test_verify_access_token(cx: &mut gpui::TestAppContext) { async fn test_verify_access_token(cx: &mut gpui::TestAppContext) {
let test_db = crate::db::TestDb::sqlite(cx.executor().clone()); let test_db = crate::db::TestDb::sqlite(cx.executor());
let db = test_db.db(); let db = test_db.db();
let user = db let user = db

View file

@ -8,7 +8,7 @@ use time::{Duration, OffsetDateTime, PrimitiveDateTime};
// SQLite does not support array arguments, so we only test this against a real postgres instance // SQLite does not support array arguments, so we only test this against a real postgres instance
#[gpui::test] #[gpui::test]
async fn test_get_embeddings_postgres(cx: &mut gpui::TestAppContext) { async fn test_get_embeddings_postgres(cx: &mut gpui::TestAppContext) {
let test_db = TestDb::postgres(cx.executor().clone()); let test_db = TestDb::postgres(cx.executor());
let db = test_db.db(); let db = test_db.db();
let provider = "test_model"; let provider = "test_model";
@ -38,7 +38,7 @@ async fn test_get_embeddings_postgres(cx: &mut gpui::TestAppContext) {
#[gpui::test] #[gpui::test]
async fn test_purge_old_embeddings(cx: &mut gpui::TestAppContext) { async fn test_purge_old_embeddings(cx: &mut gpui::TestAppContext) {
let test_db = TestDb::postgres(cx.executor().clone()); let test_db = TestDb::postgres(cx.executor());
let db = test_db.db(); let db = test_db.db();
let model = "test_model"; let model = "test_model";

View file

@ -310,7 +310,7 @@ impl Server {
let mut server = Self { let mut server = Self {
id: parking_lot::Mutex::new(id), id: parking_lot::Mutex::new(id),
peer: Peer::new(id.0 as u32), peer: Peer::new(id.0 as u32),
app_state: app_state.clone(), app_state,
connection_pool: Default::default(), connection_pool: Default::default(),
handlers: Default::default(), handlers: Default::default(),
teardown: watch::channel(false).0, teardown: watch::channel(false).0,
@ -1386,9 +1386,7 @@ async fn create_room(
let live_kit = live_kit?; let live_kit = live_kit?;
let user_id = session.user_id().to_string(); let user_id = session.user_id().to_string();
let token = live_kit let token = live_kit.room_token(&livekit_room, &user_id).trace_err()?;
.room_token(&livekit_room, &user_id.to_string())
.trace_err()?;
Some(proto::LiveKitConnectionInfo { Some(proto::LiveKitConnectionInfo {
server_url: live_kit.url().into(), server_url: live_kit.url().into(),
@ -2015,9 +2013,9 @@ async fn join_project(
.unzip(); .unzip();
response.send(proto::JoinProjectResponse { response.send(proto::JoinProjectResponse {
project_id: project.id.0 as u64, project_id: project.id.0 as u64,
worktrees: worktrees.clone(), worktrees,
replica_id: replica_id.0 as u32, replica_id: replica_id.0 as u32,
collaborators: collaborators.clone(), collaborators,
language_servers, language_servers,
language_server_capabilities, language_server_capabilities,
role: project.role.into(), role: project.role.into(),

View file

@ -3593,7 +3593,7 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let abs_path = project_a.read_with(cx_a, |project, cx| { let abs_path = project_a.read_with(cx_a, |project, cx| {
project project
.absolute_path(&project_path, cx) .absolute_path(&project_path, cx)
.map(|path_buf| Arc::from(path_buf.to_owned())) .map(Arc::from)
.unwrap() .unwrap()
}); });
@ -3647,20 +3647,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| { let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
let breakpoints_b = editor_b.update(cx_b, |editor, cx| { let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
assert_eq!(1, breakpoints_a.len()); assert_eq!(1, breakpoints_a.len());
@ -3680,20 +3676,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| { let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
let breakpoints_b = editor_b.update(cx_b, |editor, cx| { let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
assert_eq!(1, breakpoints_a.len()); assert_eq!(1, breakpoints_a.len());
@ -3713,20 +3705,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| { let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
let breakpoints_b = editor_b.update(cx_b, |editor, cx| { let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
assert_eq!(1, breakpoints_a.len()); assert_eq!(1, breakpoints_a.len());
@ -3746,20 +3734,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| { let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
let breakpoints_b = editor_b.update(cx_b, |editor, cx| { let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor editor
.breakpoint_store() .breakpoint_store()
.clone()
.unwrap() .unwrap()
.read(cx) .read(cx)
.all_source_breakpoints(cx) .all_source_breakpoints(cx)
.clone()
}); });
assert_eq!(0, breakpoints_a.len()); assert_eq!(0, breakpoints_a.len());

View file

@ -266,7 +266,7 @@ impl RandomizedTest for RandomChannelBufferTest {
"client {user_id} has different text than client {prev_user_id} for channel {channel_name}", "client {user_id} has different text than client {prev_user_id} for channel {channel_name}",
); );
} else { } else {
prev_text = Some((user_id, text.clone())); prev_text = Some((user_id, text));
} }
// Assert that all clients and the server agree about who is present in the // Assert that all clients and the server agree about who is present in the

View file

@ -643,7 +643,7 @@ impl RandomizedTest for ProjectCollaborationTest {
); );
let project = project.await?; let project = project.await?;
client.dev_server_projects_mut().push(project.clone()); client.dev_server_projects_mut().push(project);
} }
ClientOperation::CreateWorktreeEntry { ClientOperation::CreateWorktreeEntry {

View file

@ -370,8 +370,8 @@ impl TestServer {
let client = TestClient { let client = TestClient {
app_state, app_state,
username: name.to_string(), username: name.to_string(),
channel_store: cx.read(ChannelStore::global).clone(), channel_store: cx.read(ChannelStore::global),
notification_store: cx.read(NotificationStore::global).clone(), notification_store: cx.read(NotificationStore::global),
state: Default::default(), state: Default::default(),
}; };
client.wait_for_current_user(cx).await; client.wait_for_current_user(cx).await;

View file

@ -66,7 +66,7 @@ impl ChannelView {
channel_id, channel_id,
link_position, link_position,
pane.clone(), pane.clone(),
workspace.clone(), workspace,
window, window,
cx, cx,
); );

View file

@ -1038,7 +1038,7 @@ impl Render for ChatPanel {
.cloned(); .cloned();
el.when_some(reply_message, |el, reply_message| { el.when_some(reply_message, |el, reply_message| {
let user_being_replied_to = reply_message.sender.clone(); let user_being_replied_to = reply_message.sender;
el.child( el.child(
h_flex() h_flex()

View file

@ -2507,7 +2507,7 @@ impl CollabPanel {
let button = match section { let button = match section {
Section::ActiveCall => channel_link.map(|channel_link| { Section::ActiveCall => channel_link.map(|channel_link| {
let channel_link_copy = channel_link.clone(); let channel_link_copy = channel_link;
IconButton::new("channel-link", IconName::Copy) IconButton::new("channel-link", IconName::Copy)
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
.size(ButtonSize::None) .size(ButtonSize::None)
@ -2691,7 +2691,7 @@ impl CollabPanel {
h_flex() h_flex()
.w_full() .w_full()
.justify_between() .justify_between()
.child(Label::new(github_login.clone())) .child(Label::new(github_login))
.child(h_flex().children(controls)), .child(h_flex().children(controls)),
) )
.start_slot(Avatar::new(user.avatar_uri.clone())) .start_slot(Avatar::new(user.avatar_uri.clone()))
@ -3125,7 +3125,7 @@ impl Panel for CollabPanel {
impl Focusable for CollabPanel { impl Focusable for CollabPanel {
fn focus_handle(&self, cx: &App) -> gpui::FocusHandle { fn focus_handle(&self, cx: &App) -> gpui::FocusHandle {
self.filter_editor.focus_handle(cx).clone() self.filter_editor.focus_handle(cx)
} }
} }

View file

@ -289,7 +289,7 @@ impl NotificationPanel {
.gap_1() .gap_1()
.size_full() .size_full()
.overflow_hidden() .overflow_hidden()
.child(Label::new(text.clone())) .child(Label::new(text))
.child( .child(
h_flex() h_flex()
.child( .child(

View file

@ -206,7 +206,7 @@ impl CommandPaletteDelegate {
if parse_zed_link(&query, cx).is_some() { if parse_zed_link(&query, cx).is_some() {
intercept_results = vec![CommandInterceptResult { intercept_results = vec![CommandInterceptResult {
action: OpenZedUrl { url: query.clone() }.boxed_clone(), action: OpenZedUrl { url: query.clone() }.boxed_clone(),
string: query.clone(), string: query,
positions: vec![], positions: vec![],
}] }]
} }

View file

@ -42,7 +42,7 @@ impl RenderOnce for ComponentExample {
div() div()
.text_size(rems(0.875)) .text_size(rems(0.875))
.text_color(cx.theme().colors().text_muted) .text_color(cx.theme().colors().text_muted)
.child(description.clone()), .child(description),
) )
}), }),
) )

View file

@ -112,7 +112,6 @@ impl McpServer {
annotations: Some(tool.annotations()), annotations: Some(tool.annotations()),
}, },
handler: Box::new({ handler: Box::new({
let tool = tool.clone();
move |input_value, cx| { move |input_value, cx| {
let input = match input_value { let input = match input_value {
Some(input) => serde_json::from_value(input), Some(input) => serde_json::from_value(input),

View file

@ -81,10 +81,7 @@ pub fn init(
}; };
copilot_chat::init(fs.clone(), http.clone(), configuration, cx); copilot_chat::init(fs.clone(), http.clone(), configuration, cx);
let copilot = cx.new({ let copilot = cx.new(move |cx| Copilot::start(new_server_id, fs, node_runtime, cx));
let node_runtime = node_runtime.clone();
move |cx| Copilot::start(new_server_id, fs, node_runtime, cx)
});
Copilot::set_global(copilot.clone(), cx); Copilot::set_global(copilot.clone(), cx);
cx.observe(&copilot, |copilot, cx| { cx.observe(&copilot, |copilot, cx| {
copilot.update(cx, |copilot, cx| copilot.update_action_visibilities(cx)); copilot.update(cx, |copilot, cx| copilot.update_action_visibilities(cx));

View file

@ -1083,7 +1083,7 @@ mod tests {
let replace_range_marker: TextRangeMarker = ('<', '>').into(); let replace_range_marker: TextRangeMarker = ('<', '>').into();
let (_, mut marked_ranges) = marked_text_ranges_by( let (_, mut marked_ranges) = marked_text_ranges_by(
marked_string, marked_string,
vec![complete_from_marker.clone(), replace_range_marker.clone()], vec![complete_from_marker, replace_range_marker.clone()],
); );
let replace_range = let replace_range =

View file

@ -664,7 +664,7 @@ impl ToolbarItemView for DapLogToolbarItemView {
if let Some(item) = active_pane_item if let Some(item) = active_pane_item
&& let Some(log_view) = item.downcast::<DapLogView>() && let Some(log_view) = item.downcast::<DapLogView>()
{ {
self.log_view = Some(log_view.clone()); self.log_view = Some(log_view);
return workspace::ToolbarItemLocation::PrimaryLeft; return workspace::ToolbarItemLocation::PrimaryLeft;
} }
self.log_view = None; self.log_view = None;

View file

@ -386,10 +386,10 @@ impl DebugPanel {
return; return;
}; };
let dap_store_handle = self.project.read(cx).dap_store().clone(); let dap_store_handle = self.project.read(cx).dap_store();
let label = curr_session.read(cx).label(); let label = curr_session.read(cx).label();
let quirks = curr_session.read(cx).quirks(); let quirks = curr_session.read(cx).quirks();
let adapter = curr_session.read(cx).adapter().clone(); let adapter = curr_session.read(cx).adapter();
let binary = curr_session.read(cx).binary().cloned().unwrap(); let binary = curr_session.read(cx).binary().cloned().unwrap();
let task_context = curr_session.read(cx).task_context().clone(); let task_context = curr_session.read(cx).task_context().clone();
@ -447,9 +447,9 @@ impl DebugPanel {
return; return;
}; };
let dap_store_handle = self.project.read(cx).dap_store().clone(); let dap_store_handle = self.project.read(cx).dap_store();
let label = self.label_for_child_session(&parent_session, request, cx); let label = self.label_for_child_session(&parent_session, request, cx);
let adapter = parent_session.read(cx).adapter().clone(); let adapter = parent_session.read(cx).adapter();
let quirks = parent_session.read(cx).quirks(); let quirks = parent_session.read(cx).quirks();
let Some(mut binary) = parent_session.read(cx).binary().cloned() else { let Some(mut binary) = parent_session.read(cx).binary().cloned() else {
log::error!("Attempted to start a child-session without a binary"); log::error!("Attempted to start a child-session without a binary");
@ -932,7 +932,6 @@ impl DebugPanel {
.cloned(), .cloned(),
|this, running_state| { |this, running_state| {
this.children({ this.children({
let running_state = running_state.clone();
let threads = let threads =
running_state.update(cx, |running_state, cx| { running_state.update(cx, |running_state, cx| {
let session = running_state.session(); let session = running_state.session();
@ -1645,7 +1644,6 @@ impl Render for DebugPanel {
} }
}) })
.on_action({ .on_action({
let this = this.clone();
move |_: &ToggleSessionPicker, window, cx| { move |_: &ToggleSessionPicker, window, cx| {
this.update(cx, |this, cx| { this.update(cx, |this, cx| {
this.toggle_session_picker(window, cx); this.toggle_session_picker(window, cx);

View file

@ -272,7 +272,6 @@ pub fn init(cx: &mut App) {
} }
}) })
.on_action({ .on_action({
let active_item = active_item.clone();
move |_: &ToggleIgnoreBreakpoints, _, cx| { move |_: &ToggleIgnoreBreakpoints, _, cx| {
active_item active_item
.update(cx, |item, cx| item.toggle_ignore_breakpoints(cx)) .update(cx, |item, cx| item.toggle_ignore_breakpoints(cx))
@ -293,9 +292,8 @@ pub fn init(cx: &mut App) {
let Some(debug_panel) = workspace.read(cx).panel::<DebugPanel>(cx) else { let Some(debug_panel) = workspace.read(cx).panel::<DebugPanel>(cx) else {
return; return;
}; };
let Some(active_session) = debug_panel let Some(active_session) =
.clone() debug_panel.update(cx, |panel, _| panel.active_session())
.update(cx, |panel, _| panel.active_session())
else { else {
return; return;
}; };

View file

@ -272,10 +272,9 @@ impl DebugPanel {
.child(session_entry.label_element(self_depth, cx)) .child(session_entry.label_element(self_depth, cx))
.child( .child(
IconButton::new("close-debug-session", IconName::Close) IconButton::new("close-debug-session", IconName::Close)
.visible_on_hover(id.clone()) .visible_on_hover(id)
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
.on_click({ .on_click({
let weak = weak.clone();
move |_, window, cx| { move |_, window, cx| {
weak.update(cx, |panel, cx| { weak.update(cx, |panel, cx| {
panel.close_session(session_entity_id, window, cx); panel.close_session(session_entity_id, window, cx);

View file

@ -785,7 +785,7 @@ impl RenderOnce for AttachMode {
v_flex() v_flex()
.w_full() .w_full()
.track_focus(&self.attach_picker.focus_handle(cx)) .track_focus(&self.attach_picker.focus_handle(cx))
.child(self.attach_picker.clone()) .child(self.attach_picker)
} }
} }

View file

@ -256,7 +256,7 @@ pub(crate) fn deserialize_pane_layout(
Some(Member::Axis(PaneAxis::load( Some(Member::Axis(PaneAxis::load(
if should_invert { axis.invert() } else { axis }, if should_invert { axis.invert() } else { axis },
members, members,
flexes.clone(), flexes,
))) )))
} }
SerializedPaneLayout::Pane(serialized_pane) => { SerializedPaneLayout::Pane(serialized_pane) => {

View file

@ -180,7 +180,7 @@ impl SubView {
let weak_list = list.downgrade(); let weak_list = list.downgrade();
let focus_handle = list.focus_handle(cx); let focus_handle = list.focus_handle(cx);
let this = Self::new( let this = Self::new(
focus_handle.clone(), focus_handle,
list.into(), list.into(),
DebuggerPaneItem::BreakpointList, DebuggerPaneItem::BreakpointList,
cx, cx,
@ -1167,9 +1167,9 @@ impl RunningState {
id: task::TaskId("debug".to_string()), id: task::TaskId("debug".to_string()),
full_label: title.clone(), full_label: title.clone(),
label: title.clone(), label: title.clone(),
command: command.clone(), command,
args, args,
command_label: title.clone(), command_label: title,
cwd, cwd,
env: envs, env: envs,
use_new_terminal: true, use_new_terminal: true,
@ -1756,7 +1756,7 @@ impl RunningState {
this.activate_item(0, false, false, window, cx); this.activate_item(0, false, false, window, cx);
}); });
let rightmost_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx); let rightmost_pane = new_debugger_pane(workspace.clone(), project, window, cx);
rightmost_pane.update(cx, |this, cx| { rightmost_pane.update(cx, |this, cx| {
this.add_item( this.add_item(
Box::new(SubView::new( Box::new(SubView::new(

View file

@ -685,7 +685,6 @@ impl BreakpointList {
selection_kind.map(|kind| kind.0) != Some(SelectedBreakpointKind::Source), selection_kind.map(|kind| kind.0) != Some(SelectedBreakpointKind::Source),
) )
.on_click({ .on_click({
let focus_handle = focus_handle.clone();
move |_, window, cx| { move |_, window, cx| {
focus_handle.focus(window); focus_handle.focus(window);
window.dispatch_action(UnsetBreakpoint.boxed_clone(), cx) window.dispatch_action(UnsetBreakpoint.boxed_clone(), cx)
@ -1139,7 +1138,6 @@ impl ExceptionBreakpoint {
} }
}) })
.on_click({ .on_click({
let list = list.clone();
move |_, _, cx| { move |_, _, cx| {
list.update(cx, |this, cx| { list.update(cx, |this, cx| {
this.toggle_exception_breakpoint(&id, cx); this.toggle_exception_breakpoint(&id, cx);

View file

@ -365,7 +365,7 @@ impl Console {
Some(ContextMenu::build(window, cx, |context_menu, _, _| { Some(ContextMenu::build(window, cx, |context_menu, _, _| {
context_menu context_menu
.when_some(keybinding_target.clone(), |el, keybinding_target| { .when_some(keybinding_target.clone(), |el, keybinding_target| {
el.context(keybinding_target.clone()) el.context(keybinding_target)
}) })
.action("Watch Expression", WatchExpression.boxed_clone()) .action("Watch Expression", WatchExpression.boxed_clone())
})) }))

View file

@ -57,7 +57,7 @@ impl LoadedSourceList {
h_flex() h_flex()
.text_ui_xs(cx) .text_ui_xs(cx)
.text_color(cx.theme().colors().text_muted) .text_color(cx.theme().colors().text_muted)
.when_some(source.path.clone(), |this, path| this.child(path)), .when_some(source.path, |this, path| this.child(path)),
) )
.into_any() .into_any()
} }

View file

@ -461,7 +461,7 @@ impl MemoryView {
let data_breakpoint_info = this.data_breakpoint_info(context.clone(), None, cx); let data_breakpoint_info = this.data_breakpoint_info(context.clone(), None, cx);
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {
if let Some(info) = data_breakpoint_info.await { if let Some(info) = data_breakpoint_info.await {
let Some(data_id) = info.data_id.clone() else { let Some(data_id) = info.data_id else {
return; return;
}; };
_ = this.update(cx, |this, cx| { _ = this.update(cx, |this, cx| {

View file

@ -157,7 +157,7 @@ impl ModuleList {
h_flex() h_flex()
.text_ui_xs(cx) .text_ui_xs(cx)
.text_color(cx.theme().colors().text_muted) .text_color(cx.theme().colors().text_muted)
.when_some(module.path.clone(), |this, path| this.child(path)), .when_some(module.path, |this, path| this.child(path)),
) )
.into_any() .into_any()
} }

View file

@ -126,7 +126,7 @@ impl StackFrameList {
self.stack_frames(cx) self.stack_frames(cx)
.unwrap_or_default() .unwrap_or_default()
.into_iter() .into_iter()
.map(|stack_frame| stack_frame.dap.clone()) .map(|stack_frame| stack_frame.dap)
.collect() .collect()
} }
@ -224,7 +224,7 @@ impl StackFrameList {
let collapsed_entries = std::mem::take(&mut collapsed_entries); let collapsed_entries = std::mem::take(&mut collapsed_entries);
if !collapsed_entries.is_empty() { if !collapsed_entries.is_empty() {
entries.push(StackFrameEntry::Collapsed(collapsed_entries.clone())); entries.push(StackFrameEntry::Collapsed(collapsed_entries));
} }
self.entries = entries; self.entries = entries;
@ -418,7 +418,7 @@ impl StackFrameList {
let source = stack_frame.source.clone(); let source = stack_frame.source.clone();
let is_selected_frame = Some(ix) == self.selected_ix; let is_selected_frame = Some(ix) == self.selected_ix;
let path = source.clone().and_then(|s| s.path.or(s.name)); let path = source.and_then(|s| s.path.or(s.name));
let formatted_path = path.map(|path| format!("{}:{}", path, stack_frame.line,)); let formatted_path = path.map(|path| format!("{}:{}", path, stack_frame.line,));
let formatted_path = formatted_path.map(|path| { let formatted_path = formatted_path.map(|path| {
Label::new(path) Label::new(path)

View file

@ -313,7 +313,7 @@ impl VariableList {
watcher.variables_reference, watcher.variables_reference,
watcher.variables_reference, watcher.variables_reference,
EntryPath::for_watcher(watcher.expression.clone()), EntryPath::for_watcher(watcher.expression.clone()),
DapEntry::Watcher(watcher.clone()), DapEntry::Watcher(watcher),
) )
}) })
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
@ -1301,8 +1301,6 @@ impl VariableList {
IconName::Close, IconName::Close,
) )
.on_click({ .on_click({
let weak = weak.clone();
let path = path.clone();
move |_, window, cx| { move |_, window, cx| {
weak.update(cx, |variable_list, cx| { weak.update(cx, |variable_list, cx| {
variable_list.selection = Some(path.clone()); variable_list.selection = Some(path.clone());
@ -1470,7 +1468,6 @@ impl VariableList {
})) }))
}) })
.on_secondary_mouse_down(cx.listener({ .on_secondary_mouse_down(cx.listener({
let path = path.clone();
let entry = variable.clone(); let entry = variable.clone();
move |this, event: &MouseDownEvent, window, cx| { move |this, event: &MouseDownEvent, window, cx| {
this.selection = Some(path.clone()); this.selection = Some(path.clone());

View file

@ -1330,7 +1330,6 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
let called_set_breakpoints = Arc::new(AtomicBool::new(false)); let called_set_breakpoints = Arc::new(AtomicBool::new(false));
client.on_request::<SetBreakpoints, _>({ client.on_request::<SetBreakpoints, _>({
let called_set_breakpoints = called_set_breakpoints.clone();
move |_, args| { move |_, args| {
assert!( assert!(
args.breakpoints.is_none_or(|bps| bps.is_empty()), args.breakpoints.is_none_or(|bps| bps.is_empty()),
@ -1445,7 +1444,6 @@ async fn test_we_send_arguments_from_user_config(
let launch_handler_called = Arc::new(AtomicBool::new(false)); let launch_handler_called = Arc::new(AtomicBool::new(false));
start_debug_session_with(&workspace, cx, debug_definition.clone(), { start_debug_session_with(&workspace, cx, debug_definition.clone(), {
let debug_definition = debug_definition.clone();
let launch_handler_called = launch_handler_called.clone(); let launch_handler_called = launch_handler_called.clone();
move |client| { move |client| {
@ -1783,9 +1781,8 @@ async fn test_debug_adapters_shutdown_on_app_quit(
let disconnect_request_received = Arc::new(AtomicBool::new(false)); let disconnect_request_received = Arc::new(AtomicBool::new(false));
let disconnect_clone = disconnect_request_received.clone(); let disconnect_clone = disconnect_request_received.clone();
let disconnect_clone_for_handler = disconnect_clone.clone();
client.on_request::<Disconnect, _>(move |_, _| { client.on_request::<Disconnect, _>(move |_, _| {
disconnect_clone_for_handler.store(true, Ordering::SeqCst); disconnect_clone.store(true, Ordering::SeqCst);
Ok(()) Ok(())
}); });

View file

@ -106,9 +106,7 @@ async fn test_debug_session_substitutes_variables_and_relativizes_paths(
); );
let expected_other_field = if input_path.contains("$ZED_WORKTREE_ROOT") { let expected_other_field = if input_path.contains("$ZED_WORKTREE_ROOT") {
input_path input_path.replace("$ZED_WORKTREE_ROOT", path!("/test/worktree/path"))
.replace("$ZED_WORKTREE_ROOT", path!("/test/worktree/path"))
.to_owned()
} else { } else {
input_path.to_string() input_path.to_string()
}; };

View file

@ -61,15 +61,13 @@ impl PreprocessorError {
for alias in action.deprecated_aliases { for alias in action.deprecated_aliases {
if alias == &action_name { if alias == &action_name {
return PreprocessorError::DeprecatedActionUsed { return PreprocessorError::DeprecatedActionUsed {
used: action_name.clone(), used: action_name,
should_be: action.name.to_string(), should_be: action.name.to_string(),
}; };
} }
} }
} }
PreprocessorError::ActionNotFound { PreprocessorError::ActionNotFound { action_name }
action_name: action_name.to_string(),
}
} }
} }

View file

@ -168,7 +168,7 @@ impl Render for EditPredictionButton {
let account_status = agent.account_status.clone(); let account_status = agent.account_status.clone();
match account_status { match account_status {
AccountStatus::NeedsActivation { activate_url } => { AccountStatus::NeedsActivation { activate_url } => {
SupermavenButtonStatus::NeedsActivation(activate_url.clone()) SupermavenButtonStatus::NeedsActivation(activate_url)
} }
AccountStatus::Unknown => SupermavenButtonStatus::Initializing, AccountStatus::Unknown => SupermavenButtonStatus::Initializing,
AccountStatus::Ready => SupermavenButtonStatus::Ready, AccountStatus::Ready => SupermavenButtonStatus::Ready,

View file

@ -514,7 +514,7 @@ impl CompletionsMenu {
// Expand the range to resolve more completions than are predicted to be visible, to reduce // Expand the range to resolve more completions than are predicted to be visible, to reduce
// jank on navigation. // jank on navigation.
let entry_indices = util::expanded_and_wrapped_usize_range( let entry_indices = util::expanded_and_wrapped_usize_range(
entry_range.clone(), entry_range,
RESOLVE_BEFORE_ITEMS, RESOLVE_BEFORE_ITEMS,
RESOLVE_AFTER_ITEMS, RESOLVE_AFTER_ITEMS,
entries.len(), entries.len(),

View file

@ -2156,7 +2156,7 @@ mod tests {
} }
let multi_buffer_snapshot = multi_buffer.read(cx).snapshot(cx); let multi_buffer_snapshot = multi_buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
let (_, wraps_snapshot) = WrapMap::new(tab_snapshot, font, font_size, Some(wrap_width), cx); let (_, wraps_snapshot) = WrapMap::new(tab_snapshot, font, font_size, Some(wrap_width), cx);
@ -2275,7 +2275,7 @@ mod tests {
new_heights.insert(block_ids[0], 3); new_heights.insert(block_ids[0], 3);
block_map_writer.resize(new_heights); block_map_writer.resize(new_heights);
let snapshot = block_map.read(wraps_snapshot.clone(), Default::default()); let snapshot = block_map.read(wraps_snapshot, Default::default());
// Same height as before, should remain the same // Same height as before, should remain the same
assert_eq!(snapshot.text(), "aaa\n\n\n\n\n\nbbb\nccc\nddd\n\n\n"); assert_eq!(snapshot.text(), "aaa\n\n\n\n\n\nbbb\nccc\nddd\n\n\n");
} }
@ -2360,16 +2360,14 @@ mod tests {
buffer.edit([(Point::new(2, 0)..Point::new(3, 0), "")], None, cx); buffer.edit([(Point::new(2, 0)..Point::new(3, 0), "")], None, cx);
buffer.snapshot(cx) buffer.snapshot(cx)
}); });
let (inlay_snapshot, inlay_edits) = inlay_map.sync( let (inlay_snapshot, inlay_edits) =
buffer_snapshot.clone(), inlay_map.sync(buffer_snapshot, buffer_subscription.consume().into_inner());
buffer_subscription.consume().into_inner(),
);
let (fold_snapshot, fold_edits) = fold_map.read(inlay_snapshot, inlay_edits); let (fold_snapshot, fold_edits) = fold_map.read(inlay_snapshot, inlay_edits);
let (tab_snapshot, tab_edits) = tab_map.sync(fold_snapshot, fold_edits, tab_size); let (tab_snapshot, tab_edits) = tab_map.sync(fold_snapshot, fold_edits, tab_size);
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| { let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
wrap_map.sync(tab_snapshot, tab_edits, cx) wrap_map.sync(tab_snapshot, tab_edits, cx)
}); });
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), wrap_edits); let blocks_snapshot = block_map.read(wraps_snapshot, wrap_edits);
assert_eq!(blocks_snapshot.text(), "line1\n\n\n\n\nline5"); assert_eq!(blocks_snapshot.text(), "line1\n\n\n\n\nline5");
let buffer_snapshot = buffer.update(cx, |buffer, cx| { let buffer_snapshot = buffer.update(cx, |buffer, cx| {
@ -2454,7 +2452,7 @@ mod tests {
// Removing the replace block shows all the hidden blocks again. // Removing the replace block shows all the hidden blocks again.
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default()); let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
writer.remove(HashSet::from_iter([replace_block_id])); writer.remove(HashSet::from_iter([replace_block_id]));
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default()); let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
assert_eq!( assert_eq!(
blocks_snapshot.text(), blocks_snapshot.text(),
"\nline1\n\nline2\n\n\nline 2.1\nline2.2\nline 2.3\nline 2.4\n\nline4\n\nline5" "\nline1\n\nline2\n\n\nline 2.1\nline2.2\nline 2.3\nline 2.4\n\nline4\n\nline5"
@ -2793,7 +2791,7 @@ mod tests {
buffer.read_with(cx, |buffer, cx| { buffer.read_with(cx, |buffer, cx| {
writer.fold_buffers([buffer_id_3], buffer, cx); writer.fold_buffers([buffer_id_3], buffer, cx);
}); });
let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default()); let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
let blocks = blocks_snapshot let blocks = blocks_snapshot
.blocks_in_range(0..u32::MAX) .blocks_in_range(0..u32::MAX)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -2846,7 +2844,7 @@ mod tests {
assert_eq!(buffer_ids.len(), 1); assert_eq!(buffer_ids.len(), 1);
let buffer_id = buffer_ids[0]; let buffer_id = buffer_ids[0];
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
let (_, wrap_snapshot) = let (_, wrap_snapshot) =
@ -2860,7 +2858,7 @@ mod tests {
buffer.read_with(cx, |buffer, cx| { buffer.read_with(cx, |buffer, cx| {
writer.fold_buffers([buffer_id], buffer, cx); writer.fold_buffers([buffer_id], buffer, cx);
}); });
let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default()); let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
let blocks = blocks_snapshot let blocks = blocks_snapshot
.blocks_in_range(0..u32::MAX) .blocks_in_range(0..u32::MAX)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -3527,7 +3525,7 @@ mod tests {
..buffer_snapshot.anchor_after(Point::new(1, 0))], ..buffer_snapshot.anchor_after(Point::new(1, 0))],
false, false,
); );
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default()); let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
assert_eq!(blocks_snapshot.text(), "abc\n\ndef\nghi\njkl\nmno"); assert_eq!(blocks_snapshot.text(), "abc\n\ndef\nghi\njkl\nmno");
} }

View file

@ -1557,7 +1557,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx); let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe()); let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let mut map = FoldMap::new(inlay_snapshot.clone()).0; let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot, vec![]); let (mut writer, _, _) = map.write(inlay_snapshot, vec![]);
@ -1636,7 +1636,7 @@ mod tests {
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx); let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe()); let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
{ {
let mut map = FoldMap::new(inlay_snapshot.clone()).0; let mut map = FoldMap::new(inlay_snapshot.clone()).0;
@ -1712,7 +1712,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx); let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe()); let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let mut map = FoldMap::new(inlay_snapshot.clone()).0; let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]); let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
@ -1720,7 +1720,7 @@ mod tests {
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()), (Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()), (Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]); ]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]); let (snapshot, _) = map.read(inlay_snapshot, vec![]);
assert_eq!(snapshot.text(), "aa⋯cccc\nd⋯eeeee"); assert_eq!(snapshot.text(), "aa⋯cccc\nd⋯eeeee");
let buffer_snapshot = buffer.update(cx, |buffer, cx| { let buffer_snapshot = buffer.update(cx, |buffer, cx| {
@ -1747,7 +1747,7 @@ mod tests {
(Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()), (Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()), (Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]); ]);
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]); let (snapshot, _) = map.read(inlay_snapshot, vec![]);
let fold_ranges = snapshot let fold_ranges = snapshot
.folds_in_range(Point::new(1, 0)..Point::new(1, 3)) .folds_in_range(Point::new(1, 0)..Point::new(1, 3))
.map(|fold| { .map(|fold| {
@ -1782,7 +1782,7 @@ mod tests {
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
let mut map = FoldMap::new(inlay_snapshot.clone()).0; let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut initial_snapshot, _) = map.read(inlay_snapshot.clone(), vec![]); let (mut initial_snapshot, _) = map.read(inlay_snapshot, vec![]);
let mut snapshot_edits = Vec::new(); let mut snapshot_edits = Vec::new();
let mut next_inlay_id = 0; let mut next_inlay_id = 0;

View file

@ -116,7 +116,7 @@ impl TabMap {
state.new.end = edit.new.end; state.new.end = edit.new.end;
Some(None) // Skip this edit, it's merged Some(None) // Skip this edit, it's merged
} else { } else {
let new_state = edit.clone(); let new_state = edit;
let result = Some(Some(state.clone())); // Yield the previous edit let result = Some(Some(state.clone())); // Yield the previous edit
**state = new_state; **state = new_state;
result result
@ -611,7 +611,7 @@ mod tests {
fn test_expand_tabs(cx: &mut gpui::App) { fn test_expand_tabs(cx: &mut gpui::App) {
let buffer = MultiBuffer::build_simple("", cx); let buffer = MultiBuffer::build_simple("", cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@ -628,7 +628,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx); let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@ -675,7 +675,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx); let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@ -689,7 +689,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx); let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot); let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap()); let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@ -749,7 +749,7 @@ mod tests {
let buffer_snapshot = buffer.read(cx).snapshot(cx); let buffer_snapshot = buffer.read(cx).snapshot(cx);
log::info!("Buffer text: {:?}", buffer_snapshot.text()); log::info!("Buffer text: {:?}", buffer_snapshot.text());
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone()); let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
log::info!("InlayMap text: {:?}", inlay_snapshot.text()); log::info!("InlayMap text: {:?}", inlay_snapshot.text());
let (mut fold_map, _) = FoldMap::new(inlay_snapshot.clone()); let (mut fold_map, _) = FoldMap::new(inlay_snapshot.clone());
fold_map.randomly_mutate(&mut rng); fold_map.randomly_mutate(&mut rng);
@ -758,7 +758,7 @@ mod tests {
let (inlay_snapshot, _) = inlay_map.randomly_mutate(&mut 0, &mut rng); let (inlay_snapshot, _) = inlay_map.randomly_mutate(&mut 0, &mut rng);
log::info!("InlayMap text: {:?}", inlay_snapshot.text()); log::info!("InlayMap text: {:?}", inlay_snapshot.text());
let (mut tab_map, _) = TabMap::new(fold_snapshot.clone(), tab_size); let (mut tab_map, _) = TabMap::new(fold_snapshot, tab_size);
let tabs_snapshot = tab_map.set_max_expansion_column(32); let tabs_snapshot = tab_map.set_max_expansion_column(32);
let text = text::Rope::from(tabs_snapshot.text().as_str()); let text = text::Rope::from(tabs_snapshot.text().as_str());

View file

@ -4528,7 +4528,7 @@ impl Editor {
let mut char_position = 0u32; let mut char_position = 0u32;
let mut end_tag_offset = None; let mut end_tag_offset = None;
'outer: for chunk in snapshot.text_for_range(range.clone()) { 'outer: for chunk in snapshot.text_for_range(range) {
if let Some(byte_pos) = chunk.find(&**end_tag) { if let Some(byte_pos) = chunk.find(&**end_tag) {
let chars_before_match = let chars_before_match =
chunk[..byte_pos].chars().count() as u32; chunk[..byte_pos].chars().count() as u32;
@ -4881,7 +4881,7 @@ impl Editor {
let multibuffer = self.buffer.read(cx); let multibuffer = self.buffer.read(cx);
let Some(buffer) = position let Some(buffer) = position
.buffer_id .buffer_id
.and_then(|buffer_id| multibuffer.buffer(buffer_id).clone()) .and_then(|buffer_id| multibuffer.buffer(buffer_id))
else { else {
return false; return false;
}; };
@ -6269,7 +6269,7 @@ impl Editor {
})) }))
} }
CodeActionsItem::DebugScenario(scenario) => { CodeActionsItem::DebugScenario(scenario) => {
let context = actions_menu.actions.context.clone(); let context = actions_menu.actions.context;
workspace.update(cx, |workspace, cx| { workspace.update(cx, |workspace, cx| {
dap::send_telemetry(&scenario, TelemetrySpawnLocation::Gutter, cx); dap::send_telemetry(&scenario, TelemetrySpawnLocation::Gutter, cx);
@ -6469,7 +6469,7 @@ impl Editor {
fn refresh_code_actions(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<()> { fn refresh_code_actions(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<()> {
let newest_selection = self.selections.newest_anchor().clone(); let newest_selection = self.selections.newest_anchor().clone();
let newest_selection_adjusted = self.selections.newest_adjusted(cx).clone(); let newest_selection_adjusted = self.selections.newest_adjusted(cx);
let buffer = self.buffer.read(cx); let buffer = self.buffer.read(cx);
if newest_selection.head().diff_base_anchor.is_some() { if newest_selection.head().diff_base_anchor.is_some() {
return None; return None;
@ -8188,8 +8188,6 @@ impl Editor {
.icon_color(color) .icon_color(color)
.style(ButtonStyle::Transparent) .style(ButtonStyle::Transparent)
.on_click(cx.listener({ .on_click(cx.listener({
let breakpoint = breakpoint.clone();
move |editor, event: &ClickEvent, window, cx| { move |editor, event: &ClickEvent, window, cx| {
let edit_action = if event.modifiers().platform || breakpoint.is_disabled() { let edit_action = if event.modifiers().platform || breakpoint.is_disabled() {
BreakpointEditAction::InvertState BreakpointEditAction::InvertState
@ -14837,7 +14835,7 @@ impl Editor {
if parent == child { if parent == child {
return None; return None;
} }
let text = buffer.text_for_range(child.clone()).collect::<String>(); let text = buffer.text_for_range(child).collect::<String>();
Some((selection.id, parent, text)) Some((selection.id, parent, text))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -15940,7 +15938,7 @@ impl Editor {
if !split if !split
&& Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref() && Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref()
{ {
editor.go_to_singleton_buffer_range(range.clone(), window, cx); editor.go_to_singleton_buffer_range(range, window, cx);
} else { } else {
window.defer(cx, move |window, cx| { window.defer(cx, move |window, cx| {
let target_editor: Entity<Self> = let target_editor: Entity<Self> =
@ -16198,14 +16196,14 @@ impl Editor {
let item_id = item.item_id(); let item_id = item.item_id();
if split { if split {
workspace.split_item(SplitDirection::Right, item.clone(), window, cx); workspace.split_item(SplitDirection::Right, item, window, cx);
} else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation { } else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
let (preview_item_id, preview_item_idx) = let (preview_item_id, preview_item_idx) =
workspace.active_pane().read_with(cx, |pane, _| { workspace.active_pane().read_with(cx, |pane, _| {
(pane.preview_item_id(), pane.preview_item_idx()) (pane.preview_item_id(), pane.preview_item_idx())
}); });
workspace.add_item_to_active_pane(item.clone(), preview_item_idx, true, window, cx); workspace.add_item_to_active_pane(item, preview_item_idx, true, window, cx);
if let Some(preview_item_id) = preview_item_id { if let Some(preview_item_id) = preview_item_id {
workspace.active_pane().update(cx, |pane, cx| { workspace.active_pane().update(cx, |pane, cx| {
@ -16213,7 +16211,7 @@ impl Editor {
}); });
} }
} else { } else {
workspace.add_item_to_active_pane(item.clone(), None, true, window, cx); workspace.add_item_to_active_pane(item, None, true, window, cx);
} }
workspace.active_pane().update(cx, |pane, cx| { workspace.active_pane().update(cx, |pane, cx| {
pane.set_preview_item_id(Some(item_id), cx); pane.set_preview_item_id(Some(item_id), cx);
@ -19004,10 +19002,7 @@ impl Editor {
let selection = text::ToPoint::to_point(&range.start, buffer).row let selection = text::ToPoint::to_point(&range.start, buffer).row
..text::ToPoint::to_point(&range.end, buffer).row; ..text::ToPoint::to_point(&range.end, buffer).row;
Some(( Some((multi_buffer.buffer(buffer.remote_id()).unwrap(), selection))
multi_buffer.buffer(buffer.remote_id()).unwrap().clone(),
selection,
))
}); });
let Some((buffer, selection)) = buffer_and_selection else { let Some((buffer, selection)) = buffer_and_selection else {
@ -19249,7 +19244,7 @@ impl Editor {
row_highlights.insert( row_highlights.insert(
ix, ix,
RowHighlight { RowHighlight {
range: range.clone(), range,
index, index,
color, color,
options, options,
@ -21676,7 +21671,7 @@ fn wrap_with_prefix(
let subsequent_lines_prefix_len = let subsequent_lines_prefix_len =
char_len_with_expanded_tabs(0, &subsequent_lines_prefix, tab_size); char_len_with_expanded_tabs(0, &subsequent_lines_prefix, tab_size);
let mut wrapped_text = String::new(); let mut wrapped_text = String::new();
let mut current_line = first_line_prefix.clone(); let mut current_line = first_line_prefix;
let mut is_first_line = true; let mut is_first_line = true;
let tokenizer = WordBreakingTokenizer::new(&unwrapped_text); let tokenizer = WordBreakingTokenizer::new(&unwrapped_text);

View file

@ -88,7 +88,7 @@ impl RenderOnce for BufferFontFamilyControl {
.child(Icon::new(IconName::Font)) .child(Icon::new(IconName::Font))
.child(DropdownMenu::new( .child(DropdownMenu::new(
"buffer-font-family", "buffer-font-family",
value.clone(), value,
ContextMenu::build(window, cx, |mut menu, _, cx| { ContextMenu::build(window, cx, |mut menu, _, cx| {
let font_family_cache = FontFamilyCache::global(cx); let font_family_cache = FontFamilyCache::global(cx);

Some files were not shown because too many files have changed in this diff Show more