on master help sign in
Fix unused `Result` warnings in helix-term.
0b2d51cNathan Vegdahl
helix-term/src/application.rs+7−4
@@ -447,17 +447,20 @@ impl Application {
447 // Exit the alternate screen and disable raw mode before panicking
447 // Exit the alternate screen and disable raw mode before panicking
448 let hook = std::panic::take_hook();
448 let hook = std::panic::take_hook();
449 std::panic::set_hook(Box::new(move |info| {
449 std::panic::set_hook(Box::new(move |info| {
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.
450− execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
453+ let _ = execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
451− terminal::disable_raw_mode();
454+ let _ = terminal::disable_raw_mode();
452 hook(info);
455 hook(info);
453 }));
456 }));
454
457
455 self.event_loop().await;
458 self.event_loop().await;
456
459
457− self.editor.close_language_servers(None).await;
460+ self.editor.close_language_servers(None).await?;
458
461
459 // reset cursor shape
462 // reset cursor shape
460− write!(stdout, "\x1B[2 q");
463+ write!(stdout, "\x1B[2 q")?;
461
464
462 execute!(stdout, terminal::LeaveAlternateScreen)?;
465 execute!(stdout, terminal::LeaveAlternateScreen)?;
463
466
helix-term/src/commands.rs+4−2
@@ -1135,7 +1135,7 @@ mod cmd {
1135 match args.get(0) {
1135 match args.get(0) {
1136 Some(path) => {
1136 Some(path) => {
1137 // TODO: handle error
1137 // TODO: handle error
1138− cx.editor.open(path.into(), Action::Replace);
1138+ let _ = cx.editor.open(path.into(), Action::Replace);
1139 }
1139 }
1140 None => {
1140 None => {
1141 cx.editor.set_error("wrong argument count".to_string());
1141 cx.editor.set_error("wrong argument count".to_string());
@@ -1367,7 +1367,9 @@ mod cmd {
1367 errors.push_str("cannot write a buffer without a filename\n");
1367 errors.push_str("cannot write a buffer without a filename\n");
1368 continue;
1368 continue;
1369 }
1369 }
1370+
1371+ // TODO: handle error.
1370− helix_lsp::block_on(tokio::spawn(doc.save()));
1372+ let _ = helix_lsp::block_on(tokio::spawn(doc.save()));
1371 }
1373 }
1372 editor.set_error(errors);
1374 editor.set_error(errors);
1373
1375
helix-term/src/compositor.rs+1−1
@@ -141,7 +141,7 @@ impl Compositor {
141 let (pos, kind) = self.cursor(area, cx.editor);
141 let (pos, kind) = self.cursor(area, cx.editor);
142 let pos = pos.map(|pos| (pos.col as u16, pos.row as u16));
142 let pos = pos.map(|pos| (pos.col as u16, pos.row as u16));
143
143
144− self.terminal.draw(pos, kind);
144+ self.terminal.draw(pos, kind).unwrap();
145 }
145 }
146
146
147 pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
147 pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {