aboutsummaryrefslogtreecommitdiff
path: root/helix-view
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-view
parent15c9a33ebcc18f6abf983785032ffc9762c89203 (diff)
clippy lint
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/document.rs8
-rw-r--r--helix-view/src/editor.rs1
-rw-r--r--helix-view/src/tree.rs19
3 files changed, 12 insertions, 16 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 93b5e854..d63e8591 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -242,7 +242,7 @@ impl Document {
});
}
- let success = self._apply(&transaction, view_id);
+ let success = self._apply(transaction, view_id);
self.modified = true;
// TODO: be smarter about modified by keeping track of saved version instead. That way if
@@ -342,8 +342,7 @@ impl Document {
self.language
.as_ref()
.and_then(|config| config.indent.as_ref())
- .map(|config| config.tab_width)
- .unwrap_or(4) // fallback to 4 columns
+ .map_or(4, |config| config.tab_width) // fallback to 4 columns
}
/// Returns a string containing a single level of indentation.
@@ -351,8 +350,7 @@ impl Document {
self.language
.as_ref()
.and_then(|config| config.indent.as_ref())
- .map(|config| config.unit.as_str())
- .unwrap_or(" ") // fallback to 2 spaces
+ .map_or(" ", |config| config.unit.as_str()) // fallback to 2 spaces
// " ".repeat(TAB_WIDTH)
}
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index f74bbb13..b2408eb9 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -16,6 +16,7 @@ pub struct Editor {
pub executor: &'static smol::Executor<'static>,
}
+#[derive(Copy, Clone)]
pub enum Action {
Replace,
HorizontalSplit,
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index f7ef7806..5fed2d5a 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -29,14 +29,14 @@ pub enum Content {
impl Node {
pub fn container(layout: Layout) -> Self {
- Node {
+ Self {
parent: ViewId::default(),
content: Content::Container(Box::new(Container::new(layout))),
}
}
pub fn view(view: View) -> Self {
- Node {
+ Self {
parent: ViewId::default(),
content: Content::View(Box::new(view)),
}
@@ -414,15 +414,12 @@ impl Tree {
let mut iter = iter.skip_while(|&(key, _view)| key != self.focus);
iter.next(); // take the focused value
- match iter.next() {
- Some((key, _)) => {
- self.focus = key;
- }
- None => {
- // extremely crude, take the first item again
- let (key, _) = self.traverse().next().unwrap();
- self.focus = key;
- }
+ if let Some((key, _)) = iter.next() {
+ self.focus = key;
+ } else {
+ // extremely crude, take the first item again
+ let (key, _) = self.traverse().next().unwrap();
+ self.focus = key;
}
}
}