on master help sign in
Fix unused `Result` warnings in helix-term.
commit0b2d51cf5a840b6e34d360b34c116bb981b5058e authorNathan Vegdahl <cessen@cessen.com> dateThu 1 Jul 2021, 12:08 (5 years ago) parentefa3389
3 files changed+12−7
helix-term/src/application.rs+7−4 helix-term/src/commands.rs+4−2 helix-term/src/compositor.rs+1−1
helix-term/src/application.rs+7−4
@@ -447,17 +447,20 @@ impl Application {
447447 // Exit the alternate screen and disable raw mode before panicking
448448 let hook = std::panic::take_hook();
449449 std::panic::set_hook(Box::new(move |info| {
450− execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
451− terminal::disable_raw_mode();
450+ // We can't handle errors properly inside this closure. And it's
451+ // probably not a good idea to `unwrap()` inside a panic handler.
452+ // So we just ignore the `Result`s.
453+ let _ = execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
454+ let _ = terminal::disable_raw_mode();
452455 hook(info);
453456 }));
454457
455458 self.event_loop().await;
456459
457− self.editor.close_language_servers(None).await;
460+ self.editor.close_language_servers(None).await?;
458461
459462 // reset cursor shape
460− write!(stdout, "\x1B[2 q");
463+ write!(stdout, "\x1B[2 q")?;
461464
462465 execute!(stdout, terminal::LeaveAlternateScreen)?;
463466
helix-term/src/commands.rs+4−2
@@ -1135,7 +1135,7 @@ mod cmd {
11351135 match args.get(0) {
11361136 Some(path) => {
11371137 // TODO: handle error
1138− cx.editor.open(path.into(), Action::Replace);
1138+ let _ = cx.editor.open(path.into(), Action::Replace);
11391139 }
11401140 None => {
11411141 cx.editor.set_error("wrong argument count".to_string());
@@ -1367,7 +1367,9 @@ mod cmd {
13671367 errors.push_str("cannot write a buffer without a filename\n");
13681368 continue;
13691369 }
1370− helix_lsp::block_on(tokio::spawn(doc.save()));
1370+
1371+ // TODO: handle error.
1372+ let _ = helix_lsp::block_on(tokio::spawn(doc.save()));
13711373 }
13721374 editor.set_error(errors);
13731375
helix-term/src/compositor.rs+1−1
@@ -141,7 +141,7 @@ impl Compositor {
141141 let (pos, kind) = self.cursor(area, cx.editor);
142142 let pos = pos.map(|pos| (pos.col as u16, pos.row as u16));
143143
144− self.terminal.draw(pos, kind);
144+ self.terminal.draw(pos, kind).unwrap();
145145 }
146146
147147 pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {