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:
+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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user