Fix clippy::redundant_clone
lint violations (#36558)
This removes around 900 unnecessary clones, ranging from cloning a few ints all the way to large data structures and images. A lot of these were fixed using `cargo clippy --fix --workspace --all-targets`, however it often breaks other lints and needs to be run again. This was then followed up with some manual fixing. I understand this is a large diff, but all the changes are pretty trivial. Rust is doing some heavy lifting here for us. Once I get it up to speed with main, I'd appreciate this getting merged rather sooner than later. Release Notes: - N/A
This commit is contained in:
parent
cf7c64d77f
commit
7bdc99abc1
306 changed files with 805 additions and 1102 deletions
|
@ -514,7 +514,7 @@ impl CompletionsMenu {
|
|||
// Expand the range to resolve more completions than are predicted to be visible, to reduce
|
||||
// jank on navigation.
|
||||
let entry_indices = util::expanded_and_wrapped_usize_range(
|
||||
entry_range.clone(),
|
||||
entry_range,
|
||||
RESOLVE_BEFORE_ITEMS,
|
||||
RESOLVE_AFTER_ITEMS,
|
||||
entries.len(),
|
||||
|
|
|
@ -2156,7 +2156,7 @@ mod tests {
|
|||
}
|
||||
|
||||
let multi_buffer_snapshot = multi_buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
let (_, wraps_snapshot) = WrapMap::new(tab_snapshot, font, font_size, Some(wrap_width), cx);
|
||||
|
@ -2275,7 +2275,7 @@ mod tests {
|
|||
new_heights.insert(block_ids[0], 3);
|
||||
block_map_writer.resize(new_heights);
|
||||
|
||||
let snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
let snapshot = block_map.read(wraps_snapshot, Default::default());
|
||||
// Same height as before, should remain the same
|
||||
assert_eq!(snapshot.text(), "aaa\n\n\n\n\n\nbbb\nccc\nddd\n\n\n");
|
||||
}
|
||||
|
@ -2360,16 +2360,14 @@ mod tests {
|
|||
buffer.edit([(Point::new(2, 0)..Point::new(3, 0), "")], None, cx);
|
||||
buffer.snapshot(cx)
|
||||
});
|
||||
let (inlay_snapshot, inlay_edits) = inlay_map.sync(
|
||||
buffer_snapshot.clone(),
|
||||
buffer_subscription.consume().into_inner(),
|
||||
);
|
||||
let (inlay_snapshot, inlay_edits) =
|
||||
inlay_map.sync(buffer_snapshot, buffer_subscription.consume().into_inner());
|
||||
let (fold_snapshot, fold_edits) = fold_map.read(inlay_snapshot, inlay_edits);
|
||||
let (tab_snapshot, tab_edits) = tab_map.sync(fold_snapshot, fold_edits, tab_size);
|
||||
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
|
||||
wrap_map.sync(tab_snapshot, tab_edits, cx)
|
||||
});
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), wrap_edits);
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot, wrap_edits);
|
||||
assert_eq!(blocks_snapshot.text(), "line1\n\n\n\n\nline5");
|
||||
|
||||
let buffer_snapshot = buffer.update(cx, |buffer, cx| {
|
||||
|
@ -2454,7 +2452,7 @@ mod tests {
|
|||
// Removing the replace block shows all the hidden blocks again.
|
||||
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
|
||||
writer.remove(HashSet::from_iter([replace_block_id]));
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
|
||||
assert_eq!(
|
||||
blocks_snapshot.text(),
|
||||
"\nline1\n\nline2\n\n\nline 2.1\nline2.2\nline 2.3\nline 2.4\n\nline4\n\nline5"
|
||||
|
@ -2793,7 +2791,7 @@ mod tests {
|
|||
buffer.read_with(cx, |buffer, cx| {
|
||||
writer.fold_buffers([buffer_id_3], buffer, cx);
|
||||
});
|
||||
let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default());
|
||||
let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
|
||||
let blocks = blocks_snapshot
|
||||
.blocks_in_range(0..u32::MAX)
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -2846,7 +2844,7 @@ mod tests {
|
|||
assert_eq!(buffer_ids.len(), 1);
|
||||
let buffer_id = buffer_ids[0];
|
||||
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
let (_, wrap_snapshot) =
|
||||
|
@ -2860,7 +2858,7 @@ mod tests {
|
|||
buffer.read_with(cx, |buffer, cx| {
|
||||
writer.fold_buffers([buffer_id], buffer, cx);
|
||||
});
|
||||
let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default());
|
||||
let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
|
||||
let blocks = blocks_snapshot
|
||||
.blocks_in_range(0..u32::MAX)
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -3527,7 +3525,7 @@ mod tests {
|
|||
..buffer_snapshot.anchor_after(Point::new(1, 0))],
|
||||
false,
|
||||
);
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
|
||||
let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
|
||||
assert_eq!(blocks_snapshot.text(), "abc\n\ndef\nghi\njkl\nmno");
|
||||
}
|
||||
|
||||
|
|
|
@ -1557,7 +1557,7 @@ mod tests {
|
|||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
|
||||
|
||||
let (mut writer, _, _) = map.write(inlay_snapshot, vec![]);
|
||||
|
@ -1636,7 +1636,7 @@ mod tests {
|
|||
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
|
||||
{
|
||||
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
|
||||
|
@ -1712,7 +1712,7 @@ mod tests {
|
|||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
|
||||
|
||||
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
|
||||
|
@ -1720,7 +1720,7 @@ mod tests {
|
|||
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
|
||||
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
|
||||
]);
|
||||
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
|
||||
let (snapshot, _) = map.read(inlay_snapshot, vec![]);
|
||||
assert_eq!(snapshot.text(), "aa⋯cccc\nd⋯eeeee");
|
||||
|
||||
let buffer_snapshot = buffer.update(cx, |buffer, cx| {
|
||||
|
@ -1747,7 +1747,7 @@ mod tests {
|
|||
(Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()),
|
||||
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
|
||||
]);
|
||||
let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
|
||||
let (snapshot, _) = map.read(inlay_snapshot, vec![]);
|
||||
let fold_ranges = snapshot
|
||||
.folds_in_range(Point::new(1, 0)..Point::new(1, 3))
|
||||
.map(|fold| {
|
||||
|
@ -1782,7 +1782,7 @@ mod tests {
|
|||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
|
||||
|
||||
let (mut initial_snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
|
||||
let (mut initial_snapshot, _) = map.read(inlay_snapshot, vec![]);
|
||||
let mut snapshot_edits = Vec::new();
|
||||
|
||||
let mut next_inlay_id = 0;
|
||||
|
|
|
@ -116,7 +116,7 @@ impl TabMap {
|
|||
state.new.end = edit.new.end;
|
||||
Some(None) // Skip this edit, it's merged
|
||||
} else {
|
||||
let new_state = edit.clone();
|
||||
let new_state = edit;
|
||||
let result = Some(Some(state.clone())); // Yield the previous edit
|
||||
**state = new_state;
|
||||
result
|
||||
|
@ -611,7 +611,7 @@ mod tests {
|
|||
fn test_expand_tabs(cx: &mut gpui::App) {
|
||||
let buffer = MultiBuffer::build_simple("", cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
|
||||
|
@ -628,7 +628,7 @@ mod tests {
|
|||
|
||||
let buffer = MultiBuffer::build_simple(input, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
|
||||
|
@ -675,7 +675,7 @@ mod tests {
|
|||
|
||||
let buffer = MultiBuffer::build_simple(input, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
|
||||
|
@ -689,7 +689,7 @@ mod tests {
|
|||
|
||||
let buffer = MultiBuffer::build_simple(input, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
|
||||
|
||||
|
@ -749,7 +749,7 @@ mod tests {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
log::info!("Buffer text: {:?}", buffer_snapshot.text());
|
||||
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
||||
log::info!("InlayMap text: {:?}", inlay_snapshot.text());
|
||||
let (mut fold_map, _) = FoldMap::new(inlay_snapshot.clone());
|
||||
fold_map.randomly_mutate(&mut rng);
|
||||
|
@ -758,7 +758,7 @@ mod tests {
|
|||
let (inlay_snapshot, _) = inlay_map.randomly_mutate(&mut 0, &mut rng);
|
||||
log::info!("InlayMap text: {:?}", inlay_snapshot.text());
|
||||
|
||||
let (mut tab_map, _) = TabMap::new(fold_snapshot.clone(), tab_size);
|
||||
let (mut tab_map, _) = TabMap::new(fold_snapshot, tab_size);
|
||||
let tabs_snapshot = tab_map.set_max_expansion_column(32);
|
||||
|
||||
let text = text::Rope::from(tabs_snapshot.text().as_str());
|
||||
|
|
|
@ -4528,7 +4528,7 @@ impl Editor {
|
|||
let mut char_position = 0u32;
|
||||
let mut end_tag_offset = None;
|
||||
|
||||
'outer: for chunk in snapshot.text_for_range(range.clone()) {
|
||||
'outer: for chunk in snapshot.text_for_range(range) {
|
||||
if let Some(byte_pos) = chunk.find(&**end_tag) {
|
||||
let chars_before_match =
|
||||
chunk[..byte_pos].chars().count() as u32;
|
||||
|
@ -4881,7 +4881,7 @@ impl Editor {
|
|||
let multibuffer = self.buffer.read(cx);
|
||||
let Some(buffer) = position
|
||||
.buffer_id
|
||||
.and_then(|buffer_id| multibuffer.buffer(buffer_id).clone())
|
||||
.and_then(|buffer_id| multibuffer.buffer(buffer_id))
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
|
@ -6269,7 +6269,7 @@ impl Editor {
|
|||
}))
|
||||
}
|
||||
CodeActionsItem::DebugScenario(scenario) => {
|
||||
let context = actions_menu.actions.context.clone();
|
||||
let context = actions_menu.actions.context;
|
||||
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
dap::send_telemetry(&scenario, TelemetrySpawnLocation::Gutter, cx);
|
||||
|
@ -6469,7 +6469,7 @@ impl Editor {
|
|||
|
||||
fn refresh_code_actions(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<()> {
|
||||
let newest_selection = self.selections.newest_anchor().clone();
|
||||
let newest_selection_adjusted = self.selections.newest_adjusted(cx).clone();
|
||||
let newest_selection_adjusted = self.selections.newest_adjusted(cx);
|
||||
let buffer = self.buffer.read(cx);
|
||||
if newest_selection.head().diff_base_anchor.is_some() {
|
||||
return None;
|
||||
|
@ -8188,8 +8188,6 @@ impl Editor {
|
|||
.icon_color(color)
|
||||
.style(ButtonStyle::Transparent)
|
||||
.on_click(cx.listener({
|
||||
let breakpoint = breakpoint.clone();
|
||||
|
||||
move |editor, event: &ClickEvent, window, cx| {
|
||||
let edit_action = if event.modifiers().platform || breakpoint.is_disabled() {
|
||||
BreakpointEditAction::InvertState
|
||||
|
@ -14837,7 +14835,7 @@ impl Editor {
|
|||
if parent == child {
|
||||
return None;
|
||||
}
|
||||
let text = buffer.text_for_range(child.clone()).collect::<String>();
|
||||
let text = buffer.text_for_range(child).collect::<String>();
|
||||
Some((selection.id, parent, text))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -15940,7 +15938,7 @@ impl Editor {
|
|||
if !split
|
||||
&& Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref()
|
||||
{
|
||||
editor.go_to_singleton_buffer_range(range.clone(), window, cx);
|
||||
editor.go_to_singleton_buffer_range(range, window, cx);
|
||||
} else {
|
||||
window.defer(cx, move |window, cx| {
|
||||
let target_editor: Entity<Self> =
|
||||
|
@ -16198,14 +16196,14 @@ impl Editor {
|
|||
let item_id = item.item_id();
|
||||
|
||||
if split {
|
||||
workspace.split_item(SplitDirection::Right, item.clone(), window, cx);
|
||||
workspace.split_item(SplitDirection::Right, item, window, cx);
|
||||
} else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
||||
let (preview_item_id, preview_item_idx) =
|
||||
workspace.active_pane().read_with(cx, |pane, _| {
|
||||
(pane.preview_item_id(), pane.preview_item_idx())
|
||||
});
|
||||
|
||||
workspace.add_item_to_active_pane(item.clone(), preview_item_idx, true, window, cx);
|
||||
workspace.add_item_to_active_pane(item, preview_item_idx, true, window, cx);
|
||||
|
||||
if let Some(preview_item_id) = preview_item_id {
|
||||
workspace.active_pane().update(cx, |pane, cx| {
|
||||
|
@ -16213,7 +16211,7 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
workspace.add_item_to_active_pane(item.clone(), None, true, window, cx);
|
||||
workspace.add_item_to_active_pane(item, None, true, window, cx);
|
||||
}
|
||||
workspace.active_pane().update(cx, |pane, cx| {
|
||||
pane.set_preview_item_id(Some(item_id), cx);
|
||||
|
@ -19004,10 +19002,7 @@ impl Editor {
|
|||
|
||||
let selection = text::ToPoint::to_point(&range.start, buffer).row
|
||||
..text::ToPoint::to_point(&range.end, buffer).row;
|
||||
Some((
|
||||
multi_buffer.buffer(buffer.remote_id()).unwrap().clone(),
|
||||
selection,
|
||||
))
|
||||
Some((multi_buffer.buffer(buffer.remote_id()).unwrap(), selection))
|
||||
});
|
||||
|
||||
let Some((buffer, selection)) = buffer_and_selection else {
|
||||
|
@ -19249,7 +19244,7 @@ impl Editor {
|
|||
row_highlights.insert(
|
||||
ix,
|
||||
RowHighlight {
|
||||
range: range.clone(),
|
||||
range,
|
||||
index,
|
||||
color,
|
||||
options,
|
||||
|
@ -21676,7 +21671,7 @@ fn wrap_with_prefix(
|
|||
let subsequent_lines_prefix_len =
|
||||
char_len_with_expanded_tabs(0, &subsequent_lines_prefix, tab_size);
|
||||
let mut wrapped_text = String::new();
|
||||
let mut current_line = first_line_prefix.clone();
|
||||
let mut current_line = first_line_prefix;
|
||||
let mut is_first_line = true;
|
||||
|
||||
let tokenizer = WordBreakingTokenizer::new(&unwrapped_text);
|
||||
|
|
|
@ -88,7 +88,7 @@ impl RenderOnce for BufferFontFamilyControl {
|
|||
.child(Icon::new(IconName::Font))
|
||||
.child(DropdownMenu::new(
|
||||
"buffer-font-family",
|
||||
value.clone(),
|
||||
value,
|
||||
ContextMenu::build(window, cx, |mut menu, _, cx| {
|
||||
let font_family_cache = FontFamilyCache::global(cx);
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
|
|||
_ = workspace.update(cx, |_v, window, cx| {
|
||||
cx.new(|cx| {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
|
||||
let mut editor = build_editor(buffer.clone(), window, cx);
|
||||
let mut editor = build_editor(buffer, window, cx);
|
||||
let handle = cx.entity();
|
||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
|
||||
|
||||
|
@ -898,7 +898,7 @@ fn test_fold_action(cx: &mut TestAppContext) {
|
|||
.unindent(),
|
||||
cx,
|
||||
);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -989,7 +989,7 @@ fn test_fold_action_whitespace_sensitive_language(cx: &mut TestAppContext) {
|
|||
.unindent(),
|
||||
cx,
|
||||
);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -1074,7 +1074,7 @@ fn test_fold_action_multiple_line_breaks(cx: &mut TestAppContext) {
|
|||
.unindent(),
|
||||
cx,
|
||||
);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -1173,7 +1173,7 @@ fn test_fold_at_level(cx: &mut TestAppContext) {
|
|||
.unindent(),
|
||||
cx,
|
||||
);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -1335,7 +1335,7 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("🟥🟧🟨🟩🟦🟪\nabcde\nαβγδε", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
assert_eq!('🟥'.len_utf8(), 4);
|
||||
|
@ -1452,7 +1452,7 @@ fn test_move_cursor_different_line_lengths(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
|
@ -2479,7 +2479,7 @@ fn test_delete_to_word_boundary(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("one two three four", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -2527,7 +2527,7 @@ fn test_delete_to_previous_word_start_or_newline(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("one\n2\nthree\n4", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
let del_to_prev_word_start = DeleteToPreviousWordStart {
|
||||
ignore_newlines: false,
|
||||
|
@ -2563,7 +2563,7 @@ fn test_delete_to_next_word_end_or_newline(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("\none\n two\nthree\n four", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
let del_to_next_word_end = DeleteToNextWordEnd {
|
||||
ignore_newlines: false,
|
||||
|
@ -2608,7 +2608,7 @@ fn test_newline(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -2644,7 +2644,7 @@ fn test_newline_with_old_selections(cx: &mut TestAppContext) {
|
|||
.as_str(),
|
||||
cx,
|
||||
);
|
||||
let mut editor = build_editor(buffer.clone(), window, cx);
|
||||
let mut editor = build_editor(buffer, window, cx);
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([
|
||||
Point::new(2, 4)..Point::new(2, 5),
|
||||
|
@ -3175,7 +3175,7 @@ fn test_insert_with_old_selections(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
|
||||
let mut editor = build_editor(buffer.clone(), window, cx);
|
||||
let mut editor = build_editor(buffer, window, cx);
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([3..4, 11..12, 19..20])
|
||||
});
|
||||
|
@ -5562,7 +5562,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
# ˇThis is a long comment using a pound
|
||||
# sign.
|
||||
"},
|
||||
python_language.clone(),
|
||||
python_language,
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
|
@ -5669,7 +5669,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
also very long and should not merge
|
||||
with the numbered item.ˇ»
|
||||
"},
|
||||
markdown_language.clone(),
|
||||
markdown_language,
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
|
@ -5700,7 +5700,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
// This is the second long comment block
|
||||
// to be wrapped.ˇ»
|
||||
"},
|
||||
rust_language.clone(),
|
||||
rust_language,
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
|
@ -5723,7 +5723,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
«\tThis is a very long indented line
|
||||
\tthat will be wrapped.ˇ»
|
||||
"},
|
||||
plaintext_language.clone(),
|
||||
plaintext_language,
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
|
@ -8889,7 +8889,7 @@ async fn test_autoclose_with_embedded_language(cx: &mut TestAppContext) {
|
|||
));
|
||||
|
||||
cx.language_registry().add(html_language.clone());
|
||||
cx.language_registry().add(javascript_language.clone());
|
||||
cx.language_registry().add(javascript_language);
|
||||
cx.executor().run_until_parked();
|
||||
|
||||
cx.update_buffer(|buffer, cx| {
|
||||
|
@ -9633,7 +9633,7 @@ async fn test_snippets(cx: &mut TestAppContext) {
|
|||
.selections
|
||||
.all(cx)
|
||||
.iter()
|
||||
.map(|s| s.range().clone())
|
||||
.map(|s| s.range())
|
||||
.collect::<Vec<_>>();
|
||||
editor
|
||||
.insert_snippet(&insertion_ranges, snippet, window, cx)
|
||||
|
@ -9713,7 +9713,7 @@ async fn test_snippet_indentation(cx: &mut TestAppContext) {
|
|||
.selections
|
||||
.all(cx)
|
||||
.iter()
|
||||
.map(|s| s.range().clone())
|
||||
.map(|s| s.range())
|
||||
.collect::<Vec<_>>();
|
||||
editor
|
||||
.insert_snippet(&insertion_ranges, snippet, window, cx)
|
||||
|
@ -10782,7 +10782,7 @@ async fn test_multiple_formatters(cx: &mut TestAppContext) {
|
|||
kind: Some("code-action-2".into()),
|
||||
edit: Some(lsp::WorkspaceEdit::new(
|
||||
[(
|
||||
uri.clone(),
|
||||
uri,
|
||||
vec![lsp::TextEdit::new(
|
||||
lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
|
||||
"applied-code-action-2-edit\n".to_string(),
|
||||
|
@ -14366,7 +14366,7 @@ async fn test_toggle_block_comment(cx: &mut TestAppContext) {
|
|||
));
|
||||
|
||||
cx.language_registry().add(html_language.clone());
|
||||
cx.language_registry().add(javascript_language.clone());
|
||||
cx.language_registry().add(javascript_language);
|
||||
cx.update_buffer(|buffer, cx| {
|
||||
buffer.set_language(Some(html_language), cx);
|
||||
});
|
||||
|
@ -14543,7 +14543,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
|||
);
|
||||
let excerpt_ranges = markers.into_iter().map(|marker| {
|
||||
let context = excerpt_ranges.remove(&marker).unwrap()[0].clone();
|
||||
ExcerptRange::new(context.clone())
|
||||
ExcerptRange::new(context)
|
||||
});
|
||||
let buffer = cx.new(|cx| Buffer::local(initial_text, cx));
|
||||
let multibuffer = cx.new(|cx| {
|
||||
|
@ -14828,7 +14828,7 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(16, 8, 'a'), cx);
|
||||
build_editor(buffer.clone(), window, cx)
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
|
@ -15750,8 +15750,7 @@ async fn test_on_type_formatting_is_applied_after_autoindent(cx: &mut TestAppCon
|
|||
cx.simulate_keystroke("\n");
|
||||
cx.run_until_parked();
|
||||
|
||||
let buffer_cloned =
|
||||
cx.multibuffer(|multi_buffer, _| multi_buffer.as_singleton().unwrap().clone());
|
||||
let buffer_cloned = cx.multibuffer(|multi_buffer, _| multi_buffer.as_singleton().unwrap());
|
||||
let mut request =
|
||||
cx.set_request_handler::<lsp::request::OnTypeFormatting, _, _>(move |_, _, mut cx| {
|
||||
let buffer_cloned = buffer_cloned.clone();
|
||||
|
@ -19455,7 +19454,7 @@ async fn test_adjacent_diff_hunks(executor: BackgroundExecutor, cx: &mut TestApp
|
|||
let buffer_id = hunks[0].buffer_id;
|
||||
hunks
|
||||
.into_iter()
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
assert_eq!(hunk_ranges.len(), 2);
|
||||
|
@ -19546,7 +19545,7 @@ async fn test_adjacent_diff_hunks(executor: BackgroundExecutor, cx: &mut TestApp
|
|||
let buffer_id = hunks[0].buffer_id;
|
||||
hunks
|
||||
.into_iter()
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
assert_eq!(hunk_ranges.len(), 2);
|
||||
|
@ -19612,7 +19611,7 @@ async fn test_toggle_deletion_hunk_at_start_of_file(
|
|||
let buffer_id = hunks[0].buffer_id;
|
||||
hunks
|
||||
.into_iter()
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
|
||||
.map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
assert_eq!(hunk_ranges.len(), 1);
|
||||
|
@ -19635,7 +19634,7 @@ async fn test_toggle_deletion_hunk_at_start_of_file(
|
|||
});
|
||||
executor.run_until_parked();
|
||||
|
||||
cx.assert_state_with_diff(hunk_expanded.clone());
|
||||
cx.assert_state_with_diff(hunk_expanded);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -21150,7 +21149,7 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
|
|||
let abs_path = project.read_with(cx, |project, cx| {
|
||||
project
|
||||
.absolute_path(&project_path, cx)
|
||||
.map(|path_buf| Arc::from(path_buf.to_owned()))
|
||||
.map(Arc::from)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
|
@ -21168,7 +21167,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_eq!(1, breakpoints.len());
|
||||
|
@ -21193,7 +21191,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_eq!(1, breakpoints.len());
|
||||
|
@ -21215,7 +21212,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_eq!(0, breakpoints.len());
|
||||
|
@ -21267,7 +21263,7 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
let abs_path = project.read_with(cx, |project, cx| {
|
||||
project
|
||||
.absolute_path(&project_path, cx)
|
||||
.map(|path_buf| Arc::from(path_buf.to_owned()))
|
||||
.map(Arc::from)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
|
@ -21282,7 +21278,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_breakpoint(
|
||||
|
@ -21303,7 +21298,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_breakpoint(&breakpoints, &abs_path, vec![]);
|
||||
|
@ -21323,7 +21317,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_breakpoint(
|
||||
|
@ -21346,7 +21339,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_breakpoint(
|
||||
|
@ -21369,7 +21361,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_breakpoint(
|
||||
|
@ -21442,7 +21433,7 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
|
|||
let abs_path = project.read_with(cx, |project, cx| {
|
||||
project
|
||||
.absolute_path(&project_path, cx)
|
||||
.map(|path_buf| Arc::from(path_buf.to_owned()))
|
||||
.map(Arc::from)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
|
@ -21462,7 +21453,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_eq!(1, breakpoints.len());
|
||||
|
@ -21494,7 +21484,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
let disable_breakpoint = {
|
||||
|
@ -21530,7 +21519,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
|
|||
.unwrap()
|
||||
.read(cx)
|
||||
.all_source_breakpoints(cx)
|
||||
.clone()
|
||||
});
|
||||
|
||||
assert_eq!(1, breakpoints.len());
|
||||
|
@ -22509,10 +22497,7 @@ async fn test_html_linked_edits_on_completion(cx: &mut TestAppContext) {
|
|||
let closing_range =
|
||||
buffer.anchor_before(Point::new(0, 6))..buffer.anchor_after(Point::new(0, 8));
|
||||
let mut linked_ranges = HashMap::default();
|
||||
linked_ranges.insert(
|
||||
buffer_id,
|
||||
vec![(opening_range.clone(), vec![closing_range.clone()])],
|
||||
);
|
||||
linked_ranges.insert(buffer_id, vec![(opening_range, vec![closing_range])]);
|
||||
editor.linked_edit_ranges = LinkedEditingRanges(linked_ranges);
|
||||
});
|
||||
let mut completion_handle =
|
||||
|
|
|
@ -7209,7 +7209,7 @@ fn render_blame_entry_popover(
|
|||
) -> Option<AnyElement> {
|
||||
let renderer = cx.global::<GlobalBlameRenderer>().0.clone();
|
||||
let blame = blame.read(cx);
|
||||
let repository = blame.repository(cx)?.clone();
|
||||
let repository = blame.repository(cx)?;
|
||||
renderer.render_blame_entry_popover(
|
||||
blame_entry,
|
||||
scroll_handle,
|
||||
|
@ -9009,7 +9009,7 @@ impl Element for EditorElement {
|
|||
.as_ref()
|
||||
.map(|layout| (layout.bounds, layout.entry.clone())),
|
||||
display_hunks: display_hunks.clone(),
|
||||
diff_hunk_control_bounds: diff_hunk_control_bounds.clone(),
|
||||
diff_hunk_control_bounds,
|
||||
});
|
||||
|
||||
self.editor.update(cx, |editor, _| {
|
||||
|
@ -9894,7 +9894,7 @@ impl CursorLayout {
|
|||
.px_0p5()
|
||||
.line_height(text_size + px(2.))
|
||||
.text_color(cursor_name.color)
|
||||
.child(cursor_name.string.clone())
|
||||
.child(cursor_name.string)
|
||||
.into_any_element();
|
||||
|
||||
name_element.prepaint_as_root(name_origin, AvailableSpace::min_size(), window, cx);
|
||||
|
|
|
@ -623,7 +623,7 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {
|
|||
|
||||
let mut base_text_style = window.text_style();
|
||||
base_text_style.refine(&TextStyleRefinement {
|
||||
font_family: Some(ui_font_family.clone()),
|
||||
font_family: Some(ui_font_family),
|
||||
font_fallbacks: ui_font_fallbacks,
|
||||
color: Some(cx.theme().colors().editor_foreground),
|
||||
..Default::default()
|
||||
|
@ -672,7 +672,7 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {
|
|||
|
||||
let mut base_text_style = window.text_style();
|
||||
base_text_style.refine(&TextStyleRefinement {
|
||||
font_family: Some(ui_font_family.clone()),
|
||||
font_family: Some(ui_font_family),
|
||||
font_fallbacks: ui_font_fallbacks,
|
||||
color: Some(cx.theme().colors().editor_foreground),
|
||||
..Default::default()
|
||||
|
|
|
@ -507,7 +507,7 @@ pub(crate) fn handle_from(
|
|||
|
||||
{
|
||||
let selections = this
|
||||
.read_with(cx, |this, _| this.selections.disjoint_anchors().clone())
|
||||
.read_with(cx, |this, _| this.selections.disjoint_anchors())
|
||||
.ok()?;
|
||||
for selection in selections.iter() {
|
||||
let Some(selection_buffer_offset_head) =
|
||||
|
|
|
@ -119,13 +119,7 @@ impl EditorTestContext {
|
|||
for excerpt in excerpts.into_iter() {
|
||||
let (text, ranges) = marked_text_ranges(excerpt, false);
|
||||
let buffer = cx.new(|cx| Buffer::local(text, cx));
|
||||
multibuffer.push_excerpts(
|
||||
buffer,
|
||||
ranges
|
||||
.into_iter()
|
||||
.map(|range| ExcerptRange::new(range.clone())),
|
||||
cx,
|
||||
);
|
||||
multibuffer.push_excerpts(buffer, ranges.into_iter().map(ExcerptRange::new), cx);
|
||||
}
|
||||
multibuffer
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue