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

@ -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 {