Fix clippy warnings.

pull/2/head
Blaž Hrastnik 4 years ago
parent e39bd211d1
commit 4189c362b2

@ -77,7 +77,7 @@ impl Editor {
// clear with background color // clear with background color
self.surface self.surface
.set_style(area, view.theme.get("ui.background").into()); .set_style(area, view.theme.get("ui.background"));
let offset = 5 + 1; // 5 linenr + 1 gutter let offset = 5 + 1; // 5 linenr + 1 gutter
let viewport = Rect::new(offset, 0, self.size.0, self.size.1 - 1); // - 1 for statusline let viewport = Rect::new(offset, 0, self.size.0, self.size.1 - 1); // - 1 for statusline
@ -143,16 +143,14 @@ impl Editor {
// TODO: filter out spans out of viewport for now.. // TODO: filter out spans out of viewport for now..
let start = view.state.doc().byte_to_char(start); let start = view.state.doc().byte_to_char(start);
let end = view.state.doc().byte_to_char(end); let end = view.state.doc().byte_to_char(end); // <-- index 744, len 743
let text = view.state.doc().slice(start..end); let text = view.state.doc().slice(start..end);
use helix_core::graphemes::{grapheme_width, RopeGraphemes}; use helix_core::graphemes::{grapheme_width, RopeGraphemes};
let style = match spans.first() { let style = match spans.first() {
Some(span) => { Some(span) => view.theme.get(view.theme.scopes()[span.0].as_str()),
view.theme.get(view.theme.scopes()[span.0].as_str()).into()
}
None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
}; };
@ -209,7 +207,7 @@ impl Editor {
} }
} }
let style: Style = view.theme.get("ui.linenr").into(); let style: Style = view.theme.get("ui.linenr");
for (i, line) in (view.first_line..(last_line as u16)).enumerate() { for (i, line) in (view.first_line..(last_line as u16)).enumerate() {
self.surface self.surface
.set_stringn(0, line, format!("{:>5}", i + 1), 5, style); .set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
@ -248,7 +246,7 @@ impl Editor {
}; };
self.surface.set_style( self.surface.set_style(
Rect::new(0, self.size.1 - 1, self.size.0, 1), Rect::new(0, self.size.1 - 1, self.size.0, 1),
view.theme.get("ui.statusline").into(), view.theme.get("ui.statusline"),
); );
// TODO: unfocused one with different color // TODO: unfocused one with different color
let text_color = Style::default().fg(Color::Rgb(219, 191, 239)); // lilac let text_color = Style::default().fg(Color::Rgb(219, 191, 239)); // lilac
@ -325,15 +323,13 @@ impl Editor {
if let Some(command) = keymap[&Mode::Insert].get(&keys) { if let Some(command) = keymap[&Mode::Insert].get(&keys) {
// TODO: handle count other than 1 // TODO: handle count other than 1
command(view, 1); command(view, 1);
} else { } else if let KeyEvent {
if let KeyEvent {
code: KeyCode::Char(c), code: KeyCode::Char(c),
.. ..
} = event } = event
{ {
commands::insert_char(view, c); commands::insert_char(view, c);
} }
}
view.ensure_cursor_in_view(); view.ensure_cursor_in_view();
self.render(); self.render();

Loading…
Cancel
Save