diff options
Diffstat (limited to '')
| -rw-r--r-- | src/line.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/line.rs b/src/line.rs index 613dffe..2b6c894 100644 --- a/src/line.rs +++ b/src/line.rs | |||
| @@ -58,12 +58,14 @@ impl Editor { | |||
| 58 | draw(prompt, &buffer, cursor, &mut state)?; | 58 | draw(prompt, &buffer, cursor, &mut state)?; |
| 59 | } | 59 | } |
| 60 | Event::Resize(_, _) => { | 60 | Event::Resize(_, _) => { |
| 61 | // The terminal reflowed the block we were tracking, so the | 61 | // The terminal has already reflowed the block and moved the |
| 62 | // old row count is meaningless. Start a fresh prompt line | 62 | // caret with it, so drawing again here would duplicate the |
| 63 | // rather than risk erasing output above it. | 63 | // prompt. Recompute only where the caret now sits relative |
| 64 | println!(); | 64 | // to the block; the next redraw moves up from there. |
| 65 | state = DrawState::default(); | 65 | let width = terminal_width(); |
| 66 | draw(prompt, &buffer, cursor, &mut state)?; | 66 | let (cursor_row, _) = layout(prompt, &buffer, cursor, width); |
| 67 | state.cursor_row = cursor_row; | ||
| 68 | state.rows = layout(prompt, &buffer, buffer.len(), width).0 + 1; | ||
| 67 | } | 69 | } |
| 68 | Event::Key(key) if key.kind == KeyEventKind::Press => { | 70 | Event::Key(key) if key.kind == KeyEventKind::Press => { |
| 69 | match handle_key(key, &mut buffer, &mut cursor, self) { | 71 | match handle_key(key, &mut buffer, &mut cursor, self) { |
