diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-11 18:53:20 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-11 18:53:20 -0800 |
| commit | 965c0aa3446da87b84c5db656b1cc3ce6e4a691b (patch) | |
| tree | f09014de26e7d7205888339d3642a407239eb8b8 /src/main.rs | |
| parent | f842e04c4b5579342c1e74b41e867d02e1727f3d (diff) | |
| download | editor-965c0aa3446da87b84c5db656b1cc3ce6e4a691b.tar.zst | |
Do a little more to handle errors.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index c5ea852..7b9b477 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,7 +155,12 @@ impl State { let line = self.line(); write!(stdout(), "\x1b[{}H\x1b[K", self.cursor_row + 1)?; line.slice(0, self.line_offset).print(&mut stdout())?; - let (_, col) = term::cursor_pos(stdin)?; + let Ok((_, col)) = term::cursor_pos(stdin) else { + let _ = line + .slice(self.line_offset, line.len()) + .print(&mut stdout()); + return Err(Box::from("cursor_pos")); + }; if col == size.ws_col - 1 { self.cursor_col = col - 1; write!(stdout(), "\x1b[D\x1b[K")?; @@ -535,6 +540,7 @@ fn edit(file: &OsStr) -> Result<(), String> { }; let Ok(ok) = state.keypress(&mut stdin, key) else { state.need_repaint_screen = true; + let _ = stdout().flush(); continue; }; // I miss "do while" so much... |
