Skip to content

Commit

Permalink
fix(code): use terminal.clear() to refresh terminal after exiting vim…
Browse files Browse the repository at this point in the history
…, update anchors

Signed-off-by: Deep Panchal <[email protected]>
  • Loading branch information
deepanchal committed Jul 1, 2024
1 parent 883d87b commit 5db9906
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/how-to-spawn-vim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ fn main() -> Result<()> {
_ => None,
};

// ANCHOR: action-handler
if let Some(action) = action {
match action {
Action::Quit => break,
// ANCHOR: action-handler_EditFile
Action::EditFile => {
stdout().execute(LeaveAlternateScreen)?;
disable_raw_mode()?;
Expand All @@ -65,12 +65,12 @@ fn main() -> Result<()> {
Command::new("vim").arg("/tmp/a.txt").status()?;
stdout().execute(EnterAlternateScreen)?;
enable_raw_mode()?;
// re-init tui
terminal = ratatui::Terminal::new(CrosstermBackend::new(stdout()))?;
// Clear the terminal and force a full redraw on the next draw call.
terminal.clear()?;
}
// ANCHOR_END: action-handler_EditFile
}
}
// ANCHOR: action-handler
}
}
}
Expand Down

0 comments on commit 5db9906

Please sign in to comment.