resolve all lints, update MSRV
This commit is contained in:
parent
166b59f560
commit
f05a69a9d9
18 changed files with 251 additions and 283 deletions
|
|
@ -209,6 +209,9 @@ impl<'syntax_system, 'buffer> ViEditor<'syntax_system, 'buffer> {
|
|||
}
|
||||
|
||||
/// Load text from a file, and also set syntax to the best option
|
||||
///
|
||||
/// ## Errors
|
||||
/// Returns an `io::Error` if reading the file fails
|
||||
#[cfg(feature = "std")]
|
||||
pub fn load_text<P: AsRef<std::path::Path>>(
|
||||
&mut self,
|
||||
|
|
@ -517,7 +520,7 @@ impl<'syntax_system, 'buffer> ViEditor<'syntax_system, 'buffer> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer> {
|
||||
impl<'buffer> Edit<'buffer> for ViEditor<'_, 'buffer> {
|
||||
fn buffer_ref(&self) -> &BufferRef<'buffer> {
|
||||
self.editor.buffer_ref()
|
||||
}
|
||||
|
|
@ -646,10 +649,7 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
}
|
||||
};
|
||||
|
||||
let has_selection = match editor.selection() {
|
||||
Selection::None => false,
|
||||
_ => true,
|
||||
};
|
||||
let has_selection = !matches!(editor.selection(), Selection::None);
|
||||
|
||||
self.parser.parse(key, has_selection, |event| {
|
||||
log::debug!(" Event {:?}", event);
|
||||
|
|
@ -778,17 +778,14 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
TextObject::DoubleQuotes => select_in(editor, '"', '"', include),
|
||||
TextObject::Parentheses => select_in(editor, '(', ')', include),
|
||||
TextObject::Search { forwards } => {
|
||||
match &self.search_opt {
|
||||
Some((value, _)) => {
|
||||
if search(editor, value, forwards) {
|
||||
let mut cursor = editor.cursor();
|
||||
editor.set_selection(Selection::Normal(cursor));
|
||||
//TODO: traverse lines if necessary
|
||||
cursor.index += value.len();
|
||||
editor.set_cursor(cursor);
|
||||
}
|
||||
if let Some((value, _)) = &self.search_opt {
|
||||
if search(editor, value, forwards) {
|
||||
let mut cursor = editor.cursor();
|
||||
editor.set_selection(Selection::Normal(cursor));
|
||||
//TODO: traverse lines if necessary
|
||||
cursor.index += value.len();
|
||||
editor.set_cursor(cursor);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
TextObject::SingleQuotes => select_in(editor, '\'', '\'', include),
|
||||
|
|
@ -880,15 +877,11 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
editor.with_buffer(|buffer| {
|
||||
let text = buffer.lines[cursor.line].text();
|
||||
if cursor.index < text.len() {
|
||||
match text[cursor.index..]
|
||||
if let Some((i, _)) = text[cursor.index..]
|
||||
.char_indices()
|
||||
.filter(|&(i, c)| i > 0 && c == find_c)
|
||||
.next()
|
||||
.find(|&(i, c)| i > 0 && c == find_c)
|
||||
{
|
||||
Some((i, _)) => {
|
||||
cursor.index += i;
|
||||
}
|
||||
None => {}
|
||||
cursor.index += i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -986,15 +979,11 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
editor.with_buffer(|buffer| {
|
||||
let text = buffer.lines[cursor.line].text();
|
||||
if cursor.index > 0 {
|
||||
match text[..cursor.index]
|
||||
if let Some((i, _)) = text[..cursor.index]
|
||||
.char_indices()
|
||||
.filter(|&(_, c)| c == find_c)
|
||||
.last()
|
||||
.rfind(|&(_, c)| c == find_c)
|
||||
{
|
||||
Some((i, _)) => {
|
||||
cursor.index = i;
|
||||
}
|
||||
None => {}
|
||||
cursor.index = i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1006,7 +995,7 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
editor.with_buffer(|buffer| {
|
||||
let text = buffer.lines[cursor.line].text();
|
||||
if cursor.index > 0 {
|
||||
match text[..cursor.index]
|
||||
if let Some(i) = text[..cursor.index]
|
||||
.char_indices()
|
||||
.filter_map(|(i, c)| {
|
||||
if c == find_c {
|
||||
|
|
@ -1019,10 +1008,7 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
})
|
||||
.last()
|
||||
{
|
||||
Some(i) => {
|
||||
cursor.index = i;
|
||||
}
|
||||
None => {}
|
||||
cursor.index = i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1132,16 +1118,12 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
//TODO: is this efficient?
|
||||
let action_opt = editor.with_buffer(|buffer| {
|
||||
let mut layout_runs = buffer.layout_runs();
|
||||
if let Some(first) = layout_runs.next() {
|
||||
if let Some(last) = layout_runs.last() {
|
||||
Some(Action::Motion(Motion::GotoLine(
|
||||
(last.line_i + first.line_i) / 2,
|
||||
)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
||||
match (layout_runs.next(), layout_runs.last()) {
|
||||
(Some(first), Some(last)) => Some(Action::Motion(
|
||||
Motion::GotoLine((last.line_i + first.line_i) / 2),
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
match action_opt {
|
||||
|
|
@ -1167,10 +1149,11 @@ impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer
|
|||
}
|
||||
}
|
||||
|
||||
impl<'font_system, 'syntax_system, 'buffer>
|
||||
BorrowedWithFontSystem<'font_system, ViEditor<'syntax_system, 'buffer>>
|
||||
{
|
||||
impl BorrowedWithFontSystem<'_, ViEditor<'_, '_>> {
|
||||
/// Load text from a file, and also set syntax to the best option
|
||||
///
|
||||
/// ## Errors
|
||||
/// Returns an `io::Error` if reading the file fails
|
||||
#[cfg(feature = "std")]
|
||||
pub fn load_text<P: AsRef<std::path::Path>>(
|
||||
&mut self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue