Fix clippy::needless_borrow lint violations (#36444)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-18 23:54:35 +02:00 committed by GitHub
parent eecf142f06
commit 9e0e233319
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
242 changed files with 801 additions and 821 deletions

View file

@ -824,6 +824,7 @@ module_inception = { level = "deny" }
question_mark = { level = "deny" }
redundant_closure = { level = "deny" }
declare_interior_mutable_const = { level = "deny" }
needless_borrow = { level = "warn"}
# Individual rules that have violations in the codebase:
type_complexity = "allow"
# We often return trait objects from `new` functions.

View file

@ -485,7 +485,7 @@ impl ContentBlock {
}
fn resource_link_md(uri: &str) -> String {
if let Some(uri) = MentionUri::parse(&uri).log_err() {
if let Some(uri) = MentionUri::parse(uri).log_err() {
uri.as_link().to_string()
} else {
uri.to_string()
@ -1416,7 +1416,7 @@ impl AcpThread {
fn user_message(&self, id: &UserMessageId) -> Option<&UserMessage> {
self.entries.iter().find_map(|entry| {
if let AgentThreadEntry::UserMessage(message) = entry {
if message.id.as_ref() == Some(&id) {
if message.id.as_ref() == Some(id) {
Some(message)
} else {
None
@ -1430,7 +1430,7 @@ impl AcpThread {
fn user_message_mut(&mut self, id: &UserMessageId) -> Option<(usize, &mut UserMessage)> {
self.entries.iter_mut().enumerate().find_map(|(ix, entry)| {
if let AgentThreadEntry::UserMessage(message) = entry {
if message.id.as_ref() == Some(&id) {
if message.id.as_ref() == Some(id) {
Some((ix, message))
} else {
None
@ -2356,7 +2356,7 @@ mod tests {
fn cancel(&self, session_id: &acp::SessionId, cx: &mut App) {
let sessions = self.sessions.lock();
let thread = sessions.get(&session_id).unwrap().clone();
let thread = sessions.get(session_id).unwrap().clone();
cx.spawn(async move |cx| {
thread

View file

@ -71,8 +71,8 @@ impl Diff {
let hunk_ranges = {
let buffer = new_buffer.read(cx);
let diff = buffer_diff.read(cx);
diff.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&buffer))
diff.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(buffer))
.collect::<Vec<_>>()
};
@ -306,13 +306,13 @@ impl PendingDiff {
let buffer = self.buffer.read(cx);
let diff = self.diff.read(cx);
let mut ranges = diff
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&buffer))
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(buffer))
.collect::<Vec<_>>();
ranges.extend(
self.revealed_ranges
.iter()
.map(|range| range.to_point(&buffer)),
.map(|range| range.to_point(buffer)),
);
ranges.sort_unstable_by_key(|range| (range.start, Reverse(range.end)));

View file

@ -146,7 +146,7 @@ impl MentionUri {
FileIcons::get_folder_icon(false, cx)
.unwrap_or_else(|| IconName::Folder.path().into())
} else {
FileIcons::get_icon(&abs_path, cx)
FileIcons::get_icon(abs_path, cx)
.unwrap_or_else(|| IconName::File.path().into())
}
}

View file

@ -290,7 +290,7 @@ impl ActionLog {
}
_ = git_diff_updates_rx.changed().fuse() => {
if let Some(git_diff) = git_diff.as_ref() {
Self::keep_committed_edits(&this, &buffer, &git_diff, cx).await?;
Self::keep_committed_edits(&this, &buffer, git_diff, cx).await?;
}
}
}
@ -498,7 +498,7 @@ impl ActionLog {
new: new_range,
},
&new_diff_base,
&buffer_snapshot.as_rope(),
buffer_snapshot.as_rope(),
));
}
unreviewed_edits
@ -964,7 +964,7 @@ impl TrackedBuffer {
fn has_edits(&self, cx: &App) -> bool {
self.diff
.read(cx)
.hunks(&self.buffer.read(cx), cx)
.hunks(self.buffer.read(cx), cx)
.next()
.is_some()
}
@ -2268,7 +2268,7 @@ mod tests {
log::info!("quiescing...");
cx.run_until_parked();
action_log.update(cx, |log, cx| {
let tracked_buffer = log.tracked_buffers.get(&buffer).unwrap();
let tracked_buffer = log.tracked_buffers.get(buffer).unwrap();
let mut old_text = tracked_buffer.diff_base.clone();
let new_text = buffer.read(cx).as_rope();
for edit in tracked_buffer.unreviewed_edits.edits() {

View file

@ -702,7 +702,7 @@ impl ActivityIndicator {
on_click: Some(Arc::new(|this, window, cx| {
this.dismiss_error_message(&DismissErrorMessage, window, cx)
})),
tooltip_message: Some(Self::version_tooltip_message(&version)),
tooltip_message: Some(Self::version_tooltip_message(version)),
}),
AutoUpdateStatus::Installing { version } => Some(Content {
icon: Some(
@ -714,13 +714,13 @@ impl ActivityIndicator {
on_click: Some(Arc::new(|this, window, cx| {
this.dismiss_error_message(&DismissErrorMessage, window, cx)
})),
tooltip_message: Some(Self::version_tooltip_message(&version)),
tooltip_message: Some(Self::version_tooltip_message(version)),
}),
AutoUpdateStatus::Updated { version } => Some(Content {
icon: None,
message: "Click to restart and update Zed".to_string(),
on_click: Some(Arc::new(move |_, _, cx| workspace::reload(cx))),
tooltip_message: Some(Self::version_tooltip_message(&version)),
tooltip_message: Some(Self::version_tooltip_message(version)),
}),
AutoUpdateStatus::Errored => Some(Content {
icon: Some(

View file

@ -1692,7 +1692,7 @@ impl Thread {
self.last_received_chunk_at = Some(Instant::now());
let task = cx.spawn(async move |thread, cx| {
let stream_completion_future = model.stream_completion(request, &cx);
let stream_completion_future = model.stream_completion(request, cx);
let initial_token_usage =
thread.read_with(cx, |thread, _cx| thread.cumulative_token_usage);
let stream_completion = async {
@ -1824,7 +1824,7 @@ impl Thread {
let streamed_input = if tool_use.is_input_complete {
None
} else {
Some((&tool_use.input).clone())
Some(tool_use.input.clone())
};
let ui_text = thread.tool_use.request_tool_use(
@ -2051,7 +2051,7 @@ impl Thread {
retry_scheduled = thread
.handle_retryable_error_with_delay(
&completion_error,
completion_error,
Some(retry_strategy),
model.clone(),
intent,
@ -2130,7 +2130,7 @@ impl Thread {
self.pending_summary = cx.spawn(async move |this, cx| {
let result = async {
let mut messages = model.model.stream_completion(request, &cx).await?;
let mut messages = model.model.stream_completion(request, cx).await?;
let mut new_summary = String::new();
while let Some(event) = messages.next().await {
@ -2456,7 +2456,7 @@ impl Thread {
// which result to prefer (the old task could complete after the new one, resulting in a
// stale summary).
self.detailed_summary_task = cx.spawn(async move |thread, cx| {
let stream = model.stream_completion_text(request, &cx);
let stream = model.stream_completion_text(request, cx);
let Some(mut messages) = stream.await.log_err() else {
thread
.update(cx, |thread, _cx| {
@ -4043,7 +4043,7 @@ fn main() {{
});
let fake_model = model.as_fake();
simulate_successful_response(&fake_model, cx);
simulate_successful_response(fake_model, cx);
// Should start generating summary when there are >= 2 messages
thread.read_with(cx, |thread, _| {
@ -4138,7 +4138,7 @@ fn main() {{
});
let fake_model = model.as_fake();
simulate_successful_response(&fake_model, cx);
simulate_successful_response(fake_model, cx);
thread.read_with(cx, |thread, _| {
// State is still Error, not Generating
@ -5420,7 +5420,7 @@ fn main() {{
});
let fake_model = model.as_fake();
simulate_successful_response(&fake_model, cx);
simulate_successful_response(fake_model, cx);
thread.read_with(cx, |thread, _| {
assert!(matches!(thread.summary(), ThreadSummary::Generating));

View file

@ -91,7 +91,7 @@ impl LanguageModels {
for provider in &providers {
for model in provider.recommended_models(cx) {
recommended_models.insert(model.id());
recommended.push(Self::map_language_model_to_info(&model, &provider));
recommended.push(Self::map_language_model_to_info(&model, provider));
}
}
if !recommended.is_empty() {

View file

@ -62,7 +62,7 @@ fn contains(
handlebars::RenderError::new("contains: missing or invalid query parameter")
})?;
if list.contains(&query) {
if list.contains(query) {
out.write("true")?;
}

View file

@ -173,7 +173,7 @@ impl UserMessage {
&mut symbol_context,
"\n{}",
MarkdownCodeBlock {
tag: &codeblock_tag(&abs_path, None),
tag: &codeblock_tag(abs_path, None),
text: &content.to_string(),
}
)
@ -189,8 +189,8 @@ impl UserMessage {
&mut rules_context,
"\n{}",
MarkdownCodeBlock {
tag: &codeblock_tag(&path, Some(line_range)),
text: &content
tag: &codeblock_tag(path, Some(line_range)),
text: content
}
)
.ok();
@ -207,7 +207,7 @@ impl UserMessage {
"\n{}",
MarkdownCodeBlock {
tag: "",
text: &content
text: content
}
)
.ok();
@ -1048,7 +1048,7 @@ impl Thread {
tools,
tool_choice: None,
stop: Vec::new(),
temperature: AgentSettings::temperature_for_model(&model, cx),
temperature: AgentSettings::temperature_for_model(model, cx),
thinking_allowed: true,
};

View file

@ -103,7 +103,7 @@ impl ContextServerRegistry {
self.reload_tools_for_server(server_id.clone(), cx);
}
ContextServerStatus::Stopped | ContextServerStatus::Error(_) => {
self.registered_servers.remove(&server_id);
self.registered_servers.remove(server_id);
cx.notify();
}
}

View file

@ -471,7 +471,7 @@ fn resolve_path(
let parent_entry = parent_project_path
.as_ref()
.and_then(|path| project.entry_for_path(&path, cx))
.and_then(|path| project.entry_for_path(path, cx))
.context("Can't create file: parent directory doesn't exist")?;
anyhow::ensure!(

View file

@ -80,7 +80,7 @@ impl AgentTool for TerminalTool {
let first_line = lines.next().unwrap_or_default();
let remaining_line_count = lines.count();
match remaining_line_count {
0 => MarkdownInlineCode(&first_line).to_string().into(),
0 => MarkdownInlineCode(first_line).to_string().into(),
1 => MarkdownInlineCode(&format!(
"{} - {} more line",
first_line, remaining_line_count

View file

@ -19,14 +19,14 @@ pub async fn connect(
root_dir: &Path,
cx: &mut AsyncApp,
) -> Result<Rc<dyn AgentConnection>> {
let conn = v1::AcpConnection::stdio(server_name, command.clone(), &root_dir, cx).await;
let conn = v1::AcpConnection::stdio(server_name, command.clone(), root_dir, cx).await;
match conn {
Ok(conn) => Ok(Rc::new(conn) as _),
Err(err) if err.is::<UnsupportedVersion>() => {
// Consider re-using initialize response and subprocess when adding another version here
let conn: Rc<dyn AgentConnection> =
Rc::new(v0::AcpConnection::stdio(server_name, command, &root_dir, cx).await?);
Rc::new(v0::AcpConnection::stdio(server_name, command, root_dir, cx).await?);
Ok(conn)
}
Err(err) => Err(err),

View file

@ -291,7 +291,7 @@ impl AgentConnection for ClaudeAgentConnection {
fn cancel(&self, session_id: &acp::SessionId, _cx: &mut App) {
let sessions = self.sessions.borrow();
let Some(session) = sessions.get(&session_id) else {
let Some(session) = sessions.get(session_id) else {
log::warn!("Attempted to cancel nonexistent session {}", session_id);
return;
};

View file

@ -552,11 +552,11 @@ fn build_code_label_for_full_path(file_name: &str, directory: Option<&str>, cx:
let comment_id = cx.theme().syntax().highlight_id("comment").map(HighlightId);
let mut label = CodeLabel::default();
label.push_str(&file_name, None);
label.push_str(file_name, None);
label.push_str(" ", None);
if let Some(directory) = directory {
label.push_str(&directory, comment_id);
label.push_str(directory, comment_id);
}
label.filter_range = 0..label.text().len();

View file

@ -1191,7 +1191,7 @@ impl MentionSet {
})
}
MentionUri::Fetch { url } => {
let Some(content) = self.fetch_results.get(&url).cloned() else {
let Some(content) = self.fetch_results.get(url).cloned() else {
return Task::ready(Err(anyhow!("missing fetch result")));
};
let uri = uri.clone();

View file

@ -330,7 +330,7 @@ async fn fuzzy_search(
.collect::<Vec<_>>();
let mut matches = match_strings(
&candidates,
&query,
query,
false,
true,
100,

View file

@ -696,7 +696,7 @@ impl AcpThreadView {
};
diff.update(cx, |diff, cx| {
diff.move_to_path(PathKey::for_buffer(&buffer, cx), window, cx)
diff.move_to_path(PathKey::for_buffer(buffer, cx), window, cx)
})
}
@ -722,13 +722,13 @@ impl AcpThreadView {
let len = thread.read(cx).entries().len();
let index = len - 1;
self.entry_view_state.update(cx, |view_state, cx| {
view_state.sync_entry(index, &thread, window, cx)
view_state.sync_entry(index, thread, window, cx)
});
self.list_state.splice(index..index, 1);
}
AcpThreadEvent::EntryUpdated(index) => {
self.entry_view_state.update(cx, |view_state, cx| {
view_state.sync_entry(*index, &thread, window, cx)
view_state.sync_entry(*index, thread, window, cx)
});
self.list_state.splice(*index..index + 1, 1);
}
@ -1427,7 +1427,7 @@ impl AcpThreadView {
Empty.into_any_element()
}
}
ToolCallContent::Diff(diff) => self.render_diff_editor(entry_ix, &diff, cx),
ToolCallContent::Diff(diff) => self.render_diff_editor(entry_ix, diff, cx),
ToolCallContent::Terminal(terminal) => {
self.render_terminal_tool_call(entry_ix, terminal, tool_call, window, cx)
}
@ -1583,7 +1583,7 @@ impl AcpThreadView {
.border_color(self.tool_card_border_color(cx))
.child(
if let Some(entry) = self.entry_view_state.read(cx).entry(entry_ix)
&& let Some(editor) = entry.editor_for_diff(&diff)
&& let Some(editor) = entry.editor_for_diff(diff)
{
editor.clone().into_any_element()
} else {
@ -1783,7 +1783,7 @@ impl AcpThreadView {
.entry_view_state
.read(cx)
.entry(entry_ix)
.and_then(|entry| entry.terminal(&terminal));
.and_then(|entry| entry.terminal(terminal));
let show_output = self.terminal_expanded && terminal_view.is_some();
v_flex()
@ -2420,7 +2420,7 @@ impl AcpThreadView {
.buffer_font(cx)
});
let file_icon = FileIcons::get_icon(&path, cx)
let file_icon = FileIcons::get_icon(path, cx)
.map(Icon::from_path)
.map(|icon| icon.color(Color::Muted).size(IconSize::Small))
.unwrap_or_else(|| {
@ -3453,7 +3453,7 @@ impl Render for AcpThreadView {
configuration_view,
..
} => self.render_auth_required_state(
&connection,
connection,
description.as_ref(),
configuration_view.as_ref(),
window,

View file

@ -1044,12 +1044,12 @@ impl ActiveThread {
);
}
ThreadEvent::StreamedAssistantText(message_id, text) => {
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(&message_id) {
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(message_id) {
rendered_message.append_text(text, cx);
}
}
ThreadEvent::StreamedAssistantThinking(message_id, text) => {
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(&message_id) {
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(message_id) {
rendered_message.append_thinking(text, cx);
}
}
@ -2473,7 +2473,7 @@ impl ActiveThread {
message_id,
index,
content.clone(),
&scroll_handle,
scroll_handle,
Some(index) == pending_thinking_segment_index,
window,
cx,

View file

@ -207,7 +207,7 @@ impl AgentDiffPane {
),
match &thread {
AgentDiffThread::Native(thread) => {
Some(cx.subscribe(&thread, |this, _thread, event, cx| {
Some(cx.subscribe(thread, |this, _thread, event, cx| {
this.handle_thread_event(event, cx)
}))
}
@ -398,7 +398,7 @@ fn keep_edits_in_selection(
.disjoint_anchor_ranges()
.collect::<Vec<_>>();
keep_edits_in_ranges(editor, buffer_snapshot, &thread, ranges, window, cx)
keep_edits_in_ranges(editor, buffer_snapshot, thread, ranges, window, cx)
}
fn reject_edits_in_selection(
@ -412,7 +412,7 @@ fn reject_edits_in_selection(
.selections
.disjoint_anchor_ranges()
.collect::<Vec<_>>();
reject_edits_in_ranges(editor, buffer_snapshot, &thread, ranges, window, cx)
reject_edits_in_ranges(editor, buffer_snapshot, thread, ranges, window, cx)
}
fn keep_edits_in_ranges(
@ -1001,7 +1001,7 @@ impl AgentDiffToolbar {
return;
};
*state = agent_diff.read(cx).editor_state(&editor);
*state = agent_diff.read(cx).editor_state(editor);
self.update_location(cx);
cx.notify();
}
@ -1343,13 +1343,13 @@ impl AgentDiff {
});
let thread_subscription = match &thread {
AgentDiffThread::Native(thread) => cx.subscribe_in(&thread, window, {
AgentDiffThread::Native(thread) => cx.subscribe_in(thread, window, {
let workspace = workspace.clone();
move |this, _thread, event, window, cx| {
this.handle_native_thread_event(&workspace, event, window, cx)
}
}),
AgentDiffThread::AcpThread(thread) => cx.subscribe_in(&thread, window, {
AgentDiffThread::AcpThread(thread) => cx.subscribe_in(thread, window, {
let workspace = workspace.clone();
move |this, thread, event, window, cx| {
this.handle_acp_thread_event(&workspace, thread, event, window, cx)
@ -1357,11 +1357,11 @@ impl AgentDiff {
}),
};
if let Some(workspace_thread) = self.workspace_threads.get_mut(&workspace) {
if let Some(workspace_thread) = self.workspace_threads.get_mut(workspace) {
// replace thread and action log subscription, but keep editors
workspace_thread.thread = thread.downgrade();
workspace_thread._thread_subscriptions = (action_log_subscription, thread_subscription);
self.update_reviewing_editors(&workspace, window, cx);
self.update_reviewing_editors(workspace, window, cx);
return;
}
@ -1677,7 +1677,7 @@ impl AgentDiff {
editor.register_addon(EditorAgentDiffAddon);
});
} else {
unaffected.remove(&weak_editor);
unaffected.remove(weak_editor);
}
if new_state == EditorState::Reviewing && previous_state != Some(new_state) {
@ -1730,7 +1730,7 @@ impl AgentDiff {
fn editor_state(&self, editor: &WeakEntity<Editor>) -> EditorState {
self.reviewing_editors
.get(&editor)
.get(editor)
.cloned()
.unwrap_or(EditorState::Idle)
}

View file

@ -2923,7 +2923,7 @@ impl AgentPanel {
.style(ButtonStyle::Tinted(ui::TintColor::Warning))
.label_size(LabelSize::Small)
.key_binding(
KeyBinding::for_action_in(&OpenSettings, &focus_handle, window, cx)
KeyBinding::for_action_in(&OpenSettings, focus_handle, window, cx)
.map(|kb| kb.size(rems_from_px(12.))),
)
.on_click(|_event, window, cx| {
@ -3329,7 +3329,7 @@ impl AgentPanel {
.paths()
.into_iter()
.map(|path| {
Workspace::project_path_for_path(this.project.clone(), &path, false, cx)
Workspace::project_path_for_path(this.project.clone(), path, false, cx)
})
.collect::<Vec<_>>();
cx.spawn_in(window, async move |this, cx| {
@ -3599,7 +3599,7 @@ impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist {
let text_thread_store = None;
let context_store = cx.new(|_| ContextStore::new(project.clone(), None));
assistant.assist(
&prompt_editor,
prompt_editor,
self.workspace.clone(),
context_store,
project,

View file

@ -388,7 +388,7 @@ impl CodegenAlternative {
} else {
let request = self.build_request(&model, user_prompt, cx)?;
cx.spawn(async move |_, cx| {
Ok(model.stream_completion_text(request.await, &cx).await?)
Ok(model.stream_completion_text(request.await, cx).await?)
})
.boxed_local()
};
@ -447,7 +447,7 @@ impl CodegenAlternative {
}
});
let temperature = AgentSettings::temperature_for_model(&model, cx);
let temperature = AgentSettings::temperature_for_model(model, cx);
Ok(cx.spawn(async move |_cx| {
let mut request_message = LanguageModelRequestMessage {
@ -1028,7 +1028,7 @@ where
chunk.push('\n');
}
chunk.push_str(&line);
chunk.push_str(line);
}
consumed += line.len();

View file

@ -728,11 +728,11 @@ fn build_code_label_for_full_path(file_name: &str, directory: Option<&str>, cx:
let comment_id = cx.theme().syntax().highlight_id("comment").map(HighlightId);
let mut label = CodeLabel::default();
label.push_str(&file_name, None);
label.push_str(file_name, None);
label.push_str(" ", None);
if let Some(directory) = directory {
label.push_str(&directory, comment_id);
label.push_str(directory, comment_id);
}
label.filter_range = 0..label.text().len();

View file

@ -315,7 +315,7 @@ pub fn render_file_context_entry(
context_store: WeakEntity<ContextStore>,
cx: &App,
) -> Stateful<Div> {
let (file_name, directory) = extract_file_name_and_directory(&path, path_prefix);
let (file_name, directory) = extract_file_name_and_directory(path, path_prefix);
let added = context_store.upgrade().and_then(|context_store| {
let project_path = ProjectPath {
@ -334,7 +334,7 @@ pub fn render_file_context_entry(
let file_icon = if is_directory {
FileIcons::get_folder_icon(false, cx)
} else {
FileIcons::get_icon(&path, cx)
FileIcons::get_icon(path, cx)
}
.map(Icon::from_path)
.unwrap_or_else(|| Icon::new(IconName::File));

View file

@ -289,7 +289,7 @@ pub(crate) fn search_symbols(
.iter()
.enumerate()
.map(|(id, symbol)| {
StringMatchCandidate::new(id, &symbol.label.filter_text())
StringMatchCandidate::new(id, symbol.label.filter_text())
})
.partition(|candidate| {
project

View file

@ -167,7 +167,7 @@ impl PickerDelegate for ThreadContextPickerDelegate {
return;
};
let open_thread_task =
thread_store.update(cx, |this, cx| this.open_thread(&id, window, cx));
thread_store.update(cx, |this, cx| this.open_thread(id, window, cx));
cx.spawn(async move |this, cx| {
let thread = open_thread_task.await?;
@ -236,7 +236,7 @@ pub fn render_thread_context_entry(
let is_added = match entry {
ThreadContextEntry::Thread { id, .. } => context_store
.upgrade()
.map_or(false, |ctx_store| ctx_store.read(cx).includes_thread(&id)),
.map_or(false, |ctx_store| ctx_store.read(cx).includes_thread(id)),
ThreadContextEntry::Context { path, .. } => {
context_store.upgrade().map_or(false, |ctx_store| {
ctx_store.read(cx).includes_text_thread(path)
@ -338,7 +338,7 @@ pub(crate) fn search_threads(
let candidates = threads
.iter()
.enumerate()
.map(|(id, (_, thread))| StringMatchCandidate::new(id, &thread.title()))
.map(|(id, (_, thread))| StringMatchCandidate::new(id, thread.title()))
.collect::<Vec<_>>();
let matches = fuzzy::match_strings(
&candidates,

View file

@ -145,7 +145,7 @@ impl ContextStrip {
}
let file_name = active_buffer.file()?.file_name(cx);
let icon_path = FileIcons::get_icon(&Path::new(&file_name), cx);
let icon_path = FileIcons::get_icon(Path::new(&file_name), cx);
Some(SuggestedContext::File {
name: file_name.to_string_lossy().into_owned().into(),
buffer: active_buffer_entity.downgrade(),
@ -377,7 +377,7 @@ impl ContextStrip {
fn add_suggested_context(&mut self, suggested: &SuggestedContext, cx: &mut Context<Self>) {
self.context_store.update(cx, |context_store, cx| {
context_store.add_suggested_context(&suggested, cx)
context_store.add_suggested_context(suggested, cx)
});
cx.notify();
}

View file

@ -526,9 +526,9 @@ impl InlineAssistant {
if assist_to_focus.is_none() {
let focus_assist = if newest_selection.reversed {
range.start.to_point(&snapshot) == newest_selection.start
range.start.to_point(snapshot) == newest_selection.start
} else {
range.end.to_point(&snapshot) == newest_selection.end
range.end.to_point(snapshot) == newest_selection.end
};
if focus_assist {
assist_to_focus = Some(assist_id);
@ -550,7 +550,7 @@ impl InlineAssistant {
let editor_assists = self
.assists_by_editor
.entry(editor.downgrade())
.or_insert_with(|| EditorInlineAssists::new(&editor, window, cx));
.or_insert_with(|| EditorInlineAssists::new(editor, window, cx));
let mut assist_group = InlineAssistGroup::new();
for (assist_id, range, prompt_editor, prompt_block_id, end_block_id) in assists {
let codegen = prompt_editor.read(cx).codegen().clone();
@ -649,7 +649,7 @@ impl InlineAssistant {
let editor_assists = self
.assists_by_editor
.entry(editor.downgrade())
.or_insert_with(|| EditorInlineAssists::new(&editor, window, cx));
.or_insert_with(|| EditorInlineAssists::new(editor, window, cx));
let mut assist_group = InlineAssistGroup::new();
self.assists.insert(

View file

@ -75,7 +75,7 @@ impl<T: 'static> Render for PromptEditor<T> {
let codegen = codegen.read(cx);
if codegen.alternative_count(cx) > 1 {
buttons.push(self.render_cycle_controls(&codegen, cx));
buttons.push(self.render_cycle_controls(codegen, cx));
}
let editor_margins = editor_margins.lock();

View file

@ -296,7 +296,7 @@ impl ModelMatcher {
pub fn fuzzy_search(&self, query: &str) -> Vec<ModelInfo> {
let mut matches = self.bg_executor.block(match_strings(
&self.candidates,
&query,
query,
false,
true,
100,

View file

@ -1166,7 +1166,7 @@ impl MessageEditor {
.buffer_font(cx)
});
let file_icon = FileIcons::get_icon(&path, cx)
let file_icon = FileIcons::get_icon(path, cx)
.map(Icon::from_path)
.map(|icon| icon.color(Color::Muted).size(IconSize::Small))
.unwrap_or_else(|| {
@ -1559,9 +1559,8 @@ impl ContextCreasesAddon {
cx: &mut Context<Editor>,
) {
self.creases.entry(key).or_default().extend(creases);
self._subscription = Some(cx.subscribe(
&context_store,
|editor, _, event, cx| match event {
self._subscription = Some(
cx.subscribe(context_store, |editor, _, event, cx| match event {
ContextStoreEvent::ContextRemoved(key) => {
let Some(this) = editor.addon_mut::<Self>() else {
return;
@ -1581,8 +1580,8 @@ impl ContextCreasesAddon {
editor.edit(ranges.into_iter().zip(replacement_texts), cx);
cx.notify();
}
},
))
}),
)
}
pub fn into_inner(self) -> HashMap<AgentContextKey, Vec<(CreaseId, SharedString)>> {

View file

@ -214,7 +214,7 @@ impl PickerDelegate for SlashCommandDelegate {
let mut label = format!("{}", info.name);
if let Some(args) = info.args.as_ref().filter(|_| selected)
{
label.push_str(&args);
label.push_str(args);
}
Label::new(label)
.single_line()

View file

@ -48,7 +48,7 @@ impl TerminalCodegen {
let prompt = prompt_task.await;
let model_telemetry_id = model.telemetry_id();
let model_provider_id = model.provider_id();
let response = model.stream_completion_text(prompt, &cx).await;
let response = model.stream_completion_text(prompt, cx).await;
let generate = async {
let message_id = response
.as_ref()

View file

@ -353,7 +353,7 @@ impl AddedContext {
name,
parent,
tooltip: Some(full_path_string),
icon_path: FileIcons::get_icon(&full_path, cx),
icon_path: FileIcons::get_icon(full_path, cx),
status: ContextStatus::Ready,
render_hover: None,
handle: AgentContextHandle::File(handle),
@ -615,7 +615,7 @@ impl AddedContext {
let full_path_string: SharedString = full_path.to_string_lossy().into_owned().into();
let (name, parent) =
extract_file_name_and_directory_from_full_path(full_path, &full_path_string);
let icon_path = FileIcons::get_icon(&full_path, cx);
let icon_path = FileIcons::get_icon(full_path, cx);
(name, parent, icon_path)
} else {
("Image".into(), None, None)
@ -706,7 +706,7 @@ impl ContextFileExcerpt {
.and_then(|p| p.file_name())
.map(|n| n.to_string_lossy().into_owned().into());
let icon_path = FileIcons::get_icon(&full_path, cx);
let icon_path = FileIcons::get_icon(full_path, cx);
ContextFileExcerpt {
file_name_and_range: file_name_and_range.into(),

View file

@ -592,7 +592,7 @@ impl MessageMetadata {
pub fn is_cache_valid(&self, buffer: &BufferSnapshot, range: &Range<usize>) -> bool {
let result = match &self.cache {
Some(MessageCacheMetadata { cached_at, .. }) => !buffer.has_edits_since_in_range(
&cached_at,
cached_at,
Range {
start: buffer.anchor_at(range.start, Bias::Right),
end: buffer.anchor_at(range.end, Bias::Left),
@ -1413,7 +1413,7 @@ impl AssistantContext {
}
let request = {
let mut req = self.to_completion_request(Some(&model), cx);
let mut req = self.to_completion_request(Some(model), cx);
// Skip the last message because it's likely to change and
// therefore would be a waste to cache.
req.messages.pop();
@ -1428,7 +1428,7 @@ impl AssistantContext {
let model = Arc::clone(model);
self.pending_cache_warming_task = cx.spawn(async move |this, cx| {
async move {
match model.stream_completion(request, &cx).await {
match model.stream_completion(request, cx).await {
Ok(mut stream) => {
stream.next().await;
log::info!("Cache warming completed successfully");
@ -1661,12 +1661,12 @@ impl AssistantContext {
) -> Range<usize> {
let buffer = self.buffer.read(cx);
let start_ix = match all_annotations
.binary_search_by(|probe| probe.range().end.cmp(&range.start, &buffer))
.binary_search_by(|probe| probe.range().end.cmp(&range.start, buffer))
{
Ok(ix) | Err(ix) => ix,
};
let end_ix = match all_annotations
.binary_search_by(|probe| probe.range().start.cmp(&range.end, &buffer))
.binary_search_by(|probe| probe.range().start.cmp(&range.end, buffer))
{
Ok(ix) => ix + 1,
Err(ix) => ix,
@ -2045,7 +2045,7 @@ impl AssistantContext {
let task = cx.spawn({
async move |this, cx| {
let stream = model.stream_completion(request, &cx);
let stream = model.stream_completion(request, cx);
let assistant_message_id = assistant_message.id;
let mut response_latency = None;
let stream_completion = async {
@ -2708,7 +2708,7 @@ impl AssistantContext {
self.summary_task = cx.spawn(async move |this, cx| {
let result = async {
let stream = model.model.stream_completion_text(request, &cx);
let stream = model.model.stream_completion_text(request, cx);
let mut messages = stream.await?;
let mut replaced = !replace_old;
@ -2927,7 +2927,7 @@ impl AssistantContext {
if let Some(old_path) = old_path.as_ref() {
if new_path.as_path() != old_path.as_ref() {
fs.rename(
&old_path,
old_path,
&new_path,
RenameOptions {
overwrite: true,

View file

@ -1300,7 +1300,7 @@ fn test_summarize_error(
context.assist(cx);
});
simulate_successful_response(&model, cx);
simulate_successful_response(model, cx);
context.read_with(cx, |context, _| {
assert!(!context.summary().content().unwrap().done);

View file

@ -44,7 +44,7 @@ impl SlashCommand for ContextServerSlashCommand {
parts.push(arg.name.as_str());
}
}
create_label_for_command(&parts[0], &parts[1..], cx)
create_label_for_command(parts[0], &parts[1..], cx)
}
fn description(&self) -> String {

View file

@ -249,7 +249,7 @@ fn collect_diagnostics(
let worktree = worktree.read(cx);
let worktree_root_path = Path::new(worktree.root_name());
let relative_path = path.strip_prefix(worktree_root_path).ok()?;
worktree.absolutize(&relative_path).ok()
worktree.absolutize(relative_path).ok()
})
})
.is_some()
@ -365,7 +365,7 @@ pub fn collect_buffer_diagnostics(
) {
for (_, group) in snapshot.diagnostic_groups(None) {
let entry = &group.entries[group.primary_ix];
collect_diagnostic(output, entry, &snapshot, include_warnings)
collect_diagnostic(output, entry, snapshot, include_warnings)
}
}
@ -396,7 +396,7 @@ fn collect_diagnostic(
let start_row = range.start.row.saturating_sub(EXCERPT_EXPANSION_SIZE);
let end_row = (range.end.row + EXCERPT_EXPANSION_SIZE).min(snapshot.max_point().row) + 1;
let excerpt_range =
Point::new(start_row, 0).to_offset(&snapshot)..Point::new(end_row, 0).to_offset(&snapshot);
Point::new(start_row, 0).to_offset(snapshot)..Point::new(end_row, 0).to_offset(snapshot);
output.text.push_str("```");
if let Some(language_name) = snapshot.language().map(|l| l.code_fence_block_name()) {

View file

@ -536,7 +536,7 @@ fn resolve_path(
let parent_entry = parent_project_path
.as_ref()
.and_then(|path| project.entry_for_path(&path, cx))
.and_then(|path| project.entry_for_path(path, cx))
.context("Can't create file: parent directory doesn't exist")?;
anyhow::ensure!(
@ -723,13 +723,13 @@ impl EditFileToolCard {
let buffer = buffer.read(cx);
let diff = diff.read(cx);
let mut ranges = diff
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&buffer))
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, buffer, cx)
.map(|diff_hunk| diff_hunk.buffer_range.to_point(buffer))
.collect::<Vec<_>>();
ranges.extend(
self.revealed_ranges
.iter()
.map(|range| range.to_point(&buffer)),
.map(|range| range.to_point(buffer)),
);
ranges.sort_unstable_by_key(|range| (range.start, Reverse(range.end)));

View file

@ -894,7 +894,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not find files outside the project worktree"
@ -920,7 +920,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.iter().any(|p| p.contains("allowed_file.rs")),
"grep_tool should be able to search files inside worktrees"
@ -946,7 +946,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not search files in .secretdir (file_scan_exclusions)"
@ -971,7 +971,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not search .mymetadata files (file_scan_exclusions)"
@ -997,7 +997,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not search .mysecrets (private_files)"
@ -1022,7 +1022,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not search .privatekey files (private_files)"
@ -1047,7 +1047,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not search .mysensitive files (private_files)"
@ -1073,7 +1073,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.iter().any(|p| p.contains("normal_file.rs")),
"Should be able to search normal files"
@ -1100,7 +1100,7 @@ mod tests {
})
.await;
let results = result.unwrap();
let paths = extract_paths_from_results(&results.content.as_str().unwrap());
let paths = extract_paths_from_results(results.content.as_str().unwrap());
assert!(
paths.is_empty(),
"grep_tool should not allow escaping project boundaries with relative paths"
@ -1206,7 +1206,7 @@ mod tests {
.unwrap();
let content = result.content.as_str().unwrap();
let paths = extract_paths_from_results(&content);
let paths = extract_paths_from_results(content);
// Should find matches in non-private files
assert!(
@ -1271,7 +1271,7 @@ mod tests {
.unwrap();
let content = result.content.as_str().unwrap();
let paths = extract_paths_from_results(&content);
let paths = extract_paths_from_results(content);
// Should only find matches in worktree1 *.rs files (excluding private ones)
assert!(

View file

@ -81,7 +81,7 @@ fn fit_patch_to_size(patch: &str, max_size: usize) -> String {
// Compression level 1: remove context lines in diff bodies, but
// leave the counts and positions of inserted/deleted lines
let mut current_size = patch.len();
let mut file_patches = split_patch(&patch);
let mut file_patches = split_patch(patch);
file_patches.sort_by_key(|patch| patch.len());
let compressed_patches = file_patches
.iter()

View file

@ -105,7 +105,7 @@ impl Tool for TerminalTool {
let first_line = lines.next().unwrap_or_default();
let remaining_line_count = lines.count();
match remaining_line_count {
0 => MarkdownInlineCode(&first_line).to_string(),
0 => MarkdownInlineCode(first_line).to_string(),
1 => MarkdownInlineCode(&format!(
"{} - {} more line",
first_line, remaining_line_count

View file

@ -231,7 +231,7 @@ fn apply_dirty_filename_style(
let highlight = vec![(filename_position..text.len(), highlight_style)];
Some(
StyledText::new(text)
.with_default_highlights(&text_style, highlight)
.with_default_highlights(text_style, highlight)
.into_any(),
)
}

View file

@ -928,7 +928,7 @@ impl BufferDiff {
let new_index_text = self.inner.stage_or_unstage_hunks_impl(
&self.secondary_diff.as_ref()?.read(cx).inner,
stage,
&hunks,
hunks,
buffer,
file_exists,
);
@ -952,12 +952,12 @@ impl BufferDiff {
cx: &App,
) -> Option<Range<Anchor>> {
let start = self
.hunks_intersecting_range(range.clone(), &buffer, cx)
.hunks_intersecting_range(range.clone(), buffer, cx)
.next()?
.buffer_range
.start;
let end = self
.hunks_intersecting_range_rev(range.clone(), &buffer)
.hunks_intersecting_range_rev(range.clone(), buffer)
.next()?
.buffer_range
.end;
@ -1031,18 +1031,18 @@ impl BufferDiff {
&& state.base_text.syntax_update_count()
== new_state.base_text.syntax_update_count() =>
{
(false, new_state.compare(&state, buffer))
(false, new_state.compare(state, buffer))
}
_ => (true, Some(text::Anchor::MIN..text::Anchor::MAX)),
};
if let Some(secondary_changed_range) = secondary_diff_change {
if let Some(secondary_hunk_range) =
self.range_to_hunk_range(secondary_changed_range, &buffer, cx)
self.range_to_hunk_range(secondary_changed_range, buffer, cx)
{
if let Some(range) = &mut changed_range {
range.start = secondary_hunk_range.start.min(&range.start, &buffer);
range.end = secondary_hunk_range.end.max(&range.end, &buffer);
range.start = secondary_hunk_range.start.min(&range.start, buffer);
range.end = secondary_hunk_range.end.max(&range.end, buffer);
} else {
changed_range = Some(secondary_hunk_range);
}
@ -1057,8 +1057,8 @@ impl BufferDiff {
if let Some((first, last)) = state.pending_hunks.first().zip(state.pending_hunks.last())
{
if let Some(range) = &mut changed_range {
range.start = range.start.min(&first.buffer_range.start, &buffer);
range.end = range.end.max(&last.buffer_range.end, &buffer);
range.start = range.start.min(&first.buffer_range.start, buffer);
range.end = range.end.max(&last.buffer_range.end, buffer);
} else {
changed_range = Some(first.buffer_range.start..last.buffer_range.end);
}
@ -1797,7 +1797,7 @@ mod tests {
uncommitted_diff.update(cx, |diff, cx| {
let hunks = diff
.hunks_intersecting_range(hunk_range.clone(), &buffer, &cx)
.hunks_intersecting_range(hunk_range.clone(), &buffer, cx)
.collect::<Vec<_>>();
for hunk in &hunks {
assert_ne!(
@ -1812,7 +1812,7 @@ mod tests {
.to_string();
let hunks = diff
.hunks_intersecting_range(hunk_range.clone(), &buffer, &cx)
.hunks_intersecting_range(hunk_range.clone(), &buffer, cx)
.collect::<Vec<_>>();
for hunk in &hunks {
assert_eq!(
@ -1870,7 +1870,7 @@ mod tests {
.to_string();
assert_eq!(new_index_text, buffer_text);
let hunk = diff.hunks(&buffer, &cx).next().unwrap();
let hunk = diff.hunks(&buffer, cx).next().unwrap();
assert_eq!(
hunk.secondary_status,
DiffHunkSecondaryStatus::SecondaryHunkRemovalPending
@ -1882,7 +1882,7 @@ mod tests {
.to_string();
assert_eq!(index_text, head_text);
let hunk = diff.hunks(&buffer, &cx).next().unwrap();
let hunk = diff.hunks(&buffer, cx).next().unwrap();
// optimistically unstaged (fine, could also be HasSecondaryHunk)
assert_eq!(
hunk.secondary_status,

View file

@ -518,11 +518,11 @@ mod linux {
) -> Result<(), std::io::Error> {
for _ in 0..100 {
thread::sleep(Duration::from_millis(10));
if sock.connect_addr(&sock_addr).is_ok() {
if sock.connect_addr(sock_addr).is_ok() {
return Ok(());
}
}
sock.connect_addr(&sock_addr)
sock.connect_addr(sock_addr)
}
}
}

View file

@ -162,7 +162,7 @@ pub fn init(client: &Arc<Client>, cx: &mut App) {
let client = client.clone();
move |_: &SignIn, cx| {
if let Some(client) = client.upgrade() {
cx.spawn(async move |cx| client.sign_in_with_optional_connect(true, &cx).await)
cx.spawn(async move |cx| client.sign_in_with_optional_connect(true, cx).await)
.detach_and_log_err(cx);
}
}
@ -173,7 +173,7 @@ pub fn init(client: &Arc<Client>, cx: &mut App) {
move |_: &SignOut, cx| {
if let Some(client) = client.upgrade() {
cx.spawn(async move |cx| {
client.sign_out(&cx).await;
client.sign_out(cx).await;
})
.detach();
}
@ -185,7 +185,7 @@ pub fn init(client: &Arc<Client>, cx: &mut App) {
move |_: &Reconnect, cx| {
if let Some(client) = client.upgrade() {
cx.spawn(async move |cx| {
client.reconnect(&cx);
client.reconnect(cx);
})
.detach();
}
@ -677,7 +677,7 @@ impl Client {
let mut delay = INITIAL_RECONNECTION_DELAY;
loop {
match client.connect(true, &cx).await {
match client.connect(true, cx).await {
ConnectionResult::Timeout => {
log::error!("client connect attempt timed out")
}
@ -701,7 +701,7 @@ impl Client {
Status::ReconnectionError {
next_reconnection: Instant::now() + delay,
},
&cx,
cx,
);
let jitter =
Duration::from_millis(rng.gen_range(0..delay.as_millis() as u64));
@ -1151,7 +1151,7 @@ impl Client {
let this = self.clone();
async move |cx| {
while let Some(message) = incoming.next().await {
this.handle_message(message, &cx);
this.handle_message(message, cx);
// Don't starve the main thread when receiving lots of messages at once.
smol::future::yield_now().await;
}
@ -1169,12 +1169,12 @@ impl Client {
peer_id,
})
{
this.set_status(Status::SignedOut, &cx);
this.set_status(Status::SignedOut, cx);
}
}
Err(err) => {
log::error!("connection error: {:?}", err);
this.set_status(Status::ConnectionLost, &cx);
this.set_status(Status::ConnectionLost, cx);
}
}
})

View file

@ -943,21 +943,21 @@ impl Database {
let current_merge_conflicts = db_repository_entry
.current_merge_conflicts
.as_ref()
.map(|conflicts| serde_json::from_str(&conflicts))
.map(|conflicts| serde_json::from_str(conflicts))
.transpose()?
.unwrap_or_default();
let branch_summary = db_repository_entry
.branch_summary
.as_ref()
.map(|branch_summary| serde_json::from_str(&branch_summary))
.map(|branch_summary| serde_json::from_str(branch_summary))
.transpose()?
.unwrap_or_default();
let head_commit_details = db_repository_entry
.head_commit_details
.as_ref()
.map(|head_commit_details| serde_json::from_str(&head_commit_details))
.map(|head_commit_details| serde_json::from_str(head_commit_details))
.transpose()?
.unwrap_or_default();

View file

@ -746,21 +746,21 @@ impl Database {
let current_merge_conflicts = db_repository
.current_merge_conflicts
.as_ref()
.map(|conflicts| serde_json::from_str(&conflicts))
.map(|conflicts| serde_json::from_str(conflicts))
.transpose()?
.unwrap_or_default();
let branch_summary = db_repository
.branch_summary
.as_ref()
.map(|branch_summary| serde_json::from_str(&branch_summary))
.map(|branch_summary| serde_json::from_str(branch_summary))
.transpose()?
.unwrap_or_default();
let head_commit_details = db_repository
.head_commit_details
.as_ref()
.map(|head_commit_details| serde_json::from_str(&head_commit_details))
.map(|head_commit_details| serde_json::from_str(head_commit_details))
.transpose()?
.unwrap_or_default();

View file

@ -245,7 +245,7 @@ impl MessageEditor {
if !candidates.is_empty() {
return cx.spawn(async move |_, cx| {
let completion_response = Self::completions_for_candidates(
&cx,
cx,
query.as_str(),
&candidates,
start_anchor..end_anchor,
@ -263,7 +263,7 @@ impl MessageEditor {
if !candidates.is_empty() {
return cx.spawn(async move |_, cx| {
let completion_response = Self::completions_for_candidates(
&cx,
cx,
query.as_str(),
candidates,
start_anchor..end_anchor,

View file

@ -2317,7 +2317,7 @@ impl CollabPanel {
let client = this.client.clone();
cx.spawn_in(window, async move |_, cx| {
client
.connect(true, &cx)
.connect(true, cx)
.await
.into_response()
.notify_async_err(cx);

View file

@ -643,7 +643,7 @@ impl Render for NotificationPanel {
let client = client.clone();
window
.spawn(cx, async move |cx| {
match client.connect(true, &cx).await {
match client.connect(true, cx).await {
util::ConnectionResult::Timeout => {
log::error!("Connection timeout");
}

View file

@ -315,12 +315,12 @@ impl McpServer {
Self::send_err(
request_id,
format!("Tool not found: {}", params.name),
&outgoing_tx,
outgoing_tx,
);
}
}
Err(err) => {
Self::send_err(request_id, err.to_string(), &outgoing_tx);
Self::send_err(request_id, err.to_string(), outgoing_tx);
}
}
}

View file

@ -691,7 +691,7 @@ impl CallToolResponse {
let mut text = String::new();
for chunk in &self.content {
if let ToolResponseContent::Text { text: chunk } = chunk {
text.push_str(&chunk)
text.push_str(chunk)
};
}
text

View file

@ -484,7 +484,7 @@ impl CopilotChat {
};
if this.oauth_token.is_some() {
cx.spawn(async move |this, mut cx| Self::update_models(&this, &mut cx).await)
cx.spawn(async move |this, cx| Self::update_models(&this, cx).await)
.detach_and_log_err(cx);
}
@ -863,7 +863,7 @@ mod tests {
"object": "list"
}"#;
let schema: ModelSchema = serde_json::from_str(&json).unwrap();
let schema: ModelSchema = serde_json::from_str(json).unwrap();
assert_eq!(schema.data.len(), 2);
assert_eq!(schema.data[0].id, "gpt-4");

View file

@ -285,7 +285,7 @@ pub async fn download_adapter_from_github(
}
if !adapter_path.exists() {
fs.create_dir(&adapter_path.as_path())
fs.create_dir(adapter_path.as_path())
.await
.context("Failed creating adapter path")?;
}

View file

@ -36,7 +36,7 @@ impl GoDebugAdapter {
delegate: &Arc<dyn DapDelegate>,
) -> Result<AdapterVersion> {
let release = latest_github_release(
&"zed-industries/delve-shim-dap",
"zed-industries/delve-shim-dap",
true,
false,
delegate.http_client(),

View file

@ -514,7 +514,7 @@ impl DebugAdapter for JsDebugAdapter {
}
}
self.get_installed_binary(delegate, &config, user_installed_path, user_args, cx)
self.get_installed_binary(delegate, config, user_installed_path, user_args, cx)
.await
}

View file

@ -717,7 +717,7 @@ impl DebugAdapter for PythonDebugAdapter {
local_path.display()
);
return self
.get_installed_binary(delegate, &config, Some(local_path.clone()), user_args, None)
.get_installed_binary(delegate, config, Some(local_path.clone()), user_args, None)
.await;
}
@ -754,7 +754,7 @@ impl DebugAdapter for PythonDebugAdapter {
return self
.get_installed_binary(
delegate,
&config,
config,
None,
user_args,
Some(toolchain.path.to_string()),
@ -762,7 +762,7 @@ impl DebugAdapter for PythonDebugAdapter {
.await;
}
self.get_installed_binary(delegate, &config, None, user_args, None)
self.get_installed_binary(delegate, config, None, user_args, None)
.await
}

View file

@ -238,7 +238,7 @@ mod tests {
.unwrap();
let _bad_db = open_db::<BadDB>(
tempdir.path(),
&release_channel::ReleaseChannel::Dev.dev_name(),
release_channel::ReleaseChannel::Dev.dev_name(),
)
.await;
}
@ -279,7 +279,7 @@ mod tests {
{
let corrupt_db = open_db::<CorruptedDB>(
tempdir.path(),
&release_channel::ReleaseChannel::Dev.dev_name(),
release_channel::ReleaseChannel::Dev.dev_name(),
)
.await;
assert!(corrupt_db.persistent());
@ -287,7 +287,7 @@ mod tests {
let good_db = open_db::<GoodDB>(
tempdir.path(),
&release_channel::ReleaseChannel::Dev.dev_name(),
release_channel::ReleaseChannel::Dev.dev_name(),
)
.await;
assert!(
@ -334,7 +334,7 @@ mod tests {
// Setup the bad database
let corrupt_db = open_db::<CorruptedDB>(
tempdir.path(),
&release_channel::ReleaseChannel::Dev.dev_name(),
release_channel::ReleaseChannel::Dev.dev_name(),
)
.await;
assert!(corrupt_db.persistent());
@ -347,7 +347,7 @@ mod tests {
let guard = thread::spawn(move || {
let good_db = smol::block_on(open_db::<GoodDB>(
tmp_path.as_path(),
&release_channel::ReleaseChannel::Dev.dev_name(),
release_channel::ReleaseChannel::Dev.dev_name(),
));
assert!(
good_db.select_row::<usize>("SELECT * FROM test2").unwrap()()

View file

@ -485,7 +485,7 @@ impl LogStore {
&mut self,
id: &LogStoreEntryIdentifier<'_>,
) -> Option<&Vec<SharedString>> {
self.get_debug_adapter_state(&id)
self.get_debug_adapter_state(id)
.map(|state| &state.rpc_messages.initialization_sequence)
}
}
@ -536,11 +536,11 @@ impl Render for DapLogToolbarItemView {
})
.unwrap_or_else(|| "No adapter selected".into()),
))
.menu(move |mut window, cx| {
.menu(move |window, cx| {
let log_view = log_view.clone();
let menu_rows = menu_rows.clone();
let project = project.clone();
ContextMenu::build(&mut window, cx, move |mut menu, window, _cx| {
ContextMenu::build(window, cx, move |mut menu, window, _cx| {
for row in menu_rows.into_iter() {
menu = menu.custom_row(move |_window, _cx| {
div()
@ -1131,7 +1131,7 @@ impl LogStore {
project: &WeakEntity<Project>,
session_id: SessionId,
) -> Vec<SharedString> {
self.projects.get(&project).map_or(vec![], |state| {
self.projects.get(project).map_or(vec![], |state| {
state
.debug_sessions
.get(&session_id)

View file

@ -693,7 +693,7 @@ impl DebugPanel {
)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| {
this.pause_thread(cx);
},
@ -719,7 +719,7 @@ impl DebugPanel {
)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| this.continue_thread(cx),
))
.disabled(thread_status != ThreadStatus::Stopped)
@ -742,7 +742,7 @@ impl DebugPanel {
IconButton::new("debug-step-over", IconName::ArrowRight)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| {
this.step_over(cx);
},
@ -768,7 +768,7 @@ impl DebugPanel {
)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| {
this.step_in(cx);
},
@ -791,7 +791,7 @@ impl DebugPanel {
IconButton::new("debug-step-out", IconName::ArrowUpRight)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| {
this.step_out(cx);
},
@ -815,7 +815,7 @@ impl DebugPanel {
IconButton::new("debug-restart", IconName::RotateCcw)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, window, cx| {
this.rerun_session(window, cx);
},
@ -837,7 +837,7 @@ impl DebugPanel {
IconButton::new("debug-stop", IconName::Power)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _window, cx| {
if this.session().read(cx).is_building() {
this.session().update(cx, |session, cx| {
@ -892,7 +892,7 @@ impl DebugPanel {
)
.icon_size(IconSize::Small)
.on_click(window.listener_for(
&running_state,
running_state,
|this, _, _, cx| {
this.detach_client(cx);
},
@ -1160,7 +1160,7 @@ impl DebugPanel {
workspace
.project()
.read(cx)
.project_path_for_absolute_path(&path, cx)
.project_path_for_absolute_path(path, cx)
.context(
"Couldn't get project path for .zed/debug.json in active worktree",
)

View file

@ -413,7 +413,7 @@ impl NewProcessModal {
let Some(adapter) = self.debugger.as_ref() else {
return;
};
let scenario = self.debug_scenario(&adapter, cx);
let scenario = self.debug_scenario(adapter, cx);
cx.spawn_in(window, async move |this, cx| {
let scenario = scenario.await.context("no scenario to save")?;
let worktree_id = task_contexts
@ -659,12 +659,7 @@ impl Render for NewProcessModal {
this.mode = NewProcessMode::Attach;
if let Some(debugger) = this.debugger.as_ref() {
Self::update_attach_picker(
&this.attach_mode,
&debugger,
window,
cx,
);
Self::update_attach_picker(&this.attach_mode, debugger, window, cx);
}
this.mode_focus_handle(cx).focus(window);
cx.notify();
@ -1083,7 +1078,7 @@ impl DebugDelegate {
.into_iter()
.map(|(scenario, context)| {
let (kind, scenario) =
Self::get_scenario_kind(&languages, &dap_registry, scenario);
Self::get_scenario_kind(&languages, dap_registry, scenario);
(kind, scenario, Some(context))
})
.chain(
@ -1100,7 +1095,7 @@ impl DebugDelegate {
.filter(|(_, scenario)| valid_adapters.contains(&scenario.adapter))
.map(|(kind, scenario)| {
let (language, scenario) =
Self::get_scenario_kind(&languages, &dap_registry, scenario);
Self::get_scenario_kind(&languages, dap_registry, scenario);
(language.or(Some(kind)), scenario, None)
}),
)

View file

@ -341,7 +341,7 @@ impl SerializedPaneLayout {
pub(crate) fn in_order(&self) -> Vec<SerializedPaneLayout> {
let mut panes = vec![];
Self::inner_in_order(&self, &mut panes);
Self::inner_in_order(self, &mut panes);
panes
}

View file

@ -102,7 +102,7 @@ impl Render for RunningState {
.find(|pane| pane.read(cx).is_zoomed());
let active = self.panes.panes().into_iter().next();
let pane = if let Some(ref zoomed_pane) = zoomed_pane {
let pane = if let Some(zoomed_pane) = zoomed_pane {
zoomed_pane.update(cx, |pane, cx| pane.render(window, cx).into_any_element())
} else if let Some(active) = active {
self.panes
@ -627,7 +627,7 @@ impl RunningState {
if s.starts_with("\"$ZED_") && s.ends_with('"') {
*s = s[1..s.len() - 1].to_string();
}
if let Some(substituted) = substitute_variables_in_str(&s, context) {
if let Some(substituted) = substitute_variables_in_str(s, context) {
*s = substituted;
}
}
@ -657,7 +657,7 @@ impl RunningState {
}
resolve_path(s);
if let Some(substituted) = substitute_variables_in_str(&s, context) {
if let Some(substituted) = substitute_variables_in_str(s, context) {
*s = substituted;
}
}
@ -954,7 +954,7 @@ impl RunningState {
inventory.read(cx).task_template_by_label(
buffer,
worktree_id,
&label,
label,
cx,
)
})
@ -1310,7 +1310,7 @@ impl RunningState {
let mut pane_item_status = IndexMap::from_iter(
DebuggerPaneItem::all()
.iter()
.filter(|kind| kind.is_supported(&caps))
.filter(|kind| kind.is_supported(caps))
.map(|kind| (*kind, false)),
);
self.panes.panes().iter().for_each(|pane| {
@ -1371,7 +1371,7 @@ impl RunningState {
this.serialize_layout(window, cx);
match event {
Event::Remove { .. } => {
let _did_find_pane = this.panes.remove(&source_pane).is_ok();
let _did_find_pane = this.panes.remove(source_pane).is_ok();
debug_assert!(_did_find_pane);
cx.notify();
}

View file

@ -494,7 +494,7 @@ impl BreakpointList {
fn toggle_data_breakpoint(&mut self, id: &str, cx: &mut Context<Self>) {
if let Some(session) = &self.session {
session.update(cx, |this, cx| {
this.toggle_data_breakpoint(&id, cx);
this.toggle_data_breakpoint(id, cx);
});
}
}
@ -502,7 +502,7 @@ impl BreakpointList {
fn toggle_exception_breakpoint(&mut self, id: &str, cx: &mut Context<Self>) {
if let Some(session) = &self.session {
session.update(cx, |this, cx| {
this.toggle_exception_breakpoint(&id, cx);
this.toggle_exception_breakpoint(id, cx);
});
cx.notify();
const EXCEPTION_SERIALIZATION_INTERVAL: Duration = Duration::from_secs(1);

View file

@ -697,7 +697,7 @@ impl ConsoleQueryBarCompletionProvider {
new_bytes: &[u8],
snapshot: &TextBufferSnapshot,
) -> Range<Anchor> {
let buffer_offset = buffer_position.to_offset(&snapshot);
let buffer_offset = buffer_position.to_offset(snapshot);
let buffer_bytes = &buffer_text.as_bytes()[0..buffer_offset];
let mut prefix_len = 0;
@ -977,7 +977,7 @@ mod tests {
&cx.buffer_text(),
snapshot.anchor_before(buffer_position),
replacement.as_bytes(),
&snapshot,
snapshot,
);
cx.update_editor(|editor, _, cx| {

View file

@ -262,7 +262,7 @@ impl MemoryView {
cx: &mut Context<Self>,
) {
use parse_int::parse;
let Ok(as_address) = parse::<u64>(&memory_reference) else {
let Ok(as_address) = parse::<u64>(memory_reference) else {
return;
};
let access_size = evaluate_name
@ -931,7 +931,7 @@ impl Render for MemoryView {
v_flex()
.size_full()
.on_drag_move(cx.listener(|this, evt, _, _| {
this.handle_memory_drag(&evt);
this.handle_memory_drag(evt);
}))
.child(self.render_memory(cx).size_full())
.children(self.open_context_menu.as_ref().map(|(menu, position, _)| {

View file

@ -1289,7 +1289,7 @@ impl VariableList {
}),
)
.child(self.render_variable_value(
&entry,
entry,
&variable_color,
watcher.value.to_string(),
cx,
@ -1494,7 +1494,7 @@ impl VariableList {
}),
)
.child(self.render_variable_value(
&variable,
variable,
&variable_color,
dap.value.clone(),
cx,

View file

@ -139,7 +139,7 @@ async fn test_show_attach_modal_and_select_process(
workspace
.update(cx, |_, window, cx| {
let names =
attach_modal.update(cx, |modal, cx| attach_modal::_process_names(&modal, cx));
attach_modal.update(cx, |modal, cx| attach_modal::_process_names(modal, cx));
// Initially all processes are visible.
assert_eq!(3, names.len());
attach_modal.update(cx, |this, cx| {
@ -154,7 +154,7 @@ async fn test_show_attach_modal_and_select_process(
workspace
.update(cx, |_, _, cx| {
let names =
attach_modal.update(cx, |modal, cx| attach_modal::_process_names(&modal, cx));
attach_modal.update(cx, |modal, cx| attach_modal::_process_names(modal, cx));
// Initially all processes are visible.
assert_eq!(2, names.len());
})

View file

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

View file

@ -46,7 +46,7 @@ impl DiagnosticRenderer {
markdown.push_str(" (");
}
if let Some(source) = diagnostic.source.as_ref() {
markdown.push_str(&Markdown::escape(&source));
markdown.push_str(&Markdown::escape(source));
}
if diagnostic.source.is_some() && diagnostic.code.is_some() {
markdown.push(' ');
@ -306,7 +306,7 @@ impl DiagnosticBlock {
cx: &mut Context<Editor>,
) {
let snapshot = &editor.buffer().read(cx).snapshot(cx);
let range = range.start.to_offset(&snapshot)..range.end.to_offset(&snapshot);
let range = range.start.to_offset(snapshot)..range.end.to_offset(snapshot);
editor.unfold_ranges(&[range.start..range.end], true, false, cx);
editor.change_selections(Default::default(), window, cx, |s| {

View file

@ -528,7 +528,7 @@ impl ProjectDiagnosticsEditor {
lsp::DiagnosticSeverity::ERROR
};
cx.spawn_in(window, async move |this, mut cx| {
cx.spawn_in(window, async move |this, cx| {
let diagnostics = buffer_snapshot
.diagnostics_in_range::<_, text::Anchor>(
Point::zero()..buffer_snapshot.max_point(),
@ -595,7 +595,7 @@ impl ProjectDiagnosticsEditor {
b.initial_range.clone(),
DEFAULT_MULTIBUFFER_CONTEXT,
buffer_snapshot.clone(),
&mut cx,
cx,
)
.await;
let i = excerpt_ranges

View file

@ -129,7 +129,7 @@ fn handle_frontmatter(book: &mut Book, errors: &mut HashSet<PreprocessorError>)
let Some((name, value)) = line.split_once(':') else {
errors.insert(PreprocessorError::InvalidFrontmatterLine(format!(
"{}: {}",
chapter_breadcrumbs(&chapter),
chapter_breadcrumbs(chapter),
line
)));
continue;
@ -402,11 +402,11 @@ fn handle_postprocessing() -> Result<()> {
path: &'a std::path::PathBuf,
root: &'a std::path::PathBuf,
) -> &'a std::path::Path {
&path.strip_prefix(&root).unwrap_or(&path)
path.strip_prefix(&root).unwrap_or(path)
}
fn extract_title_from_page(contents: &str, pretty_path: &std::path::Path) -> String {
let title_tag_contents = &title_regex()
.captures(&contents)
.captures(contents)
.with_context(|| format!("Failed to find title in {:?}", pretty_path))
.expect("Page has <title> element")[1];
let title = title_tag_contents

View file

@ -104,6 +104,6 @@ pub fn apply_related_actions(editor: &Entity<Editor>, window: &mut Window, cx: &
.filter_map(|buffer| buffer.read(cx).language())
.any(|language| is_c_language(language))
{
register_action(&editor, window, switch_source_header);
register_action(editor, window, switch_source_header);
}
}

View file

@ -317,7 +317,7 @@ async fn filter_and_sort_matches(
let candidates: Arc<[StringMatchCandidate]> = completions
.iter()
.enumerate()
.map(|(id, completion)| StringMatchCandidate::new(id, &completion.label.filter_text()))
.map(|(id, completion)| StringMatchCandidate::new(id, completion.label.filter_text()))
.collect();
let cancel_flag = Arc::new(AtomicBool::new(false));
let background_executor = cx.executor();
@ -331,5 +331,5 @@ async fn filter_and_sort_matches(
background_executor,
)
.await;
CompletionsMenu::sort_string_matches(matches, Some(query), snippet_sort_order, &completions)
CompletionsMenu::sort_string_matches(matches, Some(query), snippet_sort_order, completions)
}

View file

@ -321,7 +321,7 @@ impl CompletionsMenu {
let match_candidates = choices
.iter()
.enumerate()
.map(|(id, completion)| StringMatchCandidate::new(id, &completion))
.map(|(id, completion)| StringMatchCandidate::new(id, completion))
.collect();
let entries = choices
.iter()

View file

@ -77,7 +77,7 @@ fn create_highlight_endpoints(
let ranges = &text_highlights.1;
let start_ix = match ranges.binary_search_by(|probe| {
let cmp = probe.end.cmp(&start, &buffer);
let cmp = probe.end.cmp(&start, buffer);
if cmp.is_gt() {
cmp::Ordering::Greater
} else {
@ -88,18 +88,18 @@ fn create_highlight_endpoints(
};
for range in &ranges[start_ix..] {
if range.start.cmp(&end, &buffer).is_ge() {
if range.start.cmp(&end, buffer).is_ge() {
break;
}
highlight_endpoints.push(HighlightEndpoint {
offset: range.start.to_offset(&buffer),
offset: range.start.to_offset(buffer),
is_start: true,
tag,
style,
});
highlight_endpoints.push(HighlightEndpoint {
offset: range.end.to_offset(&buffer),
offset: range.end.to_offset(buffer),
is_start: false,
tag,
style,

View file

@ -36,8 +36,8 @@ pub fn is_invisible(c: char) -> bool {
} else if c >= '\u{7f}' {
c <= '\u{9f}'
|| (c.is_whitespace() && c != IDEOGRAPHIC_SPACE)
|| contains(c, &FORMAT)
|| contains(c, &OTHER)
|| contains(c, FORMAT)
|| contains(c, OTHER)
} else {
false
}
@ -50,7 +50,7 @@ pub fn replacement(c: char) -> Option<&'static str> {
Some(C0_SYMBOLS[c as usize])
} else if c == '\x7f' {
Some(DEL)
} else if contains(c, &PRESERVE) {
} else if contains(c, PRESERVE) {
None
} else {
Some("\u{2007}") // fixed width space

View file

@ -1461,7 +1461,7 @@ mod tests {
}
let mut prev_ix = 0;
for boundary in line_wrapper.wrap_line(&[LineFragment::text(&line)], wrap_width) {
for boundary in line_wrapper.wrap_line(&[LineFragment::text(line)], wrap_width) {
wrapped_text.push_str(&line[prev_ix..boundary.ix]);
wrapped_text.push('\n');
wrapped_text.push_str(&" ".repeat(boundary.next_indent as usize));

View file

@ -2379,7 +2379,7 @@ impl Editor {
pending_selection
.selection
.range()
.includes(&range, &snapshot)
.includes(range, &snapshot)
})
{
return true;
@ -3342,9 +3342,9 @@ impl Editor {
let old_cursor_position = &state.old_cursor_position;
self.selections_did_change(true, &old_cursor_position, state.effects, window, cx);
self.selections_did_change(true, old_cursor_position, state.effects, window, cx);
if self.should_open_signature_help_automatically(&old_cursor_position, cx) {
if self.should_open_signature_help_automatically(old_cursor_position, cx) {
self.show_signature_help(&ShowSignatureHelp, window, cx);
}
}
@ -3764,9 +3764,9 @@ impl Editor {
ColumnarSelectionState::FromMouse {
selection_tail,
display_point,
} => display_point.unwrap_or_else(|| selection_tail.to_display_point(&display_map)),
} => display_point.unwrap_or_else(|| selection_tail.to_display_point(display_map)),
ColumnarSelectionState::FromSelection { selection_tail } => {
selection_tail.to_display_point(&display_map)
selection_tail.to_display_point(display_map)
}
};
@ -6082,7 +6082,7 @@ impl Editor {
if let Some(tasks) = &tasks {
if let Some(project) = project {
task_context_task =
Self::build_tasks_context(&project, &buffer, buffer_row, &tasks, cx);
Self::build_tasks_context(&project, &buffer, buffer_row, tasks, cx);
}
}
@ -6864,7 +6864,7 @@ impl Editor {
for (buffer_snapshot, search_range, excerpt_id) in buffer_ranges {
match_ranges.extend(
regex
.search(&buffer_snapshot, Some(search_range.clone()))
.search(buffer_snapshot, Some(search_range.clone()))
.await
.into_iter()
.filter_map(|match_range| {
@ -7206,7 +7206,7 @@ impl Editor {
return Some(false);
}
let provider = self.edit_prediction_provider()?;
if !provider.is_enabled(&buffer, buffer_position, cx) {
if !provider.is_enabled(buffer, buffer_position, cx) {
return Some(false);
}
let buffer = buffer.read(cx);
@ -7966,7 +7966,7 @@ impl Editor {
let multi_buffer_anchor =
Anchor::in_buffer(excerpt_id, buffer_snapshot.remote_id(), breakpoint.position);
let position = multi_buffer_anchor
.to_point(&multi_buffer_snapshot)
.to_point(multi_buffer_snapshot)
.to_display_point(&snapshot);
breakpoint_display_points.insert(
@ -8859,7 +8859,7 @@ impl Editor {
}
let highlighted_edits = if let Some(edit_preview) = edit_preview.as_ref() {
crate::edit_prediction_edit_text(&snapshot, edits, edit_preview, false, cx)
crate::edit_prediction_edit_text(snapshot, edits, edit_preview, false, cx)
} else {
// Fallback for providers without edit_preview
crate::edit_prediction_fallback_text(edits, cx)
@ -9222,7 +9222,7 @@ impl Editor {
.child(div().px_1p5().child(match &prediction.completion {
EditPrediction::Move { target, snapshot } => {
use text::ToPoint as _;
if target.text_anchor.to_point(&snapshot).row > cursor_point.row
if target.text_anchor.to_point(snapshot).row > cursor_point.row
{
Icon::new(IconName::ZedPredictDown)
} else {
@ -9424,7 +9424,7 @@ impl Editor {
.gap_2()
.flex_1()
.child(
if target.text_anchor.to_point(&snapshot).row > cursor_point.row {
if target.text_anchor.to_point(snapshot).row > cursor_point.row {
Icon::new(IconName::ZedPredictDown)
} else {
Icon::new(IconName::ZedPredictUp)
@ -9440,14 +9440,14 @@ impl Editor {
snapshot,
display_mode: _,
} => {
let first_edit_row = edits.first()?.0.start.text_anchor.to_point(&snapshot).row;
let first_edit_row = edits.first()?.0.start.text_anchor.to_point(snapshot).row;
let (highlighted_edits, has_more_lines) =
if let Some(edit_preview) = edit_preview.as_ref() {
crate::edit_prediction_edit_text(&snapshot, &edits, edit_preview, true, cx)
crate::edit_prediction_edit_text(snapshot, edits, edit_preview, true, cx)
.first_line_preview()
} else {
crate::edit_prediction_fallback_text(&edits, cx).first_line_preview()
crate::edit_prediction_fallback_text(edits, cx).first_line_preview()
};
let styled_text = gpui::StyledText::new(highlighted_edits.text)
@ -9770,7 +9770,7 @@ impl Editor {
if let Some(choices) = &snippet.choices[snippet.active_index] {
if let Some(selection) = current_ranges.first() {
self.show_snippet_choices(&choices, selection.clone(), cx);
self.show_snippet_choices(choices, selection.clone(), cx);
}
}
@ -12284,7 +12284,7 @@ impl Editor {
let trigger_in_words =
this.show_edit_predictions_in_menu() || !had_active_edit_prediction;
this.trigger_completion_on_input(&text, trigger_in_words, window, cx);
this.trigger_completion_on_input(text, trigger_in_words, window, cx);
});
}
@ -17896,7 +17896,7 @@ impl Editor {
ranges: &[Range<Anchor>],
snapshot: &MultiBufferSnapshot,
) -> bool {
let mut hunks = self.diff_hunks_in_ranges(ranges, &snapshot);
let mut hunks = self.diff_hunks_in_ranges(ranges, snapshot);
hunks.any(|hunk| hunk.status().has_secondary_hunk())
}
@ -19042,8 +19042,8 @@ impl Editor {
buffer_ranges.last()
}?;
let selection = text::ToPoint::to_point(&range.start, &buffer).row
..text::ToPoint::to_point(&range.end, &buffer).row;
let selection = text::ToPoint::to_point(&range.start, buffer).row
..text::ToPoint::to_point(&range.end, buffer).row;
Some((
multi_buffer.buffer(buffer.remote_id()).unwrap().clone(),
selection,
@ -20055,8 +20055,7 @@ impl Editor {
self.registered_buffers
.entry(edited_buffer.read(cx).remote_id())
.or_insert_with(|| {
project
.register_buffer_with_language_servers(&edited_buffer, cx)
project.register_buffer_with_language_servers(edited_buffer, cx)
});
});
}
@ -21079,7 +21078,7 @@ impl Editor {
};
if let Some((workspace, path)) = workspace.as_ref().zip(path) {
let Some(task) = cx
.update_window_entity(&workspace, |workspace, window, cx| {
.update_window_entity(workspace, |workspace, window, cx| {
workspace
.open_path_preview(path, None, false, false, false, window, cx)
})
@ -21303,14 +21302,14 @@ fn process_completion_for_edit(
debug_assert!(
insert_range
.start
.cmp(&cursor_position, &buffer_snapshot)
.cmp(cursor_position, &buffer_snapshot)
.is_le(),
"insert_range should start before or at cursor position"
);
debug_assert!(
replace_range
.start
.cmp(&cursor_position, &buffer_snapshot)
.cmp(cursor_position, &buffer_snapshot)
.is_le(),
"replace_range should start before or at cursor position"
);
@ -21344,7 +21343,7 @@ fn process_completion_for_edit(
LspInsertMode::ReplaceSuffix => {
if replace_range
.end
.cmp(&cursor_position, &buffer_snapshot)
.cmp(cursor_position, &buffer_snapshot)
.is_gt()
{
let range_after_cursor = *cursor_position..replace_range.end;
@ -21380,7 +21379,7 @@ fn process_completion_for_edit(
if range_to_replace
.end
.cmp(&cursor_position, &buffer_snapshot)
.cmp(cursor_position, &buffer_snapshot)
.is_lt()
{
range_to_replace.end = *cursor_position;
@ -21388,7 +21387,7 @@ fn process_completion_for_edit(
CompletionEdit {
new_text,
replace_range: range_to_replace.to_offset(&buffer),
replace_range: range_to_replace.to_offset(buffer),
snippet,
}
}
@ -22137,7 +22136,7 @@ fn snippet_completions(
snippet
.prefix
.iter()
.map(move |prefix| StringMatchCandidate::new(ix, &prefix))
.map(move |prefix| StringMatchCandidate::new(ix, prefix))
})
.collect::<Vec<StringMatchCandidate>>();
@ -22366,10 +22365,10 @@ impl SemanticsProvider for Entity<Project> {
cx: &mut App,
) -> Option<Task<Result<Vec<LocationLink>>>> {
Some(self.update(cx, |project, cx| match kind {
GotoDefinitionKind::Symbol => project.definitions(&buffer, position, cx),
GotoDefinitionKind::Declaration => project.declarations(&buffer, position, cx),
GotoDefinitionKind::Type => project.type_definitions(&buffer, position, cx),
GotoDefinitionKind::Implementation => project.implementations(&buffer, position, cx),
GotoDefinitionKind::Symbol => project.definitions(buffer, position, cx),
GotoDefinitionKind::Declaration => project.declarations(buffer, position, cx),
GotoDefinitionKind::Type => project.type_definitions(buffer, position, cx),
GotoDefinitionKind::Implementation => project.implementations(buffer, position, cx),
}))
}
@ -23778,7 +23777,7 @@ fn all_edits_insertions_or_deletions(
let mut all_deletions = true;
for (range, new_text) in edits.iter() {
let range_is_empty = range.to_offset(&snapshot).is_empty();
let range_is_empty = range.to_offset(snapshot).is_empty();
let text_is_empty = new_text.is_empty();
if range_is_empty != text_is_empty {

View file

@ -8393,7 +8393,7 @@ async fn test_autoindent_disabled_with_nested_language(cx: &mut TestAppContext)
buffer.set_language(Some(language), cx);
});
cx.set_state(&r#"struct A {ˇ}"#);
cx.set_state(r#"struct A {ˇ}"#);
cx.update_editor(|editor, window, cx| {
editor.newline(&Default::default(), window, cx);
@ -8405,7 +8405,7 @@ async fn test_autoindent_disabled_with_nested_language(cx: &mut TestAppContext)
}"
));
cx.set_state(&r#"select_biased!(ˇ)"#);
cx.set_state(r#"select_biased!(ˇ)"#);
cx.update_editor(|editor, window, cx| {
editor.newline(&Default::default(), window, cx);
@ -12319,7 +12319,7 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
let counter = Arc::new(AtomicUsize::new(0));
handle_completion_request_with_insert_and_replace(
&mut cx,
&buffer_marked_text,
buffer_marked_text,
vec![(completion_text, completion_text)],
counter.clone(),
)
@ -12333,7 +12333,7 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
.confirm_completion_replace(&ConfirmCompletionReplace, window, cx)
.unwrap()
});
cx.assert_editor_state(&expected_with_replace_mode);
cx.assert_editor_state(expected_with_replace_mode);
handle_resolve_completion_request(&mut cx, None).await;
apply_additional_edits.await.unwrap();
@ -12353,7 +12353,7 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
});
handle_completion_request_with_insert_and_replace(
&mut cx,
&buffer_marked_text,
buffer_marked_text,
vec![(completion_text, completion_text)],
counter.clone(),
)
@ -12367,7 +12367,7 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
.confirm_completion_insert(&ConfirmCompletionInsert, window, cx)
.unwrap()
});
cx.assert_editor_state(&expected_with_insert_mode);
cx.assert_editor_state(expected_with_insert_mode);
handle_resolve_completion_request(&mut cx, None).await;
apply_additional_edits.await.unwrap();
}
@ -13141,7 +13141,7 @@ async fn test_word_completion(cx: &mut TestAppContext) {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["first", "last"],
"When LSP server is fast to reply, no fallback word completions are used"
);
@ -13164,7 +13164,7 @@ async fn test_word_completion(cx: &mut TestAppContext) {
cx.update_editor(|editor, _, _| {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(completion_menu_entries(&menu), &["one", "three", "two"],
assert_eq!(completion_menu_entries(menu), &["one", "three", "two"],
"When LSP server is slow, document words can be shown instead, if configured accordingly");
} else {
panic!("expected completion menu to be open");
@ -13225,7 +13225,7 @@ async fn test_word_completions_do_not_duplicate_lsp_ones(cx: &mut TestAppContext
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["first", "last", "second"],
"Word completions that has the same edit as the any of the LSP ones, should not be proposed"
);
@ -13281,7 +13281,7 @@ async fn test_word_completions_continue_on_typing(cx: &mut TestAppContext) {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["first", "last", "second"],
"`ShowWordCompletions` action should show word completions"
);
@ -13298,7 +13298,7 @@ async fn test_word_completions_continue_on_typing(cx: &mut TestAppContext) {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["last"],
"After showing word completions, further editing should filter them and not query the LSP"
);
@ -13337,7 +13337,7 @@ async fn test_word_completions_usually_skip_digits(cx: &mut TestAppContext) {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["let"],
"With no digits in the completion query, no digits should be in the word completions"
);
@ -13362,7 +13362,7 @@ async fn test_word_completions_usually_skip_digits(cx: &mut TestAppContext) {
cx.update_editor(|editor, _, _| {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(completion_menu_entries(&menu), &["33", "35f32"], "The digit is in the completion query, \
assert_eq!(completion_menu_entries(menu), &["33", "35f32"], "The digit is in the completion query, \
return matching words with digits (`33`, `35f32`) but exclude query duplicates (`3`)");
} else {
panic!("expected completion menu to be open");
@ -13599,7 +13599,7 @@ async fn test_completion_page_up_down_keys(cx: &mut TestAppContext) {
cx.update_editor(|editor, _, _| {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(completion_menu_entries(&menu), &["first", "last"]);
assert_eq!(completion_menu_entries(menu), &["first", "last"]);
} else {
panic!("expected completion menu to be open");
}
@ -16702,7 +16702,7 @@ async fn test_completions_in_languages_with_extra_word_characters(cx: &mut TestA
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(
completion_menu_entries(&menu),
completion_menu_entries(menu),
&["bg-blue", "bg-red", "bg-yellow"]
);
} else {
@ -16715,7 +16715,7 @@ async fn test_completions_in_languages_with_extra_word_characters(cx: &mut TestA
cx.update_editor(|editor, _, _| {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(completion_menu_entries(&menu), &["bg-blue", "bg-yellow"]);
assert_eq!(completion_menu_entries(menu), &["bg-blue", "bg-yellow"]);
} else {
panic!("expected completion menu to be open");
}
@ -16729,7 +16729,7 @@ async fn test_completions_in_languages_with_extra_word_characters(cx: &mut TestA
cx.update_editor(|editor, _, _| {
if let Some(CodeContextMenu::Completions(menu)) = editor.context_menu.borrow_mut().as_ref()
{
assert_eq!(completion_menu_entries(&menu), &["bg-yellow"]);
assert_eq!(completion_menu_entries(menu), &["bg-yellow"]);
} else {
panic!("expected completion menu to be open");
}
@ -17298,7 +17298,7 @@ async fn test_multibuffer_reverts(cx: &mut TestAppContext) {
(buffer_2.clone(), base_text_2),
(buffer_3.clone(), base_text_3),
] {
let diff = cx.new(|cx| BufferDiff::new_with_base_text(&diff_base, &buffer, cx));
let diff = cx.new(|cx| BufferDiff::new_with_base_text(diff_base, &buffer, cx));
editor
.buffer
.update(cx, |buffer, cx| buffer.add_diff(diff, cx));
@ -17919,7 +17919,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut TestAppContext) {
(buffer_2.clone(), file_2_old),
(buffer_3.clone(), file_3_old),
] {
let diff = cx.new(|cx| BufferDiff::new_with_base_text(&diff_base, &buffer, cx));
let diff = cx.new(|cx| BufferDiff::new_with_base_text(diff_base, &buffer, cx));
editor
.buffer
.update(cx, |buffer, cx| buffer.add_diff(diff, cx));
@ -21024,7 +21024,7 @@ async fn assert_highlighted_edits(
cx.update(|_window, cx| {
let highlighted_edits = edit_prediction_edit_text(
&snapshot.as_singleton().unwrap().2,
snapshot.as_singleton().unwrap().2,
&edits,
&edit_preview,
include_deletions,
@ -21091,7 +21091,7 @@ fn add_log_breakpoint_at_cursor(
.buffer_snapshot
.anchor_before(Point::new(cursor_position.row, 0));
(breakpoint_position, Breakpoint::new_log(&log_message))
(breakpoint_position, Breakpoint::new_log(log_message))
});
editor.edit_breakpoint_at_anchor(

View file

@ -1162,7 +1162,7 @@ impl EditorElement {
.map_or(false, |state| state.keyboard_grace);
if mouse_over_inline_blame || mouse_over_popover {
editor.show_blame_popover(&blame_entry, event.position, false, cx);
editor.show_blame_popover(blame_entry, event.position, false, cx);
} else if !keyboard_grace {
editor.hide_blame_popover(cx);
}
@ -2818,7 +2818,7 @@ impl EditorElement {
}
let row =
MultiBufferRow(DisplayPoint::new(display_row, 0).to_point(&snapshot).row);
MultiBufferRow(DisplayPoint::new(display_row, 0).to_point(snapshot).row);
if snapshot.is_line_folded(row) {
return None;
}
@ -3312,7 +3312,7 @@ impl EditorElement {
let chunks = snapshot.highlighted_chunks(rows.clone(), true, style);
LineWithInvisibles::from_chunks(
chunks,
&style,
style,
MAX_LINE_LEN,
rows.len(),
&snapshot.mode,
@ -3393,7 +3393,7 @@ impl EditorElement {
let line_ix = align_to.row().0.checked_sub(rows.start.0);
x_position =
if let Some(layout) = line_ix.and_then(|ix| line_layouts.get(ix as usize)) {
x_and_width(&layout)
x_and_width(layout)
} else {
x_and_width(&layout_line(
align_to.row(),
@ -5549,9 +5549,9 @@ impl EditorElement {
// In singleton buffers, we select corresponding lines on the line number click, so use | -like cursor.
// In multi buffers, we open file at the line number clicked, so use a pointing hand cursor.
if is_singleton {
window.set_cursor_style(CursorStyle::IBeam, &hitbox);
window.set_cursor_style(CursorStyle::IBeam, hitbox);
} else {
window.set_cursor_style(CursorStyle::PointingHand, &hitbox);
window.set_cursor_style(CursorStyle::PointingHand, hitbox);
}
}
}
@ -5570,7 +5570,7 @@ impl EditorElement {
&layout.position_map.snapshot,
line_height,
layout.gutter_hitbox.bounds,
&hunk,
hunk,
);
Some((
hunk_bounds,
@ -6092,10 +6092,10 @@ impl EditorElement {
if axis == ScrollbarAxis::Vertical {
let fast_markers =
self.collect_fast_scrollbar_markers(layout, &scrollbar_layout, cx);
self.collect_fast_scrollbar_markers(layout, scrollbar_layout, cx);
// Refresh slow scrollbar markers in the background. Below, we
// paint whatever markers have already been computed.
self.refresh_slow_scrollbar_markers(layout, &scrollbar_layout, window, cx);
self.refresh_slow_scrollbar_markers(layout, scrollbar_layout, window, cx);
let markers = self.editor.read(cx).scrollbar_marker_state.markers.clone();
for marker in markers.iter().chain(&fast_markers) {
@ -6129,7 +6129,7 @@ impl EditorElement {
if any_scrollbar_dragged {
window.set_window_cursor_style(CursorStyle::Arrow);
} else {
window.set_cursor_style(CursorStyle::Arrow, &hitbox);
window.set_cursor_style(CursorStyle::Arrow, hitbox);
}
}
})
@ -9782,7 +9782,7 @@ pub fn layout_line(
let chunks = snapshot.highlighted_chunks(row..row + DisplayRow(1), true, style);
LineWithInvisibles::from_chunks(
chunks,
&style,
style,
MAX_LINE_LEN,
1,
&snapshot.mode,

View file

@ -794,7 +794,7 @@ pub(crate) async fn find_file(
) -> Option<ResolvedPath> {
project
.update(cx, |project, cx| {
project.resolve_path_in_buffer(&candidate_file_path, buffer, cx)
project.resolve_path_in_buffer(candidate_file_path, buffer, cx)
})
.ok()?
.await

View file

@ -524,8 +524,8 @@ fn serialize_selection(
) -> proto::Selection {
proto::Selection {
id: selection.id as u64,
start: Some(serialize_anchor(&selection.start, &buffer)),
end: Some(serialize_anchor(&selection.end, &buffer)),
start: Some(serialize_anchor(&selection.start, buffer)),
end: Some(serialize_anchor(&selection.end, buffer)),
reversed: selection.reversed,
}
}
@ -1010,7 +1010,7 @@ impl Item for Editor {
self.workspace = Some((workspace.weak_handle(), workspace.database_id()));
if let Some(workspace) = &workspace.weak_handle().upgrade() {
cx.subscribe(
&workspace,
workspace,
|editor, _, event: &workspace::Event, _cx| match event {
workspace::Event::ModalOpened => {
editor.mouse_context_menu.take();
@ -1296,7 +1296,7 @@ impl SerializableItem for Editor {
project
.read(cx)
.worktree_for_id(worktree_id, cx)
.and_then(|worktree| worktree.read(cx).absolutize(&file.path()).ok())
.and_then(|worktree| worktree.read(cx).absolutize(file.path()).ok())
.or_else(|| {
let full_path = file.full_path(cx);
let project_path = project.read(cx).find_project_path(&full_path, cx)?;
@ -1385,14 +1385,14 @@ impl ProjectItem for Editor {
})
{
editor.fold_ranges(
clip_ranges(&restoration_data.folds, &snapshot),
clip_ranges(&restoration_data.folds, snapshot),
false,
window,
cx,
);
if !restoration_data.selections.is_empty() {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges(clip_ranges(&restoration_data.selections, &snapshot));
s.select_ranges(clip_ranges(&restoration_data.selections, snapshot));
});
}
let (top_row, offset) = restoration_data.scroll_position;

View file

@ -37,7 +37,7 @@ pub(crate) fn should_auto_close(
let text = buffer
.text_for_range(edited_range.clone())
.collect::<String>();
let edited_range = edited_range.to_offset(&buffer);
let edited_range = edited_range.to_offset(buffer);
if !text.ends_with(">") {
continue;
}

View file

@ -207,7 +207,7 @@ impl Editor {
.entry(buffer_snapshot.remote_id())
.or_insert_with(Vec::new);
let excerpt_point_range =
excerpt_range.context.to_point_utf16(&buffer_snapshot);
excerpt_range.context.to_point_utf16(buffer_snapshot);
excerpt_data.push((
excerpt_id,
buffer_snapshot.clone(),

View file

@ -76,7 +76,7 @@ async fn lsp_task_context(
let project_env = project
.update(cx, |project, cx| {
project.buffer_environment(&buffer, &worktree_store, cx)
project.buffer_environment(buffer, &worktree_store, cx)
})
.ok()?
.await;

View file

@ -102,11 +102,11 @@ impl MouseContextMenu {
let display_snapshot = &editor
.display_map
.update(cx, |display_map, cx| display_map.snapshot(cx));
let selection_init_range = selection_init.display_range(&display_snapshot);
let selection_init_range = selection_init.display_range(display_snapshot);
let selection_now_range = editor
.selections
.newest_anchor()
.display_range(&display_snapshot);
.display_range(display_snapshot);
if selection_now_range == selection_init_range {
return;
}

View file

@ -439,17 +439,17 @@ pub fn start_of_excerpt(
};
match direction {
Direction::Prev => {
let mut start = excerpt.start_anchor().to_display_point(&map);
let mut start = excerpt.start_anchor().to_display_point(map);
if start >= display_point && start.row() > DisplayRow(0) {
let Some(excerpt) = map.buffer_snapshot.excerpt_before(excerpt.id()) else {
return display_point;
};
start = excerpt.start_anchor().to_display_point(&map);
start = excerpt.start_anchor().to_display_point(map);
}
start
}
Direction::Next => {
let mut end = excerpt.end_anchor().to_display_point(&map);
let mut end = excerpt.end_anchor().to_display_point(map);
*end.row_mut() += 1;
map.clip_point(end, Bias::Right)
}
@ -467,7 +467,7 @@ pub fn end_of_excerpt(
};
match direction {
Direction::Prev => {
let mut start = excerpt.start_anchor().to_display_point(&map);
let mut start = excerpt.start_anchor().to_display_point(map);
if start.row() > DisplayRow(0) {
*start.row_mut() -= 1;
}
@ -476,7 +476,7 @@ pub fn end_of_excerpt(
start
}
Direction::Next => {
let mut end = excerpt.end_anchor().to_display_point(&map);
let mut end = excerpt.end_anchor().to_display_point(map);
*end.column_mut() = 0;
if end <= display_point {
*end.row_mut() += 1;
@ -485,7 +485,7 @@ pub fn end_of_excerpt(
else {
return display_point;
};
end = excerpt.end_anchor().to_display_point(&map);
end = excerpt.end_anchor().to_display_point(map);
*end.column_mut() = 0;
}
end

View file

@ -478,7 +478,7 @@ impl SemanticsProvider for BranchBufferSemanticsProvider {
}
fn supports_inlay_hints(&self, buffer: &Entity<Buffer>, cx: &mut App) -> bool {
if let Some(buffer) = self.to_base(&buffer, &[], cx) {
if let Some(buffer) = self.to_base(buffer, &[], cx) {
self.0.supports_inlay_hints(&buffer, cx)
} else {
false
@ -491,7 +491,7 @@ impl SemanticsProvider for BranchBufferSemanticsProvider {
position: text::Anchor,
cx: &mut App,
) -> Option<Task<anyhow::Result<Vec<project::DocumentHighlight>>>> {
let buffer = self.to_base(&buffer, &[position], cx)?;
let buffer = self.to_base(buffer, &[position], cx)?;
self.0.document_highlights(&buffer, position, cx)
}
@ -502,7 +502,7 @@ impl SemanticsProvider for BranchBufferSemanticsProvider {
kind: crate::GotoDefinitionKind,
cx: &mut App,
) -> Option<Task<anyhow::Result<Vec<project::LocationLink>>>> {
let buffer = self.to_base(&buffer, &[position], cx)?;
let buffer = self.to_base(buffer, &[position], cx)?;
self.0.definitions(&buffer, position, kind, cx)
}

View file

@ -35,12 +35,12 @@ pub fn apply_related_actions(editor: &Entity<Editor>, window: &mut Window, cx: &
.filter_map(|buffer| buffer.read(cx).language())
.any(|language| is_rust_language(language))
{
register_action(&editor, window, go_to_parent_module);
register_action(&editor, window, expand_macro_recursively);
register_action(&editor, window, open_docs);
register_action(&editor, window, cancel_flycheck_action);
register_action(&editor, window, run_flycheck_action);
register_action(&editor, window, clear_flycheck_action);
register_action(editor, window, go_to_parent_module);
register_action(editor, window, expand_macro_recursively);
register_action(editor, window, open_docs);
register_action(editor, window, cancel_flycheck_action);
register_action(editor, window, run_flycheck_action);
register_action(editor, window, clear_flycheck_action);
}
}

View file

@ -196,7 +196,7 @@ impl Editor {
.highlight_text(&text, 0..signature.label.len())
.into_iter()
.flat_map(|(range, highlight_id)| {
Some((range, highlight_id.style(&cx.theme().syntax())?))
Some((range, highlight_id.style(cx.theme().syntax())?))
});
signature.highlights =
combine_highlights(signature.highlights.clone(), highlights)

View file

@ -189,7 +189,7 @@ pub fn editor_content_with_blocks(editor: &Entity<Editor>, cx: &mut VisualTestCo
continue;
}
};
let content = block_content_for_tests(&editor, custom_block.id, cx)
let content = block_content_for_tests(editor, custom_block.id, cx)
.expect("block content not found");
// 2: "related info 1 for diagnostic 0"
if let Some(height) = custom_block.height {

View file

@ -520,7 +520,7 @@ async fn judge_example(
enable_telemetry: bool,
cx: &AsyncApp,
) -> JudgeOutput {
let judge_output = example.judge(model.clone(), &run_output, cx).await;
let judge_output = example.judge(model.clone(), run_output, cx).await;
if enable_telemetry {
telemetry::event!(

View file

@ -64,7 +64,7 @@ impl ExampleMetadata {
self.url
.split('/')
.next_back()
.unwrap_or(&"")
.unwrap_or("")
.trim_end_matches(".git")
.into()
}
@ -255,7 +255,7 @@ impl ExampleContext {
thread.update(cx, |thread, _cx| {
if let Some(tool_use) = pending_tool_use {
let mut tool_metrics = tool_metrics.lock().unwrap();
if let Some(tool_result) = thread.tool_result(&tool_use_id) {
if let Some(tool_result) = thread.tool_result(tool_use_id) {
let message = if tool_result.is_error {
format!("✖︎ {}", tool_use.name)
} else {

View file

@ -459,8 +459,8 @@ impl ExampleInstance {
let mut output_file =
File::create(self.run_directory.join("judge.md")).expect("failed to create judge.md");
let diff_task = self.judge_diff(model.clone(), &run_output, cx);
let thread_task = self.judge_thread(model.clone(), &run_output, cx);
let diff_task = self.judge_diff(model.clone(), run_output, cx);
let thread_task = self.judge_thread(model.clone(), run_output, cx);
let (diff_result, thread_result) = futures::join!(diff_task, thread_task);
@ -661,7 +661,7 @@ pub fn wait_for_lang_server(
.update(cx, |buffer, cx| {
lsp_store.update(cx, |lsp_store, cx| {
lsp_store
.language_servers_for_local_buffer(&buffer, cx)
.language_servers_for_local_buffer(buffer, cx)
.next()
.is_some()
})
@ -693,7 +693,7 @@ pub fn wait_for_lang_server(
_ => {}
}
}),
cx.subscribe(&project, {
cx.subscribe(project, {
let buffer = buffer.clone();
move |project, event, cx| match event {
project::Event::LanguageServerAdded(_, _, _) => {
@ -838,7 +838,7 @@ fn messages_to_markdown<'a>(message_iter: impl IntoIterator<Item = &'a Message>)
for segment in &message.segments {
match segment {
MessageSegment::Text(text) => {
messages.push_str(&text);
messages.push_str(text);
messages.push_str("\n\n");
}
MessageSegment::Thinking { text, signature } => {
@ -846,7 +846,7 @@ fn messages_to_markdown<'a>(message_iter: impl IntoIterator<Item = &'a Message>)
if let Some(sig) = signature {
messages.push_str(&format!("Signature: {}\n\n", sig));
}
messages.push_str(&text);
messages.push_str(text);
messages.push_str("\n");
}
MessageSegment::RedactedThinking(items) => {
@ -878,7 +878,7 @@ pub async fn send_language_model_request(
request: LanguageModelRequest,
cx: &AsyncApp,
) -> anyhow::Result<String> {
match model.stream_completion_text(request, &cx).await {
match model.stream_completion_text(request, cx).await {
Ok(mut stream) => {
let mut full_response = String::new();
while let Some(chunk_result) = stream.stream.next().await {

View file

@ -452,7 +452,7 @@ impl ExtensionBuilder {
let mut output = Vec::new();
let mut stack = Vec::new();
for payload in Parser::new(0).parse_all(&input) {
for payload in Parser::new(0).parse_all(input) {
let payload = payload?;
// Track nesting depth, so that we don't mess with inner producer sections:

View file

@ -1341,7 +1341,7 @@ impl ExtensionStore {
&extension_path,
&extension.manifest,
wasm_host.clone(),
&cx,
cx,
)
.await
.with_context(|| format!("Loading extension from {extension_path:?}"));
@ -1776,7 +1776,7 @@ impl ExtensionStore {
})?;
for client in clients {
Self::sync_extensions_over_ssh(&this, client, cx)
Self::sync_extensions_over_ssh(this, client, cx)
.await
.log_err();
}

View file

@ -175,7 +175,7 @@ impl HeadlessExtensionStore {
}
let wasm_extension: Arc<dyn Extension> =
Arc::new(WasmExtension::load(&extension_dir, &manifest, wasm_host.clone(), &cx).await?);
Arc::new(WasmExtension::load(&extension_dir, &manifest, wasm_host.clone(), cx).await?);
for (language_server_id, language_server_config) in &manifest.language_servers {
for language in language_server_config.languages() {

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