chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
@@ -28,7 +28,7 @@ pub fn switch_source_header(
|
||||
};
|
||||
|
||||
let Some((_, _, server_to_query, buffer)) =
|
||||
find_specific_language_server_in_selection(&editor, cx, &is_c_language, CLANGD_SERVER_NAME)
|
||||
find_specific_language_server_in_selection(editor, cx, is_c_language, CLANGD_SERVER_NAME)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
@@ -85,7 +85,7 @@ pub fn switch_source_header(
|
||||
|
||||
pub fn apply_related_actions(editor: &View<Editor>, cx: &mut WindowContext) {
|
||||
if editor.update(cx, |e, cx| {
|
||||
find_specific_language_server_in_selection(e, cx, &is_c_language, CLANGD_SERVER_NAME)
|
||||
find_specific_language_server_in_selection(e, cx, is_c_language, CLANGD_SERVER_NAME)
|
||||
.is_some()
|
||||
}) {
|
||||
register_action(editor, cx, switch_source_header);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//! - [`WrapMap`] that handles soft wrapping.
|
||||
//! - [`BlockMap`] that tracks custom blocks such as diagnostics that should be displayed within buffer.
|
||||
//! - [`DisplayMap`] that adds background highlights to the regions of text.
|
||||
//! Each one of those builds on top of preceding map.
|
||||
//! Each one of those builds on top of preceding map.
|
||||
//!
|
||||
//! [Editor]: crate::Editor
|
||||
//! [EditorElement]: crate::element::EditorElement
|
||||
@@ -588,7 +588,7 @@ impl DisplaySnapshot {
|
||||
|
||||
pub fn display_point_to_anchor(&self, point: DisplayPoint, bias: Bias) -> Anchor {
|
||||
self.buffer_snapshot
|
||||
.anchor_at(point.to_offset(&self, bias), bias)
|
||||
.anchor_at(point.to_offset(self, bias), bias)
|
||||
}
|
||||
|
||||
fn display_point_to_inlay_point(&self, point: DisplayPoint, bias: Bias) -> InlayPoint {
|
||||
@@ -735,7 +735,7 @@ impl DisplaySnapshot {
|
||||
let mut line = String::new();
|
||||
|
||||
let range = display_row..display_row.next_row();
|
||||
for chunk in self.highlighted_chunks(range, false, &editor_style) {
|
||||
for chunk in self.highlighted_chunks(range, false, editor_style) {
|
||||
line.push_str(chunk.text);
|
||||
|
||||
let text_style = if let Some(style) = chunk.style {
|
||||
@@ -1286,7 +1286,7 @@ pub mod tests {
|
||||
height,
|
||||
disposition,
|
||||
render: Box::new(|_| div().into_any()),
|
||||
priority: priority,
|
||||
priority,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -60,9 +60,9 @@ pub struct BlockSnapshot {
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct CustomBlockId(usize);
|
||||
|
||||
impl Into<ElementId> for CustomBlockId {
|
||||
fn into(self) -> ElementId {
|
||||
ElementId::Integer(self.0)
|
||||
impl From<CustomBlockId> for ElementId {
|
||||
fn from(val: CustomBlockId) -> Self {
|
||||
ElementId::Integer(val.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ impl BlockMap {
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub(crate) fn sort_blocks<B: BlockLike>(blocks: &mut Vec<(u32, B)>) {
|
||||
pub(crate) fn sort_blocks<B: BlockLike>(blocks: &mut [(u32, B)]) {
|
||||
// Place excerpt headers and footers above custom blocks on the same row
|
||||
blocks.sort_unstable_by(|(row_a, block_a), (row_b, block_b)| {
|
||||
row_a.cmp(row_b).then_with(|| {
|
||||
@@ -1478,7 +1478,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_basic_blocks(cx: &mut gpui::TestAppContext) {
|
||||
cx.update(|cx| init_test(cx));
|
||||
cx.update(init_test);
|
||||
|
||||
let text = "aaa\nbbb\nccc\nddd";
|
||||
|
||||
@@ -1734,7 +1734,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_replace_with_heights(cx: &mut gpui::TestAppContext) {
|
||||
let _update = cx.update(|cx| init_test(cx));
|
||||
cx.update(init_test);
|
||||
|
||||
let text = "aaa\nbbb\nccc\nddd";
|
||||
|
||||
@@ -1838,7 +1838,7 @@ mod tests {
|
||||
#[cfg(target_os = "macos")]
|
||||
#[gpui::test]
|
||||
fn test_blocks_on_wrapped_lines(cx: &mut gpui::TestAppContext) {
|
||||
cx.update(|cx| init_test(cx));
|
||||
cx.update(init_test);
|
||||
|
||||
let _font_id = cx.text_system().font_id(&font("Helvetica")).unwrap();
|
||||
|
||||
@@ -1885,7 +1885,7 @@ mod tests {
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_blocks(cx: &mut gpui::TestAppContext, mut rng: StdRng) {
|
||||
cx.update(|cx| init_test(cx));
|
||||
cx.update(init_test);
|
||||
|
||||
let operations = env::var("OPERATIONS")
|
||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||
|
||||
@@ -46,7 +46,7 @@ impl CreaseSnapshot {
|
||||
Ordering::Greater => break,
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
pub fn crease_items_with_offsets(
|
||||
@@ -183,7 +183,7 @@ impl CreaseMap {
|
||||
}
|
||||
}
|
||||
removals.sort_unstable_by(|(a_id, a_range), (b_id, b_range)| {
|
||||
AnchorRangeExt::cmp(a_range, b_range, snapshot).then(b_id.cmp(&a_id))
|
||||
AnchorRangeExt::cmp(a_range, b_range, snapshot).then(b_id.cmp(a_id))
|
||||
});
|
||||
|
||||
self.snapshot.creases = {
|
||||
|
||||
@@ -122,7 +122,7 @@ impl<'a> FoldMapWriter<'a> {
|
||||
let snapshot = self.0.snapshot.inlay_snapshot.clone();
|
||||
for (range, fold_text) in ranges.into_iter() {
|
||||
let buffer = &snapshot.buffer;
|
||||
let range = range.start.to_offset(&buffer)..range.end.to_offset(&buffer);
|
||||
let range = range.start.to_offset(buffer)..range.end.to_offset(buffer);
|
||||
|
||||
// Ignore any empty ranges.
|
||||
if range.start == range.end {
|
||||
@@ -420,7 +420,7 @@ impl FoldMap {
|
||||
}
|
||||
|
||||
if fold_range.end > fold_range.start {
|
||||
const ELLIPSIS: &'static str = "⋯";
|
||||
const ELLIPSIS: &str = "⋯";
|
||||
|
||||
let fold_id = fold.id;
|
||||
new_transforms.push(
|
||||
@@ -850,7 +850,8 @@ fn consolidate_inlay_edits(mut edits: Vec<InlayEdit>) -> Vec<InlayEdit> {
|
||||
|
||||
let _old_alloc_ptr = edits.as_ptr();
|
||||
let mut inlay_edits = edits.into_iter();
|
||||
let inlay_edits = if let Some(mut first_edit) = inlay_edits.next() {
|
||||
|
||||
if let Some(mut first_edit) = inlay_edits.next() {
|
||||
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
|
||||
#[allow(clippy::filter_map_identity)]
|
||||
let mut v: Vec<_> = inlay_edits
|
||||
@@ -872,9 +873,7 @@ fn consolidate_inlay_edits(mut edits: Vec<InlayEdit>) -> Vec<InlayEdit> {
|
||||
v
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
inlay_edits
|
||||
}
|
||||
}
|
||||
|
||||
fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
|
||||
@@ -886,7 +885,8 @@ fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
|
||||
});
|
||||
let _old_alloc_ptr = edits.as_ptr();
|
||||
let mut fold_edits = edits.into_iter();
|
||||
let fold_edits = if let Some(mut first_edit) = fold_edits.next() {
|
||||
|
||||
if let Some(mut first_edit) = fold_edits.next() {
|
||||
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
|
||||
#[allow(clippy::filter_map_identity)]
|
||||
let mut v: Vec<_> = fold_edits
|
||||
@@ -907,9 +907,7 @@ fn consolidate_fold_edits(mut edits: Vec<FoldEdit>) -> Vec<FoldEdit> {
|
||||
v
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
fold_edits
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
@@ -956,9 +954,9 @@ impl sum_tree::Summary for TransformSummary {
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
|
||||
pub struct FoldId(usize);
|
||||
|
||||
impl Into<ElementId> for FoldId {
|
||||
fn into(self) -> ElementId {
|
||||
ElementId::Integer(self.0)
|
||||
impl From<FoldId> for ElementId {
|
||||
fn from(val: FoldId) -> Self {
|
||||
ElementId::Integer(val.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ impl<'a> Iterator for InlayChunks<'a> {
|
||||
} else {
|
||||
next_inlay_highlight_endpoint = range.end - offset_in_inlay.0;
|
||||
highlight_style
|
||||
.get_or_insert_with(|| Default::default())
|
||||
.get_or_insert_with(Default::default)
|
||||
.highlight(*style);
|
||||
}
|
||||
} else {
|
||||
@@ -451,15 +451,14 @@ impl InlayMap {
|
||||
) -> (InlaySnapshot, Vec<InlayEdit>) {
|
||||
let snapshot = &mut self.snapshot;
|
||||
|
||||
if buffer_edits.is_empty() {
|
||||
if snapshot.buffer.trailing_excerpt_update_count()
|
||||
if buffer_edits.is_empty()
|
||||
&& snapshot.buffer.trailing_excerpt_update_count()
|
||||
!= buffer_snapshot.trailing_excerpt_update_count()
|
||||
{
|
||||
buffer_edits.push(Edit {
|
||||
old: snapshot.buffer.len()..snapshot.buffer.len(),
|
||||
new: buffer_snapshot.len()..buffer_snapshot.len(),
|
||||
});
|
||||
}
|
||||
{
|
||||
buffer_edits.push(Edit {
|
||||
old: snapshot.buffer.len()..snapshot.buffer.len(),
|
||||
new: buffer_snapshot.len()..buffer_snapshot.len(),
|
||||
});
|
||||
}
|
||||
|
||||
if buffer_edits.is_empty() {
|
||||
|
||||
@@ -654,7 +654,7 @@ mod tests {
|
||||
fn test_marking_tabs(cx: &mut gpui::AppContext) {
|
||||
let input = "\t \thello";
|
||||
|
||||
let buffer = MultiBuffer::build_simple(&input, cx);
|
||||
let buffer = MultiBuffer::build_simple(input, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
|
||||
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
|
||||
|
||||
@@ -111,7 +111,7 @@ impl WrapMap {
|
||||
} else {
|
||||
self.edits_since_sync = self
|
||||
.edits_since_sync
|
||||
.compose(&self.snapshot.interpolate(tab_snapshot, &edits));
|
||||
.compose(self.snapshot.interpolate(tab_snapshot, &edits));
|
||||
self.snapshot.interpolated = false;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ impl WrapMap {
|
||||
}
|
||||
let new_rows = self.snapshot.transforms.summary().output.lines.row + 1;
|
||||
self.snapshot.interpolated = false;
|
||||
self.edits_since_sync = self.edits_since_sync.compose(&Patch::new(vec![WrapEdit {
|
||||
self.edits_since_sync = self.edits_since_sync.compose(Patch::new(vec![WrapEdit {
|
||||
old: 0..old_rows,
|
||||
new: 0..new_rows,
|
||||
}]));
|
||||
@@ -1009,7 +1009,8 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for WrapPoint {
|
||||
fn consolidate_wrap_edits(edits: Vec<WrapEdit>) -> Vec<WrapEdit> {
|
||||
let _old_alloc_ptr = edits.as_ptr();
|
||||
let mut wrap_edits = edits.into_iter();
|
||||
let wrap_edits = if let Some(mut first_edit) = wrap_edits.next() {
|
||||
|
||||
if let Some(mut first_edit) = wrap_edits.next() {
|
||||
// This code relies on reusing allocations from the Vec<_> - at the time of writing .flatten() prevents them.
|
||||
#[allow(clippy::filter_map_identity)]
|
||||
let mut v: Vec<_> = wrap_edits
|
||||
@@ -1030,9 +1031,7 @@ fn consolidate_wrap_edits(edits: Vec<WrapEdit>) -> Vec<WrapEdit> {
|
||||
v
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
wrap_edits
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+89
-104
@@ -1003,11 +1003,11 @@ impl CompletionsMenu {
|
||||
cx,
|
||||
);
|
||||
|
||||
return cx.spawn(move |this, mut cx| async move {
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
if let Some(true) = resolve_task.await.log_err() {
|
||||
this.update(&mut cx, |_, cx| cx.notify()).ok();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
fn attempt_resolve_selected_completion_documentation(
|
||||
@@ -2350,7 +2350,7 @@ impl Editor {
|
||||
if let Some(show_inline_completions) = self.show_inline_completions_override {
|
||||
show_inline_completions
|
||||
} else {
|
||||
self.mode == EditorMode::Full && provider.is_enabled(&buffer, buffer_position, cx)
|
||||
self.mode == EditorMode::Full && provider.is_enabled(buffer, buffer_position, cx)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
@@ -2729,7 +2729,7 @@ impl Editor {
|
||||
|
||||
if !add || click_count > 1 {
|
||||
None
|
||||
} else if selected_points.len() > 0 {
|
||||
} else if !selected_points.is_empty() {
|
||||
Some(selected_points[0].id)
|
||||
} else {
|
||||
let clicked_point_already_selected =
|
||||
@@ -2738,17 +2738,13 @@ impl Editor {
|
||||
|| selection.end.to_point(buffer) == end.to_point(buffer)
|
||||
});
|
||||
|
||||
if let Some(selection) = clicked_point_already_selected {
|
||||
Some(selection.id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
clicked_point_already_selected.map(|selection| selection.id)
|
||||
}
|
||||
};
|
||||
|
||||
let selections_count = self.selections.count();
|
||||
|
||||
self.change_selections(auto_scroll.then(|| Autoscroll::newest()), cx, |s| {
|
||||
self.change_selections(auto_scroll.then(Autoscroll::newest), cx, |s| {
|
||||
if let Some(point_to_delete) = point_to_delete {
|
||||
s.delete(point_to_delete);
|
||||
|
||||
@@ -2981,10 +2977,10 @@ impl Editor {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.mode == EditorMode::Full {
|
||||
if self.change_selections(Some(Autoscroll::fit()), cx, |s| s.try_cancel()) {
|
||||
return;
|
||||
}
|
||||
if self.mode == EditorMode::Full
|
||||
&& self.change_selections(Some(Autoscroll::fit()), cx, |s| s.try_cancel())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cx.propagate();
|
||||
@@ -3023,11 +3019,9 @@ impl Editor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self.mode == EditorMode::Full {
|
||||
if self.active_diagnostics.is_some() {
|
||||
self.dismiss_diagnostics(cx);
|
||||
return true;
|
||||
}
|
||||
if self.mode == EditorMode::Full && self.active_diagnostics.is_some() {
|
||||
self.dismiss_diagnostics(cx);
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
@@ -3550,10 +3544,10 @@ impl Editor {
|
||||
.unwrap_or_default();
|
||||
let mut new_text =
|
||||
String::with_capacity(1 + capacity_for_delimiter + indent.len as usize);
|
||||
new_text.push_str("\n");
|
||||
new_text.push('\n');
|
||||
new_text.extend(indent.chars());
|
||||
if let Some(delimiter) = &comment_delimiter {
|
||||
new_text.push_str(&delimiter);
|
||||
new_text.push_str(delimiter);
|
||||
}
|
||||
if insert_extra_newline {
|
||||
new_text = new_text.repeat(2);
|
||||
@@ -4187,7 +4181,7 @@ impl Editor {
|
||||
};
|
||||
let trigger_kind = match (&options.trigger, is_followup_invoke) {
|
||||
(_, true) => CompletionTriggerKind::TRIGGER_FOR_INCOMPLETE_COMPLETIONS,
|
||||
(Some(trigger), _) if buffer.read(cx).completion_triggers().contains(&trigger) => {
|
||||
(Some(trigger), _) if buffer.read(cx).completion_triggers().contains(trigger) => {
|
||||
CompletionTriggerKind::TRIGGER_CHARACTER
|
||||
}
|
||||
|
||||
@@ -4627,33 +4621,30 @@ impl Editor {
|
||||
&& code_actions
|
||||
.as_ref()
|
||||
.map_or(true, |actions| actions.is_empty());
|
||||
if let Some(task) = editor
|
||||
.update(&mut cx, |editor, cx| {
|
||||
*editor.context_menu.write() =
|
||||
Some(ContextMenu::CodeActions(CodeActionsMenu {
|
||||
buffer,
|
||||
actions: CodeActionContents {
|
||||
tasks: resolved_tasks,
|
||||
actions: code_actions,
|
||||
},
|
||||
selected_item: Default::default(),
|
||||
scroll_handle: UniformListScrollHandle::default(),
|
||||
deployed_from_indicator,
|
||||
}));
|
||||
if spawn_straight_away {
|
||||
if let Some(task) = editor.confirm_code_action(
|
||||
&ConfirmCodeAction { item_ix: Some(0) },
|
||||
cx,
|
||||
) {
|
||||
cx.notify();
|
||||
return task;
|
||||
}
|
||||
if let Ok(task) = editor.update(&mut cx, |editor, cx| {
|
||||
*editor.context_menu.write() =
|
||||
Some(ContextMenu::CodeActions(CodeActionsMenu {
|
||||
buffer,
|
||||
actions: CodeActionContents {
|
||||
tasks: resolved_tasks,
|
||||
actions: code_actions,
|
||||
},
|
||||
selected_item: Default::default(),
|
||||
scroll_handle: UniformListScrollHandle::default(),
|
||||
deployed_from_indicator,
|
||||
}));
|
||||
if spawn_straight_away {
|
||||
if let Some(task) = editor.confirm_code_action(
|
||||
&ConfirmCodeAction { item_ix: Some(0) },
|
||||
cx,
|
||||
) {
|
||||
cx.notify();
|
||||
return task;
|
||||
}
|
||||
cx.notify();
|
||||
Task::ready(Ok(()))
|
||||
})
|
||||
.ok()
|
||||
{
|
||||
}
|
||||
cx.notify();
|
||||
Task::ready(Ok(()))
|
||||
}) {
|
||||
task.await
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -5257,7 +5248,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
fn insert_tasks(&mut self, key: (BufferId, BufferRow), value: RunnableTasks) {
|
||||
if let Some(_) = self.tasks.insert(key, value) {
|
||||
if self.tasks.insert(key, value).is_some() {
|
||||
// This case should hopefully be rare, but just in case...
|
||||
log::error!("multiple different run targets found on a single line, only the last target will be rendered")
|
||||
}
|
||||
@@ -6060,7 +6051,7 @@ impl Editor {
|
||||
Some(MultiBufferRow(0)..multi_buffer_snapshot.max_buffer_row()).into_iter(),
|
||||
&multi_buffer_snapshot,
|
||||
) {
|
||||
Self::prepare_revert_change(&mut revert_changes, &self.buffer(), &hunk, cx);
|
||||
Self::prepare_revert_change(&mut revert_changes, self.buffer(), &hunk, cx);
|
||||
}
|
||||
if !revert_changes.is_empty() {
|
||||
self.transact(cx, |editor, cx| {
|
||||
@@ -6634,7 +6625,7 @@ impl Editor {
|
||||
head = display_map.clip_point(head, Bias::Right);
|
||||
let goal = SelectionGoal::HorizontalPosition(
|
||||
display_map
|
||||
.x_for_display_point(head, &text_layout_details)
|
||||
.x_for_display_point(head, text_layout_details)
|
||||
.into(),
|
||||
);
|
||||
selection.collapse_to(head, goal);
|
||||
@@ -6967,7 +6958,7 @@ impl Editor {
|
||||
selection.start,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7003,7 +6994,7 @@ impl Editor {
|
||||
action.lines,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7034,7 +7025,7 @@ impl Editor {
|
||||
action.lines,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7045,7 +7036,7 @@ impl Editor {
|
||||
let text_layout_details = &self.text_layout_details(cx);
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::down_by_rows(map, head, action.lines, goal, false, &text_layout_details)
|
||||
movement::down_by_rows(map, head, action.lines, goal, false, text_layout_details)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -7054,7 +7045,7 @@ impl Editor {
|
||||
let text_layout_details = &self.text_layout_details(cx);
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::up_by_rows(map, head, action.lines, goal, false, &text_layout_details)
|
||||
movement::up_by_rows(map, head, action.lines, goal, false, text_layout_details)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -7068,7 +7059,7 @@ impl Editor {
|
||||
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::up_by_rows(map, head, row_count, goal, false, &text_layout_details)
|
||||
movement::up_by_rows(map, head, row_count, goal, false, text_layout_details)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -7117,7 +7108,7 @@ impl Editor {
|
||||
row_count,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7128,7 +7119,7 @@ impl Editor {
|
||||
let text_layout_details = &self.text_layout_details(cx);
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::up(map, head, goal, false, &text_layout_details)
|
||||
movement::up(map, head, goal, false, text_layout_details)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -7156,7 +7147,7 @@ impl Editor {
|
||||
selection.end,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7177,7 +7168,7 @@ impl Editor {
|
||||
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::down_by_rows(map, head, row_count, goal, false, &text_layout_details)
|
||||
movement::down_by_rows(map, head, row_count, goal, false, text_layout_details)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -7225,7 +7216,7 @@ impl Editor {
|
||||
row_count,
|
||||
selection.goal,
|
||||
false,
|
||||
&text_layout_details,
|
||||
text_layout_details,
|
||||
);
|
||||
selection.collapse_to(cursor, goal);
|
||||
});
|
||||
@@ -7236,7 +7227,7 @@ impl Editor {
|
||||
let text_layout_details = &self.text_layout_details(cx);
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_heads_with(|map, head, goal| {
|
||||
movement::down(map, head, goal, false, &text_layout_details)
|
||||
movement::down(map, head, goal, false, text_layout_details)
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -7919,12 +7910,12 @@ impl Editor {
|
||||
let query_match = query_match.unwrap(); // can only fail due to I/O
|
||||
let offset_range =
|
||||
start_offset + query_match.start()..start_offset + query_match.end();
|
||||
let display_range = offset_range.start.to_display_point(&display_map)
|
||||
..offset_range.end.to_display_point(&display_map);
|
||||
let display_range = offset_range.start.to_display_point(display_map)
|
||||
..offset_range.end.to_display_point(display_map);
|
||||
|
||||
if !select_next_state.wordwise
|
||||
|| (!movement::is_inside_word(&display_map, display_range.start)
|
||||
&& !movement::is_inside_word(&display_map, display_range.end))
|
||||
|| (!movement::is_inside_word(display_map, display_range.start)
|
||||
&& !movement::is_inside_word(display_map, display_range.end))
|
||||
{
|
||||
// TODO: This is n^2, because we might check all the selections
|
||||
if !selections
|
||||
@@ -7988,11 +7979,11 @@ impl Editor {
|
||||
if only_carets {
|
||||
for selection in &mut selections {
|
||||
let word_range = movement::surrounding_word(
|
||||
&display_map,
|
||||
selection.start.to_display_point(&display_map),
|
||||
display_map,
|
||||
selection.start.to_display_point(display_map),
|
||||
);
|
||||
selection.start = word_range.start.to_offset(&display_map, Bias::Left);
|
||||
selection.end = word_range.end.to_offset(&display_map, Bias::Left);
|
||||
selection.start = word_range.start.to_offset(display_map, Bias::Left);
|
||||
selection.end = word_range.end.to_offset(display_map, Bias::Left);
|
||||
selection.goal = SelectionGoal::None;
|
||||
selection.reversed = false;
|
||||
select_next_match_ranges(
|
||||
@@ -8525,7 +8516,7 @@ impl Editor {
|
||||
let display_point = point.to_display_point(display_snapshot);
|
||||
let goal = SelectionGoal::HorizontalPosition(
|
||||
display_snapshot
|
||||
.x_for_display_point(display_point, &text_layout_details)
|
||||
.x_for_display_point(display_point, text_layout_details)
|
||||
.into(),
|
||||
);
|
||||
(display_point, goal)
|
||||
@@ -8550,8 +8541,8 @@ impl Editor {
|
||||
let cursor = selection.head();
|
||||
let (_buffer_id, symbols) = buffer_snap.symbols_containing(cursor, None)?;
|
||||
for symbol in symbols.iter().rev() {
|
||||
let start = symbol.range.start.to_offset(&buffer_snap);
|
||||
let end = symbol.range.end.to_offset(&buffer_snap);
|
||||
let start = symbol.range.start.to_offset(buffer_snap);
|
||||
let end = symbol.range.end.to_offset(buffer_snap);
|
||||
let new_range = start..end;
|
||||
if start < selection.start || end > selection.end {
|
||||
return Some(Selection {
|
||||
@@ -8836,12 +8827,10 @@ impl Editor {
|
||||
} else {
|
||||
open.start
|
||||
}
|
||||
} else if inside {
|
||||
*close.start()
|
||||
} else {
|
||||
if inside {
|
||||
*close.start()
|
||||
} else {
|
||||
*close.end()
|
||||
}
|
||||
*close.end()
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -8912,7 +8901,7 @@ impl Editor {
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
buffer.expand_excerpts(
|
||||
selections
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|selection| selection.head().excerpt_id)
|
||||
.dedup(),
|
||||
lines,
|
||||
@@ -9109,7 +9098,7 @@ impl Editor {
|
||||
) -> bool {
|
||||
let display_point = initial_point.to_display_point(snapshot);
|
||||
let mut hunks = hunks
|
||||
.map(|hunk| diff_hunk_to_display(&hunk, &snapshot))
|
||||
.map(|hunk| diff_hunk_to_display(&hunk, snapshot))
|
||||
.filter(|hunk| is_wrapped || !hunk.contains_display_row(display_point.row()))
|
||||
.dedup();
|
||||
|
||||
@@ -9790,9 +9779,10 @@ impl Editor {
|
||||
}
|
||||
editor
|
||||
});
|
||||
cx.subscribe(&rename_editor, |_, _, e, cx| match e {
|
||||
EditorEvent::Focused => cx.emit(EditorEvent::FocusedIn),
|
||||
_ => {}
|
||||
cx.subscribe(&rename_editor, |_, _, e: &EditorEvent, cx| {
|
||||
if e == &EditorEvent::Focused {
|
||||
cx.emit(EditorEvent::FocusedIn)
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
@@ -10579,9 +10569,7 @@ impl Editor {
|
||||
|
||||
pub fn soft_wrap_mode(&self, cx: &AppContext) -> SoftWrap {
|
||||
let settings = self.buffer.read(cx).settings_at(0, cx);
|
||||
let mode = self
|
||||
.soft_wrap_mode_override
|
||||
.unwrap_or_else(|| settings.soft_wrap);
|
||||
let mode = self.soft_wrap_mode_override.unwrap_or(settings.soft_wrap);
|
||||
match mode {
|
||||
language_settings::SoftWrap::None => SoftWrap::None,
|
||||
language_settings::SoftWrap::PreferLine => SoftWrap::PreferLine,
|
||||
@@ -11046,8 +11034,8 @@ impl Editor {
|
||||
highlight
|
||||
.range
|
||||
.start()
|
||||
.cmp(&rows.start(), &snapshot)
|
||||
.then(highlight.range.end().cmp(&rows.end(), &snapshot))
|
||||
.cmp(rows.start(), &snapshot)
|
||||
.then(highlight.range.end().cmp(rows.end(), &snapshot))
|
||||
});
|
||||
match (color, existing_highlight_index) {
|
||||
(Some(_), Ok(ix)) | (_, Err(ix)) => row_highlights.insert(
|
||||
@@ -11126,7 +11114,7 @@ impl Editor {
|
||||
if highlight.color.is_none() || !highlight.should_autoscroll {
|
||||
return None;
|
||||
}
|
||||
Some(highlight.range.start().to_display_point(&snapshot).row())
|
||||
Some(highlight.range.start().to_display_point(snapshot).row())
|
||||
})
|
||||
.min()
|
||||
}
|
||||
@@ -11300,8 +11288,8 @@ impl Editor {
|
||||
break;
|
||||
}
|
||||
|
||||
let start = range.start.to_display_point(&display_snapshot);
|
||||
let end = range.end.to_display_point(&display_snapshot);
|
||||
let start = range.start.to_display_point(display_snapshot);
|
||||
let end = range.end.to_display_point(display_snapshot);
|
||||
results.push((start..end, color))
|
||||
}
|
||||
}
|
||||
@@ -11413,8 +11401,8 @@ impl Editor {
|
||||
break;
|
||||
}
|
||||
|
||||
let start = range.start.to_display_point(&display_snapshot);
|
||||
let end = range.end.to_display_point(&display_snapshot);
|
||||
let start = range.start.to_display_point(display_snapshot);
|
||||
let end = range.end.to_display_point(display_snapshot);
|
||||
results.push((start..end, color))
|
||||
}
|
||||
}
|
||||
@@ -12168,8 +12156,8 @@ fn hunks_for_selections(
|
||||
let buffer_rows_for_selections = selections.iter().map(|selection| {
|
||||
let head = selection.head();
|
||||
let tail = selection.tail();
|
||||
let start = MultiBufferRow(tail.to_point(&multi_buffer_snapshot).row);
|
||||
let end = MultiBufferRow(head.to_point(&multi_buffer_snapshot).row);
|
||||
let start = MultiBufferRow(tail.to_point(multi_buffer_snapshot).row);
|
||||
let end = MultiBufferRow(head.to_point(multi_buffer_snapshot).row);
|
||||
if start > end {
|
||||
end..start
|
||||
} else {
|
||||
@@ -12349,10 +12337,7 @@ fn snippet_completions(
|
||||
filter_range: 0..matching_prefix.len(),
|
||||
},
|
||||
server_id: LanguageServerId(usize::MAX),
|
||||
documentation: snippet
|
||||
.description
|
||||
.clone()
|
||||
.map(|description| Documentation::SingleLine(description)),
|
||||
documentation: snippet.description.clone().map(Documentation::SingleLine),
|
||||
lsp_completion: lsp::CompletionItem {
|
||||
label: snippet.prefix.first().unwrap().clone(),
|
||||
kind: Some(CompletionItemKind::SNIPPET),
|
||||
@@ -12390,7 +12375,7 @@ impl CompletionProvider for Model<Project> {
|
||||
) -> Task<Result<Vec<Completion>>> {
|
||||
self.update(cx, |project, cx| {
|
||||
let snippets = snippet_completions(project, buffer, buffer_position, cx);
|
||||
let project_completions = project.completions(&buffer, buffer_position, options, cx);
|
||||
let project_completions = project.completions(buffer, buffer_position, options, cx);
|
||||
cx.background_executor().spawn(async move {
|
||||
let mut completions = project_completions.await?;
|
||||
//let snippets = snippets.into_iter().;
|
||||
@@ -12847,7 +12832,7 @@ impl ViewInputHandler for Editor {
|
||||
|
||||
fn marked_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>> {
|
||||
let snapshot = self.buffer.read(cx).read(cx);
|
||||
let range = self.text_highlights::<InputComposition>(cx)?.1.get(0)?;
|
||||
let range = self.text_highlights::<InputComposition>(cx)?.1.first()?;
|
||||
Some(range.start.to_offset_utf16(&snapshot).0..range.end.to_offset_utf16(&snapshot).0)
|
||||
}
|
||||
|
||||
@@ -13276,7 +13261,7 @@ pub fn highlight_diagnostic_message(
|
||||
let mut code_ranges = Vec::new();
|
||||
|
||||
if let Some(source) = &diagnostic.source {
|
||||
text_without_backticks.push_str(&source);
|
||||
text_without_backticks.push_str(source);
|
||||
code_ranges.push(0..source.len());
|
||||
text_without_backticks.push_str(": ");
|
||||
}
|
||||
@@ -13415,7 +13400,7 @@ pub trait RangeToAnchorExt: Sized {
|
||||
|
||||
fn to_display_points(self, snapshot: &EditorSnapshot) -> Range<DisplayPoint> {
|
||||
let anchor_range = self.to_anchors(&snapshot.buffer_snapshot);
|
||||
anchor_range.start.to_display_point(&snapshot)..anchor_range.end.to_display_point(&snapshot)
|
||||
anchor_range.start.to_display_point(snapshot)..anchor_range.end.to_display_point(snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ use crate::EditorSettings;
|
||||
#[derive(IntoElement)]
|
||||
pub struct EditorSettingsControls {}
|
||||
|
||||
impl Default for EditorSettingsControls {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl EditorSettingsControls {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
@@ -235,13 +241,7 @@ impl EditableSettingControl for BufferFontLigaturesControl {
|
||||
let mut features = settings
|
||||
.buffer_font_features
|
||||
.as_ref()
|
||||
.map(|features| {
|
||||
features
|
||||
.tag_value_list()
|
||||
.into_iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.map(|features| features.tag_value_list().to_vec())
|
||||
.unwrap_or_default();
|
||||
|
||||
if let Some(calt_index) = features.iter().position(|(tag, _)| tag == "calt") {
|
||||
|
||||
@@ -195,7 +195,7 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
|
||||
editor.change_selections(None, cx, |s| s.select_ranges([2..2]));
|
||||
|
||||
// Simulate an edit in another editor
|
||||
_ = buffer.update(cx, |buffer, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.start_transaction_at(now, cx);
|
||||
buffer.edit([(0..1, "a")], None, cx);
|
||||
buffer.edit([(1..1, "b")], None, cx);
|
||||
@@ -661,7 +661,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
let handle = cx.view();
|
||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
|
||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(handle)));
|
||||
|
||||
fn pop_history(editor: &mut Editor, cx: &mut WindowContext) -> Option<NavigationEntry> {
|
||||
editor.nav_history.as_mut().unwrap().pop_backward(cx)
|
||||
@@ -1088,7 +1088,7 @@ fn test_move_cursor(cx: &mut TestAppContext) {
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx));
|
||||
let view = cx.add_window(|cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
_ = buffer.update(cx, |buffer, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.edit(
|
||||
vec![
|
||||
(Point::new(1, 0)..Point::new(1, 0), "\t"),
|
||||
@@ -1822,7 +1822,7 @@ async fn test_scroll_page_up_page_down(cx: &mut gpui::TestAppContext) {
|
||||
cx.simulate_window_resize(window, size(px(1000.), 4. * line_height + px(0.5)));
|
||||
|
||||
cx.set_state(
|
||||
&r#"ˇone
|
||||
r#"ˇone
|
||||
two
|
||||
three
|
||||
four
|
||||
@@ -1886,7 +1886,7 @@ async fn test_autoscroll(cx: &mut gpui::TestAppContext) {
|
||||
cx.simulate_window_resize(window, size(px(1000.), 6. * line_height));
|
||||
|
||||
cx.set_state(
|
||||
&r#"ˇone
|
||||
r#"ˇone
|
||||
two
|
||||
three
|
||||
four
|
||||
@@ -4650,17 +4650,8 @@ let foo = «2ˇ»;"#,
|
||||
async fn test_select_previous_multibuffer(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
||||
let mut cx = EditorTestContext::new_multibuffer(
|
||||
cx,
|
||||
[
|
||||
&indoc! {
|
||||
"aaa\n«bbb\nccc\n»ddd"
|
||||
},
|
||||
&indoc! {
|
||||
"aaa\n«bbb\nccc\n»ddd"
|
||||
},
|
||||
],
|
||||
);
|
||||
let mut cx =
|
||||
EditorTestContext::new_multibuffer(cx, ["aaa\n«bbb\nccc\n»ddd", "aaa\n«bbb\nccc\n»ddd"]);
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
ˇbbb
|
||||
@@ -4809,7 +4800,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
|
||||
editor
|
||||
.condition::<crate::EditorEvent>(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
editor.update(cx, |view, cx| {
|
||||
@@ -5021,7 +5012,7 @@ async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
|
||||
.condition::<crate::EditorEvent>(cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.change_selections(None, cx, |s| s.select_ranges([5..5, 8..8, 9..9]));
|
||||
editor.newline(&Newline, cx);
|
||||
assert_eq!(editor.text(cx), "fn a(\n \n) {\n \n}\n");
|
||||
@@ -5702,7 +5693,7 @@ async fn test_surround_with_pair(cx: &mut gpui::TestAppContext) {
|
||||
view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
_ = view.update(cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 1),
|
||||
@@ -5852,7 +5843,7 @@ async fn test_delete_autoclose_pair(cx: &mut gpui::TestAppContext) {
|
||||
.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.select_ranges([
|
||||
Point::new(0, 1)..Point::new(0, 1),
|
||||
@@ -6042,7 +6033,7 @@ async fn test_auto_replace_emoji_shortcode(cx: &mut gpui::TestAppContext) {
|
||||
.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.set_auto_replace_emoji_shortcode(true);
|
||||
|
||||
editor.handle_input("Hello ", cx);
|
||||
@@ -6111,7 +6102,7 @@ async fn test_snippets(cx: &mut gpui::TestAppContext) {
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
let snippet = Snippet::parse("f(${1:one}, ${2:two}, ${1:three})$0").unwrap();
|
||||
|
||||
editor
|
||||
@@ -6738,7 +6729,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
|
||||
let format = editor
|
||||
.update(cx, |editor, cx| {
|
||||
@@ -6766,7 +6757,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) {
|
||||
"one, two\nthree\n"
|
||||
);
|
||||
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx));
|
||||
// Ensure we don't lock if formatting hangs.
|
||||
fake_server.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||
assert_eq!(
|
||||
@@ -7765,7 +7756,7 @@ async fn test_completion(cx: &mut gpui::TestAppContext) {
|
||||
handle_resolve_completion_request(&mut cx, None).await;
|
||||
apply_additional_edits.await.unwrap();
|
||||
|
||||
_ = cx.update(|cx| {
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.show_completions_on_input = Some(false);
|
||||
@@ -8371,7 +8362,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) {
|
||||
});
|
||||
|
||||
let (view, cx) = cx.add_window_view(|cx| build_editor(multibuffer, cx));
|
||||
_ = view.update(cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
assert_eq!(view.text(cx), "aaaa\nbbbb");
|
||||
view.change_selections(None, cx, |s| {
|
||||
s.select_ranges([
|
||||
@@ -8441,7 +8432,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
|
||||
});
|
||||
|
||||
let (view, cx) = cx.add_window_view(|cx| build_editor(multibuffer, cx));
|
||||
_ = view.update(cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
let (expected_text, selection_ranges) = marked_text_ranges(
|
||||
indoc! {"
|
||||
aaaa
|
||||
@@ -8545,7 +8536,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) {
|
||||
);
|
||||
});
|
||||
|
||||
_ = multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.remove_excerpts([excerpt1_id.unwrap()], cx);
|
||||
});
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
@@ -8612,7 +8603,7 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) {
|
||||
editor
|
||||
});
|
||||
|
||||
_ = multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.remove_excerpts([excerpt1_id.unwrap()], cx);
|
||||
});
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
@@ -8679,7 +8670,7 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
||||
view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
_ = view.update(cx, |view, cx| {
|
||||
view.update(cx, |view, cx| {
|
||||
view.change_selections(None, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(0), 2)..DisplayPoint::new(DisplayRow(0), 3),
|
||||
@@ -8864,7 +8855,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
_ = follower.update(cx, |follower, cx| {
|
||||
assert_eq!(follower.selections.ranges(cx), vec![1..1]);
|
||||
});
|
||||
assert_eq!(*is_still_following.borrow(), true);
|
||||
assert!(*is_still_following.borrow());
|
||||
assert_eq!(*follower_edit_event_count.borrow(), 0);
|
||||
|
||||
// Update the scroll position only
|
||||
@@ -8884,7 +8875,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
.unwrap(),
|
||||
gpui::Point::new(1.5, 3.5)
|
||||
);
|
||||
assert_eq!(*is_still_following.borrow(), true);
|
||||
assert!(*is_still_following.borrow());
|
||||
assert_eq!(*follower_edit_event_count.borrow(), 0);
|
||||
|
||||
// Update the selections and scroll position. The follower's scroll position is updated
|
||||
@@ -8905,7 +8896,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
assert_eq!(follower.scroll_position(cx), gpui::Point::new(1.5, 0.0));
|
||||
assert_eq!(follower.selections.ranges(cx), vec![0..0]);
|
||||
});
|
||||
assert_eq!(*is_still_following.borrow(), true);
|
||||
assert!(*is_still_following.borrow());
|
||||
|
||||
// Creating a pending selection that precedes another selection
|
||||
_ = leader.update(cx, |leader, cx| {
|
||||
@@ -8922,7 +8913,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
_ = follower.update(cx, |follower, cx| {
|
||||
assert_eq!(follower.selections.ranges(cx), vec![0..0, 1..1]);
|
||||
});
|
||||
assert_eq!(*is_still_following.borrow(), true);
|
||||
assert!(*is_still_following.borrow());
|
||||
|
||||
// Extend the pending selection so that it surrounds another selection
|
||||
_ = leader.update(cx, |leader, cx| {
|
||||
@@ -8950,7 +8941,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
|
||||
cx,
|
||||
);
|
||||
});
|
||||
assert_eq!(*is_still_following.borrow(), false);
|
||||
assert!(!(*is_still_following.borrow()));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
@@ -9011,7 +9002,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
||||
});
|
||||
|
||||
// Insert some excerpts.
|
||||
_ = leader.update(cx, |leader, cx| {
|
||||
leader.update(cx, |leader, cx| {
|
||||
leader.buffer.update(cx, |multibuffer, cx| {
|
||||
let excerpt_ids = multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
@@ -9086,7 +9077,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
||||
);
|
||||
|
||||
// Remove some excerpts.
|
||||
_ = leader.update(cx, |leader, cx| {
|
||||
leader.update(cx, |leader, cx| {
|
||||
leader.buffer.update(cx, |multibuffer, cx| {
|
||||
let excerpt_ids = multibuffer.excerpt_ids();
|
||||
multibuffer.remove_excerpts([excerpt_ids[1], excerpt_ids[2]], cx);
|
||||
@@ -9129,8 +9120,8 @@ async fn go_to_prev_overlapping_diagnostic(
|
||||
}
|
||||
"});
|
||||
|
||||
_ = cx.update(|cx| {
|
||||
_ = project.update(cx, |project, cx| {
|
||||
cx.update(|cx| {
|
||||
project.update(cx, |project, cx| {
|
||||
project
|
||||
.update_diagnostics(
|
||||
LanguageServerId(0),
|
||||
@@ -9568,7 +9559,7 @@ async fn test_on_type_formatting_not_triggered(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
cx.executor().run_until_parked();
|
||||
|
||||
_ = buffer.update(cx, |buffer, _| {
|
||||
buffer.update(cx, |buffer, _| {
|
||||
assert_eq!(
|
||||
buffer.text(),
|
||||
"fn main() { let a = {5}; }",
|
||||
@@ -9971,7 +9962,7 @@ async fn test_document_format_with_prettier(cx: &mut gpui::TestAppContext) {
|
||||
let buffer_text = "one\ntwo\nthree\n";
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
|
||||
_ = editor.update(cx, |editor, cx| editor.set_text(buffer_text, cx));
|
||||
editor.update(cx, |editor, cx| editor.set_text(buffer_text, cx));
|
||||
|
||||
editor
|
||||
.update(cx, |editor, cx| {
|
||||
@@ -10913,7 +10904,7 @@ async fn test_toggle_hunk_diff(executor: BackgroundExecutor, cx: &mut gpui::Test
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(1)..=DisplayRow(1), DisplayRow(7)..=DisplayRow(7), DisplayRow(9)..=DisplayRow(9)],
|
||||
@@ -11058,7 +11049,7 @@ async fn test_toggled_diff_base_change(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(9)..=DisplayRow(10), DisplayRow(13)..=DisplayRow(14)],
|
||||
@@ -11240,7 +11231,7 @@ async fn test_fold_unfold_diff(executor: BackgroundExecutor, cx: &mut gpui::Test
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![
|
||||
@@ -11317,7 +11308,7 @@ async fn test_fold_unfold_diff(executor: BackgroundExecutor, cx: &mut gpui::Test
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(0)..=DisplayRow(0), DisplayRow(5)..=DisplayRow(5)],
|
||||
@@ -11410,7 +11401,7 @@ async fn test_fold_unfold_diff(executor: BackgroundExecutor, cx: &mut gpui::Test
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![
|
||||
@@ -11622,7 +11613,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
||||
multi_buffer_editor.update(cx, |editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
|
||||
assert_eq!(all_hunks, expected_all_hunks);
|
||||
assert_eq!(all_expanded_hunks, Vec::new());
|
||||
@@ -11636,7 +11627,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
||||
multi_buffer_editor.update(cx, |editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![
|
||||
@@ -11655,7 +11646,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
||||
multi_buffer_editor.update(cx, |editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
|
||||
assert_eq!(all_hunks, expected_all_hunks);
|
||||
assert_eq!(all_expanded_hunks, Vec::new());
|
||||
@@ -11668,7 +11659,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
||||
multi_buffer_editor.update(cx, |editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![
|
||||
@@ -11687,7 +11678,7 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut gpui::TestAppContext)
|
||||
multi_buffer_editor.update(cx, |editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
|
||||
assert_eq!(all_hunks, expected_all_hunks);
|
||||
assert_eq!(all_expanded_hunks, Vec::new());
|
||||
@@ -11775,7 +11766,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -11815,7 +11806,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -11860,7 +11851,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -11904,7 +11895,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -11952,7 +11943,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -11988,7 +11979,7 @@ async fn test_edits_around_toggled_additions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![
|
||||
@@ -12103,7 +12094,7 @@ async fn test_edits_around_toggled_deletions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
@@ -12139,7 +12130,7 @@ async fn test_edits_around_toggled_deletions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
Vec::new(),
|
||||
@@ -12178,7 +12169,7 @@ async fn test_edits_around_toggled_deletions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(expanded_hunks_background_highlights(editor, cx), Vec::new());
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
@@ -12213,7 +12204,7 @@ async fn test_edits_around_toggled_deletions(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
all_hunks,
|
||||
vec![(
|
||||
@@ -12315,7 +12306,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(6)],
|
||||
@@ -12358,7 +12349,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(6)],
|
||||
@@ -12404,7 +12395,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(8)],
|
||||
@@ -12448,7 +12439,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(9)],
|
||||
@@ -12492,7 +12483,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(8)],
|
||||
@@ -12533,7 +12524,7 @@ async fn test_edits_around_toggled_modifications(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
Vec::new(),
|
||||
@@ -12636,7 +12627,7 @@ async fn test_multiple_expanded_hunks_merge(
|
||||
cx.update_editor(|editor, cx| {
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let all_hunks = editor_hunks(editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(&editor, &snapshot, cx);
|
||||
let all_expanded_hunks = expanded_hunks(editor, &snapshot, cx);
|
||||
assert_eq!(
|
||||
expanded_hunks_background_highlights(editor, cx),
|
||||
vec![DisplayRow(6)..=DisplayRow(6)],
|
||||
@@ -12689,8 +12680,8 @@ async fn setup_indent_guides_editor(
|
||||
let buffer_id = cx.update_editor(|editor, cx| {
|
||||
editor.set_text(text, cx);
|
||||
let buffer_ids = editor.buffer().read(cx).excerpt_buffer_ids();
|
||||
let buffer_id = buffer_ids[0];
|
||||
buffer_id
|
||||
|
||||
buffer_ids[0]
|
||||
});
|
||||
|
||||
(buffer_id, cx)
|
||||
@@ -13249,7 +13240,7 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) {
|
||||
|
||||
let render_args = render_args.lock().take().unwrap();
|
||||
assert_eq!(render_args.row, MultiBufferRow(1));
|
||||
assert_eq!(render_args.folded, false);
|
||||
assert!(!render_args.folded);
|
||||
assert!(!snapshot.is_line_folded(MultiBufferRow(1)));
|
||||
|
||||
cx.update_window(*editor, |_, cx| (render_args.callback)(true, cx))
|
||||
@@ -13616,7 +13607,7 @@ pub(crate) fn update_test_language_settings(
|
||||
cx: &mut TestAppContext,
|
||||
f: impl Fn(&mut AllLanguageSettingsContent),
|
||||
) {
|
||||
_ = cx.update(|cx| {
|
||||
cx.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, f);
|
||||
});
|
||||
@@ -13627,7 +13618,7 @@ pub(crate) fn update_test_project_settings(
|
||||
cx: &mut TestAppContext,
|
||||
f: impl Fn(&mut ProjectSettings),
|
||||
) {
|
||||
_ = cx.update(|cx| {
|
||||
cx.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<ProjectSettings>(cx, f);
|
||||
});
|
||||
@@ -13635,7 +13626,7 @@ pub(crate) fn update_test_project_settings(
|
||||
}
|
||||
|
||||
pub(crate) fn init_test(cx: &mut TestAppContext, f: fn(&mut AllLanguageSettingsContent)) {
|
||||
_ = cx.update(|cx| {
|
||||
cx.update(|cx| {
|
||||
assets::Assets.load_test_fonts(cx);
|
||||
let store = SettingsStore::test(cx);
|
||||
cx.set_global(store);
|
||||
|
||||
+96
-117
@@ -241,7 +241,7 @@ impl EditorElement {
|
||||
if text.is_empty() {
|
||||
return;
|
||||
}
|
||||
editor.handle_input(&text, cx);
|
||||
editor.handle_input(text, cx);
|
||||
});
|
||||
register_action(view, cx, |editor, _: &HalfPageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-0.5), cx)
|
||||
@@ -652,30 +652,11 @@ impl EditorElement {
|
||||
cx.stop_propagation();
|
||||
} else if end_selection && pending_nonempty_selections {
|
||||
cx.stop_propagation();
|
||||
} else if cfg!(target_os = "linux") && event.button == MouseButton::Middle {
|
||||
if !text_hitbox.is_hovered(cx) || editor.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
if EditorSettings::get_global(cx).middle_click_paste {
|
||||
if let Some(text) = cx.read_from_primary().and_then(|item| item.text()) {
|
||||
let point_for_position =
|
||||
position_map.point_for_position(text_hitbox.bounds, event.position);
|
||||
let position = point_for_position.previous_valid;
|
||||
|
||||
editor.select(
|
||||
SelectPhase::Begin {
|
||||
position,
|
||||
add: false,
|
||||
click_count: 1,
|
||||
},
|
||||
cx,
|
||||
);
|
||||
editor.insert(&text, cx);
|
||||
}
|
||||
cx.stop_propagation()
|
||||
}
|
||||
} else if cfg!(target_os = "linux")
|
||||
&& event.button == MouseButton::Middle
|
||||
&& (!text_hitbox.is_hovered(cx) || editor.read_only(cx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1315,7 +1296,7 @@ impl EditorElement {
|
||||
let hitbox = match hunk {
|
||||
DisplayDiffHunk::Unfolded { .. } => {
|
||||
let hunk_bounds = Self::diff_hunk_bounds(
|
||||
&snapshot,
|
||||
snapshot,
|
||||
line_height,
|
||||
gutter_hitbox.bounds,
|
||||
&hunk,
|
||||
@@ -1610,7 +1591,7 @@ impl EditorElement {
|
||||
.tasks
|
||||
.as_ref()
|
||||
.map(|tasks| tasks.position.to_display_point(snapshot).row())
|
||||
.or_else(|| *deployed_from_indicator)
|
||||
.or(*deployed_from_indicator)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -2794,7 +2775,7 @@ impl EditorElement {
|
||||
let hover_popovers = self.editor.update(cx, |editor, cx| {
|
||||
editor
|
||||
.hover_state
|
||||
.render(&snapshot, visible_display_row_range.clone(), max_size, cx)
|
||||
.render(snapshot, visible_display_row_range.clone(), max_size, cx)
|
||||
});
|
||||
let Some((position, hover_popovers)) = hover_popovers else {
|
||||
return;
|
||||
@@ -3199,7 +3180,7 @@ impl EditorElement {
|
||||
&layout.position_map.snapshot,
|
||||
line_height,
|
||||
layout.gutter_hitbox.bounds,
|
||||
&hunk,
|
||||
hunk,
|
||||
);
|
||||
Some((
|
||||
hunk_bounds,
|
||||
@@ -3454,7 +3435,7 @@ impl EditorElement {
|
||||
let corner_radius = 0.15 * layout.position_map.line_height;
|
||||
|
||||
for (player_color, selections) in &layout.selections {
|
||||
for selection in selections.into_iter() {
|
||||
for selection in selections.iter() {
|
||||
self.paint_highlighted_range(
|
||||
selection.range.clone(),
|
||||
player_color.selection,
|
||||
@@ -3772,20 +3753,18 @@ impl EditorElement {
|
||||
if is_symbol_occurrences {
|
||||
color.fade_out(0.5);
|
||||
}
|
||||
let marker_row_ranges =
|
||||
background_ranges.into_iter().map(|range| {
|
||||
let display_start = range
|
||||
.start
|
||||
.to_display_point(&snapshot.display_snapshot);
|
||||
let display_end = range
|
||||
.end
|
||||
.to_display_point(&snapshot.display_snapshot);
|
||||
ColoredRange {
|
||||
start: display_start.row(),
|
||||
end: display_end.row(),
|
||||
color,
|
||||
}
|
||||
});
|
||||
let marker_row_ranges = background_ranges.iter().map(|range| {
|
||||
let display_start = range
|
||||
.start
|
||||
.to_display_point(&snapshot.display_snapshot);
|
||||
let display_end =
|
||||
range.end.to_display_point(&snapshot.display_snapshot);
|
||||
ColoredRange {
|
||||
start: display_start.row(),
|
||||
end: display_end.row(),
|
||||
color,
|
||||
}
|
||||
});
|
||||
marker_quads.extend(
|
||||
scrollbar_layout
|
||||
.marker_quads_for_ranges(marker_row_ranges, Some(1)),
|
||||
@@ -4608,7 +4587,7 @@ impl LineWithInvisibles {
|
||||
}
|
||||
|
||||
self.draw_invisibles(
|
||||
&selection_ranges,
|
||||
selection_ranges,
|
||||
layout,
|
||||
content_origin,
|
||||
line_y,
|
||||
@@ -4661,7 +4640,7 @@ impl LineWithInvisibles {
|
||||
|
||||
let invisible_iter = self.invisibles.iter().map(extract_whitespace_info);
|
||||
match whitespace_setting {
|
||||
ShowWhitespaceSetting::None => return,
|
||||
ShowWhitespaceSetting::None => (),
|
||||
ShowWhitespaceSetting::All => invisible_iter.for_each(|(_, paint)| paint(cx)),
|
||||
ShowWhitespaceSetting::Selection => invisible_iter.for_each(|([start, _], paint)| {
|
||||
let invisible_point = DisplayPoint::new(row, start as u32);
|
||||
@@ -4717,7 +4696,7 @@ impl LineWithInvisibles {
|
||||
last_seen = Some((should_render, end, paint));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn x_for_index(&self, index: usize) -> Pixels {
|
||||
@@ -5452,7 +5431,7 @@ impl Element for EditorElement {
|
||||
|
||||
let show_code_actions = snapshot
|
||||
.show_code_actions
|
||||
.unwrap_or_else(|| gutter_settings.code_actions);
|
||||
.unwrap_or(gutter_settings.code_actions);
|
||||
if show_code_actions {
|
||||
let newest_selection_point =
|
||||
newest_selection_head.to_point(&snapshot.display_snapshot);
|
||||
@@ -6273,6 +6252,73 @@ fn scale_horizontal_mouse_autoscroll_delta(delta: Pixels) -> f32 {
|
||||
(delta.pow(1.2) / 300.0).into()
|
||||
}
|
||||
|
||||
pub fn register_action<T: Action>(
|
||||
view: &View<Editor>,
|
||||
cx: &mut WindowContext,
|
||||
listener: impl Fn(&mut Editor, &T, &mut ViewContext<Editor>) + 'static,
|
||||
) {
|
||||
let view = view.clone();
|
||||
cx.on_action(TypeId::of::<T>(), move |action, phase, cx| {
|
||||
let action = action.downcast_ref().unwrap();
|
||||
if phase == DispatchPhase::Bubble {
|
||||
view.update(cx, |editor, cx| {
|
||||
listener(editor, action, cx);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn compute_auto_height_layout(
|
||||
editor: &mut Editor,
|
||||
max_lines: usize,
|
||||
max_line_number_width: Pixels,
|
||||
known_dimensions: Size<Option<Pixels>>,
|
||||
available_width: AvailableSpace,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Option<Size<Pixels>> {
|
||||
let width = known_dimensions.width.or({
|
||||
if let AvailableSpace::Definite(available_width) = available_width {
|
||||
Some(available_width)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})?;
|
||||
if let Some(height) = known_dimensions.height {
|
||||
return Some(size(width, height));
|
||||
}
|
||||
|
||||
let style = editor.style.as_ref().unwrap();
|
||||
let font_id = cx.text_system().resolve_font(&style.text.font());
|
||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||
let em_width = cx
|
||||
.text_system()
|
||||
.typographic_bounds(font_id, font_size, 'm')
|
||||
.unwrap()
|
||||
.size
|
||||
.width;
|
||||
|
||||
let mut snapshot = editor.snapshot(cx);
|
||||
let gutter_dimensions =
|
||||
snapshot.gutter_dimensions(font_id, font_size, em_width, max_line_number_width, cx);
|
||||
|
||||
editor.gutter_dimensions = gutter_dimensions;
|
||||
let text_width = width - gutter_dimensions.width;
|
||||
let overscroll = size(em_width, px(0.));
|
||||
|
||||
let editor_width = text_width - gutter_dimensions.margin - overscroll.width - em_width;
|
||||
if editor.set_wrap_width(Some(editor_width), cx) {
|
||||
snapshot = editor.snapshot(cx);
|
||||
}
|
||||
|
||||
let scroll_height = Pixels::from(snapshot.max_point().row().next_row().0) * line_height;
|
||||
let height = scroll_height
|
||||
.max(line_height)
|
||||
.min(line_height * max_lines as f32);
|
||||
|
||||
Some(size(width, height))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -6605,7 +6651,7 @@ mod tests {
|
||||
});
|
||||
|
||||
let actual_invisibles =
|
||||
collect_invisibles_from_new_editor(cx, EditorMode::Full, &input_text, px(500.0));
|
||||
collect_invisibles_from_new_editor(cx, EditorMode::Full, input_text, px(500.0));
|
||||
|
||||
assert_eq!(expected_invisibles, actual_invisibles);
|
||||
}
|
||||
@@ -6730,7 +6776,7 @@ mod tests {
|
||||
editor_width.0
|
||||
);
|
||||
let window = cx.add_window(|cx| {
|
||||
let buffer = MultiBuffer::build_simple(&input_text, cx);
|
||||
let buffer = MultiBuffer::build_simple(input_text, cx);
|
||||
Editor::new(editor_mode, buffer, None, true, cx)
|
||||
});
|
||||
let cx = &mut VisualTestContext::from_window(*window, cx);
|
||||
@@ -6754,70 +6800,3 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_action<T: Action>(
|
||||
view: &View<Editor>,
|
||||
cx: &mut WindowContext,
|
||||
listener: impl Fn(&mut Editor, &T, &mut ViewContext<Editor>) + 'static,
|
||||
) {
|
||||
let view = view.clone();
|
||||
cx.on_action(TypeId::of::<T>(), move |action, phase, cx| {
|
||||
let action = action.downcast_ref().unwrap();
|
||||
if phase == DispatchPhase::Bubble {
|
||||
view.update(cx, |editor, cx| {
|
||||
listener(editor, action, cx);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn compute_auto_height_layout(
|
||||
editor: &mut Editor,
|
||||
max_lines: usize,
|
||||
max_line_number_width: Pixels,
|
||||
known_dimensions: Size<Option<Pixels>>,
|
||||
available_width: AvailableSpace,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Option<Size<Pixels>> {
|
||||
let width = known_dimensions.width.or_else(|| {
|
||||
if let AvailableSpace::Definite(available_width) = available_width {
|
||||
Some(available_width)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})?;
|
||||
if let Some(height) = known_dimensions.height {
|
||||
return Some(size(width, height));
|
||||
}
|
||||
|
||||
let style = editor.style.as_ref().unwrap();
|
||||
let font_id = cx.text_system().resolve_font(&style.text.font());
|
||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||
let em_width = cx
|
||||
.text_system()
|
||||
.typographic_bounds(font_id, font_size, 'm')
|
||||
.unwrap()
|
||||
.size
|
||||
.width;
|
||||
|
||||
let mut snapshot = editor.snapshot(cx);
|
||||
let gutter_dimensions =
|
||||
snapshot.gutter_dimensions(font_id, font_size, em_width, max_line_number_width, cx);
|
||||
|
||||
editor.gutter_dimensions = gutter_dimensions;
|
||||
let text_width = width - gutter_dimensions.width;
|
||||
let overscroll = size(em_width, px(0.));
|
||||
|
||||
let editor_width = text_width - gutter_dimensions.margin - overscroll.width - em_width;
|
||||
if editor.set_wrap_width(Some(editor_width), cx) {
|
||||
snapshot = editor.snapshot(cx);
|
||||
}
|
||||
|
||||
let scroll_height = Pixels::from(snapshot.max_point().row().next_row().0) * line_height;
|
||||
let height = scroll_height
|
||||
.max(line_height)
|
||||
.min(line_height * max_lines as f32);
|
||||
|
||||
Some(size(width, height))
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ async fn parse_commit_messages(
|
||||
.and_then(|remote_url| parse_git_remote_url(provider_registry, remote_url));
|
||||
|
||||
for (oid, message) in messages {
|
||||
let parsed_message = parse_markdown(&message, &languages).await;
|
||||
let parsed_message = parse_markdown(&message, languages).await;
|
||||
|
||||
let permalink = if let Some((provider, git_remote)) = parsed_remote_url.as_ref() {
|
||||
Some(provider.build_commit_permalink(
|
||||
|
||||
@@ -134,7 +134,7 @@ impl Editor {
|
||||
}
|
||||
None => {
|
||||
update_inlay_link_and_hover_points(
|
||||
&snapshot,
|
||||
snapshot,
|
||||
point_for_position,
|
||||
self,
|
||||
modifiers.secondary(),
|
||||
@@ -490,12 +490,12 @@ pub fn show_link_definition(
|
||||
.is_some_and(|d| matches!(d, HoverLink::Url(_)));
|
||||
|
||||
if same_kind {
|
||||
if is_cached && (&hovered_link_state.last_trigger_point == &trigger_point)
|
||||
if is_cached && (hovered_link_state.last_trigger_point == trigger_point)
|
||||
|| hovered_link_state
|
||||
.symbol_range
|
||||
.as_ref()
|
||||
.is_some_and(|symbol_range| {
|
||||
symbol_range.point_within_range(&trigger_point, &snapshot)
|
||||
symbol_range.point_within_range(&trigger_point, snapshot)
|
||||
})
|
||||
{
|
||||
editor.hovered_link_state = Some(hovered_link_state);
|
||||
@@ -596,7 +596,7 @@ pub fn show_link_definition(
|
||||
if let Some((symbol_range, definitions)) = result {
|
||||
hovered_link_state.links = definitions;
|
||||
|
||||
let underline_hovered_link = hovered_link_state.links.len() > 0
|
||||
let underline_hovered_link = !hovered_link_state.links.is_empty()
|
||||
|| hovered_link_state.symbol_range.is_some();
|
||||
|
||||
if underline_hovered_link {
|
||||
@@ -718,7 +718,7 @@ pub(crate) async fn find_file(
|
||||
|
||||
let existing_path = project
|
||||
.update(cx, |project, cx| {
|
||||
project.resolve_existing_file_path(&candidate_file_path, &buffer, cx)
|
||||
project.resolve_existing_file_path(&candidate_file_path, buffer, cx)
|
||||
})
|
||||
.ok()?
|
||||
.await?;
|
||||
@@ -1258,7 +1258,7 @@ mod tests {
|
||||
let variable« »= TestStruct;
|
||||
}
|
||||
"})
|
||||
.get(0)
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let midpoint = cx.update_editor(|editor, cx| {
|
||||
|
||||
@@ -74,7 +74,7 @@ pub fn show_keyboard_hover(editor: &mut Editor, cx: &mut ViewContext<Editor>) ->
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
pub struct InlayHover {
|
||||
@@ -648,7 +648,7 @@ impl HoverState {
|
||||
}
|
||||
}
|
||||
}
|
||||
return hover_popover_is_focused;
|
||||
hover_popover_is_focused
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1445,7 +1445,7 @@ mod tests {
|
||||
let variable« »= TestNewType(TestStruct);
|
||||
}
|
||||
"})
|
||||
.get(0)
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let new_type_hint_part_hover_position = cx.update_editor(|editor, cx| {
|
||||
|
||||
@@ -337,8 +337,8 @@ impl Editor {
|
||||
.offset_to_point(hunk.diff_base_byte_range.start)
|
||||
.row;
|
||||
let diff_end_row = diff_base.offset_to_point(hunk.diff_base_byte_range.end).row;
|
||||
let line_count = diff_end_row - diff_start_row;
|
||||
line_count
|
||||
|
||||
diff_end_row - diff_start_row
|
||||
})?;
|
||||
Some((diff_base_buffer, deleted_text_lines))
|
||||
} else {
|
||||
@@ -358,7 +358,7 @@ impl Editor {
|
||||
|
||||
let block = match hunk.status {
|
||||
DiffHunkStatus::Removed => {
|
||||
self.insert_deleted_text_block(diff_base_buffer, deleted_text_lines, &hunk, cx)
|
||||
self.insert_deleted_text_block(diff_base_buffer, deleted_text_lines, hunk, cx)
|
||||
}
|
||||
DiffHunkStatus::Added => {
|
||||
self.highlight_rows::<DiffRowHighlight>(
|
||||
@@ -376,7 +376,7 @@ impl Editor {
|
||||
false,
|
||||
cx,
|
||||
);
|
||||
self.insert_deleted_text_block(diff_base_buffer, deleted_text_lines, &hunk, cx)
|
||||
self.insert_deleted_text_block(diff_base_buffer, deleted_text_lines, hunk, cx)
|
||||
}
|
||||
};
|
||||
self.expanded_hunks.hunks.insert(
|
||||
@@ -591,7 +591,7 @@ impl Editor {
|
||||
.to_display_point(&snapshot)
|
||||
.row();
|
||||
while let Some(buffer_hunk) = recalculated_hunks.peek() {
|
||||
match diff_hunk_to_display(&buffer_hunk, &snapshot) {
|
||||
match diff_hunk_to_display(buffer_hunk, &snapshot) {
|
||||
DisplayDiffHunk::Folded { display_row } => {
|
||||
recalculated_hunks.next();
|
||||
if !expanded_hunk.folded
|
||||
@@ -710,12 +710,12 @@ fn to_diff_hunk(
|
||||
.multi_buffer_range
|
||||
.start
|
||||
.buffer_id
|
||||
.or_else(|| hovered_hunk.multi_buffer_range.end.buffer_id)?;
|
||||
.or(hovered_hunk.multi_buffer_range.end.buffer_id)?;
|
||||
let buffer_range = hovered_hunk.multi_buffer_range.start.text_anchor
|
||||
..hovered_hunk.multi_buffer_range.end.text_anchor;
|
||||
let point_range = hovered_hunk
|
||||
.multi_buffer_range
|
||||
.to_point(&multi_buffer_snapshot);
|
||||
.to_point(multi_buffer_snapshot);
|
||||
Some(DiffHunk {
|
||||
associated_range: MultiBufferRow(point_range.start.row)
|
||||
..MultiBufferRow(point_range.end.row),
|
||||
|
||||
@@ -466,7 +466,7 @@ impl InlayHintCache {
|
||||
to_insert.push(Inlay::hint(
|
||||
cached_hint_id.id(),
|
||||
anchor,
|
||||
&cached_hint,
|
||||
cached_hint,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -490,7 +490,7 @@ impl InlayHintCache {
|
||||
to_insert.push(Inlay::hint(
|
||||
cached_hint_id.id(),
|
||||
anchor,
|
||||
&maybe_missed_cached_hint,
|
||||
maybe_missed_cached_hint,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -844,7 +844,7 @@ fn new_update_task(
|
||||
.get_mut(&query.excerpt_id)
|
||||
{
|
||||
let buffer_snapshot = excerpt_buffer.read(cx).snapshot();
|
||||
task_ranges.invalidate_range(&buffer_snapshot, &range);
|
||||
task_ranges.invalidate_range(&buffer_snapshot, range);
|
||||
}
|
||||
})
|
||||
.ok()
|
||||
@@ -3424,7 +3424,7 @@ pub mod tests {
|
||||
|
||||
pub fn cached_hint_labels(editor: &Editor) -> Vec<String> {
|
||||
let mut labels = Vec::new();
|
||||
for (_, excerpt_hints) in &editor.inlay_hint_cache().hints {
|
||||
for excerpt_hints in editor.inlay_hint_cache().hints.values() {
|
||||
let excerpt_hints = excerpt_hints.read();
|
||||
for id in &excerpt_hints.ordered_hints {
|
||||
labels.push(excerpt_hints.hints_by_id[id].text());
|
||||
|
||||
+10
-10
@@ -356,7 +356,7 @@ async fn update_editor_from_message(
|
||||
.collect::<Vec<_>>();
|
||||
removed_excerpt_ids.sort_by({
|
||||
let multibuffer = multibuffer.read(cx);
|
||||
move |a, b| a.cmp(&b, &multibuffer)
|
||||
move |a, b| a.cmp(b, &multibuffer)
|
||||
});
|
||||
|
||||
let mut insertions = message.inserted_excerpts.into_iter().peekable();
|
||||
@@ -604,7 +604,7 @@ impl Item for Editor {
|
||||
.and_then(|path| FileIcons::get_icon(path.path.as_ref(), cx))
|
||||
})
|
||||
.flatten()
|
||||
.map(|icon| Icon::from_path(icon))
|
||||
.map(Icon::from_path)
|
||||
}
|
||||
|
||||
fn tab_content(&self, params: TabContentParams, cx: &WindowContext) -> AnyElement {
|
||||
@@ -631,7 +631,7 @@ impl Item for Editor {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(util::truncate_and_trailoff(&description, MAX_TAB_TITLE_LEN))
|
||||
Some(util::truncate_and_trailoff(description, MAX_TAB_TITLE_LEN))
|
||||
});
|
||||
|
||||
h_flex()
|
||||
@@ -829,7 +829,7 @@ impl Item for Editor {
|
||||
let cursor = self.selections.newest_anchor().head();
|
||||
let multibuffer = &self.buffer().read(cx);
|
||||
let (buffer_id, symbols) =
|
||||
multibuffer.symbols_containing(cursor, Some(&variant.syntax()), cx)?;
|
||||
multibuffer.symbols_containing(cursor, Some(variant.syntax()), cx)?;
|
||||
let buffer = multibuffer.buffer(buffer_id)?;
|
||||
|
||||
let buffer = buffer.read(cx);
|
||||
@@ -1154,7 +1154,7 @@ impl SearchableItem for Editor {
|
||||
self.background_highlights
|
||||
.get(&TypeId::of::<BufferSearchHighlights>())
|
||||
.map_or(Vec::new(), |(_color, ranges)| {
|
||||
ranges.iter().map(|range| range.clone()).collect()
|
||||
ranges.iter().cloned().collect()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1254,7 +1254,7 @@ impl SearchableItem for Editor {
|
||||
self.unfold_ranges(matches.to_vec(), false, false, cx);
|
||||
let mut ranges = Vec::new();
|
||||
for m in matches {
|
||||
ranges.push(self.range_for_match(&m))
|
||||
ranges.push(self.range_for_match(m))
|
||||
}
|
||||
self.change_selections(None, cx, |s| s.select_ranges(ranges));
|
||||
}
|
||||
@@ -1335,7 +1335,7 @@ impl SearchableItem for Editor {
|
||||
.cmp(¤t_index_position, &buffer)
|
||||
.is_gt()
|
||||
{
|
||||
count = count - 1
|
||||
count -= 1
|
||||
}
|
||||
|
||||
(current_index + count) % matches.len()
|
||||
@@ -1346,7 +1346,7 @@ impl SearchableItem for Editor {
|
||||
.cmp(¤t_index_position, &buffer)
|
||||
.is_lt()
|
||||
{
|
||||
count = count - 1;
|
||||
count -= 1;
|
||||
}
|
||||
|
||||
if current_index >= count {
|
||||
@@ -1368,7 +1368,7 @@ impl SearchableItem for Editor {
|
||||
.background_highlights
|
||||
.get(&TypeId::of::<SearchWithinRange>())
|
||||
.map_or(vec![], |(_color, ranges)| {
|
||||
ranges.iter().map(|range| range.clone()).collect::<Vec<_>>()
|
||||
ranges.iter().cloned().collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
cx.background_executor().spawn(async move {
|
||||
@@ -1411,7 +1411,7 @@ impl SearchableItem for Editor {
|
||||
if !search_range.is_empty() {
|
||||
ranges.extend(
|
||||
query
|
||||
.search(&search_buffer, Some(search_range.clone()))
|
||||
.search(search_buffer, Some(search_range.clone()))
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|match_range| {
|
||||
|
||||
@@ -73,7 +73,7 @@ pub(super) fn refresh_linked_ranges(this: &mut Editor, cx: &mut ViewContext<Edit
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
let linked_edits_task = project.linked_edit(&buffer, *start, cx);
|
||||
let linked_edits_task = project.linked_edit(buffer, *start, cx);
|
||||
let highlights = move || async move {
|
||||
let edits = linked_edits_task.await.log_err()?;
|
||||
// Find the range containing our current selection.
|
||||
@@ -87,9 +87,7 @@ pub(super) fn refresh_linked_ranges(this: &mut Editor, cx: &mut ViewContext<Edit
|
||||
range.start.to_point(&snapshot) <= start_point
|
||||
&& range.end.to_point(&snapshot) >= end_point
|
||||
});
|
||||
if _current_selection_contains_range.is_none() {
|
||||
return None;
|
||||
}
|
||||
_current_selection_contains_range?;
|
||||
// Now link every range as each-others sibling.
|
||||
let mut siblings: HashMap<Range<text::Anchor>, Vec<_>> = Default::default();
|
||||
let mut insert_sorted_anchor =
|
||||
|
||||
@@ -23,7 +23,7 @@ where
|
||||
editor
|
||||
.selections
|
||||
.disjoint_anchors()
|
||||
.into_iter()
|
||||
.iter()
|
||||
.filter(|selection| selection.start == selection.end)
|
||||
.filter_map(|selection| Some((selection.start.buffer_id?, selection.start)))
|
||||
.filter_map(|(buffer_id, trigger_anchor)| {
|
||||
|
||||
@@ -113,7 +113,7 @@ fn display_ranges<'a>(
|
||||
.disjoint
|
||||
.iter()
|
||||
.chain(pending)
|
||||
.map(move |s| s.start.to_display_point(&display_map)..s.end.to_display_point(&display_map))
|
||||
.map(move |s| s.start.to_display_point(display_map)..s.end.to_display_point(display_map))
|
||||
}
|
||||
|
||||
pub fn deploy_context_menu(
|
||||
|
||||
@@ -416,7 +416,7 @@ pub fn find_preceding_boundary_point(
|
||||
mut is_boundary: impl FnMut(char, char) -> bool,
|
||||
) -> Point {
|
||||
let mut prev_ch = None;
|
||||
let mut offset = from.to_offset(&buffer_snapshot);
|
||||
let mut offset = from.to_offset(buffer_snapshot);
|
||||
|
||||
for ch in buffer_snapshot.reversed_chars_at(offset) {
|
||||
if find_range == FindRange::SingleLine && ch == '\n' {
|
||||
@@ -432,7 +432,7 @@ pub fn find_preceding_boundary_point(
|
||||
prev_ch = Some(ch);
|
||||
}
|
||||
|
||||
offset.to_point(&buffer_snapshot)
|
||||
offset.to_point(buffer_snapshot)
|
||||
}
|
||||
|
||||
/// Scans for a boundary preceding the given start point `from` until a boundary is found,
|
||||
@@ -466,7 +466,7 @@ pub fn find_boundary_point(
|
||||
mut is_boundary: impl FnMut(char, char) -> bool,
|
||||
return_point_before_boundary: bool,
|
||||
) -> DisplayPoint {
|
||||
let mut offset = from.to_offset(&map, Bias::Right);
|
||||
let mut offset = from.to_offset(map, Bias::Right);
|
||||
let mut prev_offset = offset;
|
||||
let mut prev_ch = None;
|
||||
|
||||
@@ -496,7 +496,7 @@ pub fn find_boundary(
|
||||
find_range: FindRange,
|
||||
is_boundary: impl FnMut(char, char) -> bool,
|
||||
) -> DisplayPoint {
|
||||
return find_boundary_point(map, from, find_range, is_boundary, false);
|
||||
find_boundary_point(map, from, find_range, is_boundary, false)
|
||||
}
|
||||
|
||||
pub fn find_boundary_exclusive(
|
||||
@@ -505,7 +505,7 @@ pub fn find_boundary_exclusive(
|
||||
find_range: FindRange,
|
||||
is_boundary: impl FnMut(char, char) -> bool,
|
||||
) -> DisplayPoint {
|
||||
return find_boundary_point(map, from, find_range, is_boundary, true);
|
||||
find_boundary_point(map, from, find_range, is_boundary, true)
|
||||
}
|
||||
|
||||
/// Returns an iterator over the characters following a given offset in the [`DisplaySnapshot`].
|
||||
@@ -517,7 +517,7 @@ pub fn chars_after(
|
||||
) -> impl Iterator<Item = (char, Range<usize>)> + '_ {
|
||||
map.buffer_snapshot.chars_at(offset).map(move |ch| {
|
||||
let before = offset;
|
||||
offset = offset + ch.len_utf8();
|
||||
offset += ch.len_utf8();
|
||||
(ch, before..offset)
|
||||
})
|
||||
}
|
||||
@@ -533,7 +533,7 @@ pub fn chars_before(
|
||||
.reversed_chars_at(offset)
|
||||
.map(move |ch| {
|
||||
let after = offset;
|
||||
offset = offset - ch.len_utf8();
|
||||
offset -= ch.len_utf8();
|
||||
(ch, offset..after)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -220,7 +220,6 @@ impl EditorDb {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gpui;
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_save_and_get_serialized_editor() {
|
||||
|
||||
@@ -19,7 +19,7 @@ fn is_rust_language(language: &Language) -> bool {
|
||||
pub fn apply_related_actions(editor: &View<Editor>, cx: &mut WindowContext) {
|
||||
if editor
|
||||
.update(cx, |e, cx| {
|
||||
find_specific_language_server_in_selection(e, cx, &is_rust_language, RUST_ANALYZER_NAME)
|
||||
find_specific_language_server_in_selection(e, cx, is_rust_language, RUST_ANALYZER_NAME)
|
||||
})
|
||||
.is_some()
|
||||
{
|
||||
@@ -44,9 +44,9 @@ pub fn expand_macro_recursively(
|
||||
|
||||
let Some((trigger_anchor, rust_language, server_to_query, buffer)) =
|
||||
find_specific_language_server_in_selection(
|
||||
&editor,
|
||||
editor,
|
||||
cx,
|
||||
&is_rust_language,
|
||||
is_rust_language,
|
||||
RUST_ANALYZER_NAME,
|
||||
)
|
||||
else {
|
||||
|
||||
@@ -50,7 +50,7 @@ impl ScrollAnchor {
|
||||
scroll_position.y = 0.;
|
||||
} else {
|
||||
let scroll_top = self.anchor.to_display_point(snapshot).row().as_f32();
|
||||
scroll_position.y = scroll_top + scroll_position.y;
|
||||
scroll_position.y += scroll_top;
|
||||
}
|
||||
scroll_position
|
||||
}
|
||||
@@ -224,7 +224,7 @@ impl ScrollManager {
|
||||
};
|
||||
|
||||
let scroll_top_buffer_point =
|
||||
DisplayPoint::new(DisplayRow(scroll_top as u32), 0).to_point(&map);
|
||||
DisplayPoint::new(DisplayRow(scroll_top as u32), 0).to_point(map);
|
||||
let top_anchor = map
|
||||
.buffer_snapshot
|
||||
.anchor_at(scroll_top_buffer_point, Bias::Right);
|
||||
@@ -234,7 +234,7 @@ impl ScrollManager {
|
||||
anchor: top_anchor,
|
||||
offset: point(
|
||||
scroll_position.x.max(0.),
|
||||
scroll_top - top_anchor.to_display_point(&map).row().as_f32(),
|
||||
scroll_top - top_anchor.to_display_point(map).row().as_f32(),
|
||||
),
|
||||
},
|
||||
scroll_top_buffer_point.row,
|
||||
|
||||
@@ -339,7 +339,7 @@ impl SelectionsCollection {
|
||||
let is_empty = positions.start == positions.end;
|
||||
let line_len = display_map.line_len(row);
|
||||
|
||||
let line = display_map.layout_row(row, &text_layout_details);
|
||||
let line = display_map.layout_row(row, text_layout_details);
|
||||
|
||||
let start_col = line.closest_index_for_x(positions.start) as u32;
|
||||
if start_col < line_len || (is_empty && positions.start == line.width) {
|
||||
|
||||
@@ -13,7 +13,7 @@ pub use popover::SignatureHelpPopover;
|
||||
pub use state::SignatureHelpState;
|
||||
|
||||
// Language-specific settings may define quotes as "brackets", so filter them out separately.
|
||||
const QUOTE_PAIRS: [(&'static str, &'static str); 3] = [("'", "'"), ("\"", "\""), ("`", "`")];
|
||||
const QUOTE_PAIRS: [(&str, &str); 3] = [("'", "'"), ("\"", "\""), ("`", "`")];
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum SignatureHelpHiddenBy {
|
||||
@@ -167,10 +167,10 @@ impl Editor {
|
||||
let language = editor.language_at(position, cx);
|
||||
let project = editor.project.clone()?;
|
||||
let (markdown, language_registry) = {
|
||||
project.update(cx, |project, mut cx| {
|
||||
project.update(cx, |project, cx| {
|
||||
let language_registry = project.languages().clone();
|
||||
(
|
||||
project.signature_help(&buffer, buffer_position, &mut cx),
|
||||
project.signature_help(&buffer, buffer_position, cx),
|
||||
language_registry,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -120,8 +120,7 @@ impl EditorTestContext {
|
||||
where
|
||||
F: FnOnce(&Editor, &ViewContext<Editor>) -> T,
|
||||
{
|
||||
self.editor
|
||||
.update(&mut self.cx, |this, cx| read(&this, &cx))
|
||||
self.editor.update(&mut self.cx, |this, cx| read(this, cx))
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
@@ -327,8 +326,8 @@ impl EditorTestContext {
|
||||
.background_highlights
|
||||
.get(&TypeId::of::<Tag>())
|
||||
.map(|h| h.1.clone())
|
||||
.unwrap_or_else(|| Arc::default())
|
||||
.into_iter()
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|range| range.to_offset(&snapshot.buffer_snapshot))
|
||||
.collect()
|
||||
});
|
||||
@@ -424,6 +423,12 @@ pub struct AssertionContextManager {
|
||||
contexts: Arc<RwLock<BTreeMap<usize, String>>>,
|
||||
}
|
||||
|
||||
impl Default for AssertionContextManager {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl AssertionContextManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user