aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-31 14:42:16 +0000
committerBlaž Hrastnik2021-03-31 14:42:16 +0000
commitceea5eacd814c5bbd8c6789610c87a882e3d72cf (patch)
tree1b8aef96c10764e761539b8f6fb15abc78f07a61 /helix-term/src/ui
parent15c9a33ebcc18f6abf983785032ffc9762c89203 (diff)
clippy lint
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs6
-rw-r--r--helix-term/src/ui/menu.rs4
-rw-r--r--helix-term/src/ui/mod.rs5
-rw-r--r--helix-term/src/ui/prompt.rs9
4 files changed, 8 insertions, 16 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 7ceeb6ca..d0822500 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -58,13 +58,13 @@ impl EditorView {
viewport.width - OFFSET,
viewport.height.saturating_sub(1),
); // - 1 for statusline
- self.render_buffer(&doc, view, area, surface, theme, is_focused);
+ self.render_buffer(doc, view, area, surface, theme, is_focused);
// clear with background color
// TODO: this seems to prevent setting style later
// surface.set_style(viewport, theme.get("ui.background"));
- self.render_diagnostics(&doc, view, area, surface, theme, is_focused);
+ self.render_diagnostics(doc, view, area, surface, theme, is_focused);
let area = Rect::new(
viewport.x,
@@ -72,7 +72,7 @@ impl EditorView {
viewport.width,
1,
);
- self.render_statusline(&doc, area, surface, theme, is_focused);
+ self.render_statusline(doc, area, surface, theme, is_focused);
// render status
if let Some(status_msg) = &self.status_msg {
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 5c3ff654..fbd25a6d 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -90,13 +90,13 @@ impl<T> Menu<T> {
pub fn move_up(&mut self) {
// TODO: wrap around to end
- let pos = self.cursor.map(|i| i.saturating_sub(1)).unwrap_or(0) % self.options.len();
+ let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.options.len();
self.cursor = Some(pos);
self.adjust_scroll();
}
pub fn move_down(&mut self) {
- let pos = self.cursor.map(|i| i + 1).unwrap_or(0) % self.options.len();
+ let pos = self.cursor.map_or(0, |i| i + 1) % self.options.len();
self.cursor = Some(pos);
self.adjust_scroll();
}
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 341a30e0..479e684a 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -149,10 +149,7 @@ pub mod completers {
.build()
.filter_map(|file| {
file.ok().map(|entry| {
- let is_dir = entry
- .file_type()
- .map(|entry| entry.is_dir())
- .unwrap_or(false);
+ let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
let mut path = entry.path().strip_prefix(&dir).unwrap().to_path_buf();
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index c61f0bd1..3588853e 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -81,8 +81,7 @@ impl Prompt {
if self.completion.is_empty() {
return;
}
- let index =
- self.completion_selection_index.map(|i| i + 1).unwrap_or(0) % self.completion.len();
+ let index = self.completion_selection_index.map_or(0, |i| i + 1) % self.completion.len();
self.completion_selection_index = Some(index);
let (range, item) = &self.completion[index];
@@ -183,11 +182,7 @@ impl Component for Prompt {
// char or shift char
KeyEvent {
code: KeyCode::Char(c),
- modifiers: KeyModifiers::NONE,
- }
- | KeyEvent {
- code: KeyCode::Char(c),
- modifiers: KeyModifiers::SHIFT,
+ modifiers: KeyModifiers::NONE | KeyModifiers::SHIFT,
} => {
self.insert_char(c);
(self.callback_fn)(cx.editor, &self.line, PromptEvent::Update);