Fix clippy::needless_borrow lint violations (#36444)
Release Notes: - N/A
This commit is contained in:
parent
eecf142f06
commit
9e0e233319
242 changed files with 801 additions and 821 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -330,7 +330,7 @@ async fn fuzzy_search(
|
|||
.collect::<Vec<_>>();
|
||||
let mut matches = match_strings(
|
||||
&candidates,
|
||||
&query,
|
||||
query,
|
||||
false,
|
||||
true,
|
||||
100,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)>> {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue