One big cleanup pass of clippy lints
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
e7540d2833
commit
8ba2f77148
138 changed files with 1328 additions and 1366 deletions
|
@ -126,10 +126,10 @@ fn motion(motion: Motion, cx: &mut MutableAppContext) {
|
|||
impl Motion {
|
||||
pub fn linewise(self) -> bool {
|
||||
use Motion::*;
|
||||
match self {
|
||||
Down | Up | StartOfDocument | EndOfDocument | CurrentLine => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
self,
|
||||
Down | Up | StartOfDocument | EndOfDocument | CurrentLine
|
||||
)
|
||||
}
|
||||
|
||||
pub fn inclusive(self) -> bool {
|
||||
|
@ -282,8 +282,7 @@ fn next_word_end(
|
|||
// we have backtraced already
|
||||
if !map
|
||||
.chars_at(point)
|
||||
.skip(1)
|
||||
.next()
|
||||
.nth(1)
|
||||
.map(|c| c == '\n')
|
||||
.unwrap_or(true)
|
||||
{
|
||||
|
|
|
@ -254,7 +254,7 @@ fn paste(_: &mut Workspace, _: &Paste, cx: &mut ViewContext<Workspace>) {
|
|||
}
|
||||
// Drop selection at the start of the next line
|
||||
let selection_point = Point::new(point.row + 1, 0);
|
||||
new_selections.push(selection.map(|_| selection_point.clone()));
|
||||
new_selections.push(selection.map(|_| selection_point));
|
||||
point
|
||||
} else {
|
||||
let mut point = selection.end;
|
||||
|
|
|
@ -28,7 +28,7 @@ pub fn change_over(vim: &mut Vim, motion: Motion, cx: &mut MutableAppContext) {
|
|||
});
|
||||
});
|
||||
copy_selections_content(editor, motion.linewise(), cx);
|
||||
editor.insert(&"", cx);
|
||||
editor.insert("", cx);
|
||||
});
|
||||
});
|
||||
vim.switch_mode(Mode::Insert, false, cx)
|
||||
|
@ -67,7 +67,7 @@ fn change_word(
|
|||
});
|
||||
});
|
||||
copy_selections_content(editor, false, cx);
|
||||
editor.insert(&"", cx);
|
||||
editor.insert("", cx);
|
||||
});
|
||||
});
|
||||
vim.switch_mode(Mode::Insert, false, cx);
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn delete_over(vim: &mut Vim, motion: Motion, cx: &mut MutableAppContext) {
|
|||
});
|
||||
});
|
||||
copy_selections_content(editor, motion.linewise(), cx);
|
||||
editor.insert(&"", cx);
|
||||
editor.insert("", cx);
|
||||
|
||||
// Fixup cursor position after the deletion
|
||||
editor.set_clip_at_line_ends(true, cx);
|
||||
|
|
|
@ -54,10 +54,7 @@ impl VimState {
|
|||
}
|
||||
|
||||
pub fn clip_at_line_end(&self) -> bool {
|
||||
match self.mode {
|
||||
Mode::Insert | Mode::Visual { .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self.mode, Mode::Insert | Mode::Visual { .. })
|
||||
}
|
||||
|
||||
pub fn empty_selections_only(&self) -> bool {
|
||||
|
@ -99,6 +96,6 @@ impl Operator {
|
|||
|
||||
context
|
||||
.map
|
||||
.insert("vim_operator".to_string(), operator_context.to_string());
|
||||
.insert("vim_operator".to_string(), operator_context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ impl<'a> VimTestContext<'a> {
|
|||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.active_pane().update(cx, |pane, cx| {
|
||||
pane.toolbar().update(cx, |toolbar, cx| {
|
||||
let buffer_search_bar = cx.add_view(|cx| BufferSearchBar::new(cx));
|
||||
let buffer_search_bar = cx.add_view(BufferSearchBar::new);
|
||||
toolbar.add_item(buffer_search_bar, cx);
|
||||
let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
|
||||
toolbar.add_item(project_search_bar, cx);
|
||||
|
|
|
@ -103,7 +103,7 @@ pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspac
|
|||
s.move_with(|map, selection| {
|
||||
if line_mode {
|
||||
original_columns
|
||||
.insert(selection.id, selection.head().to_point(&map).column);
|
||||
.insert(selection.id, selection.head().to_point(map).column);
|
||||
} else if !selection.reversed {
|
||||
// Head is at the end of the selection. Adjust the end position to
|
||||
// to include the character under the cursor.
|
||||
|
@ -230,15 +230,15 @@ pub fn paste(_: &mut Workspace, _: &VisualPaste, cx: &mut ViewContext<Workspace>
|
|||
|
||||
let new_position = if linewise {
|
||||
edits.push((range.start..range.start, "\n"));
|
||||
let mut new_position = range.start.clone();
|
||||
let mut new_position = range.start;
|
||||
new_position.column = 0;
|
||||
new_position.row += 1;
|
||||
new_position
|
||||
} else {
|
||||
range.start.clone()
|
||||
range.start
|
||||
};
|
||||
|
||||
new_selections.push(selection.map(|_| new_position.clone()));
|
||||
new_selections.push(selection.map(|_| new_position));
|
||||
|
||||
if linewise && to_insert.ends_with('\n') {
|
||||
edits.push((
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue