mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Restore the cursor shape when reedline exits (#574)
This commit is contained in:
parent
3b60811f57
commit
86beb8793e
@ -33,9 +33,10 @@ use {
|
||||
PromptHistorySearch, ReedlineMenu, Signal, UndoBehavior, ValidationResult, Validator,
|
||||
},
|
||||
crossterm::{
|
||||
cursor::{SetCursorStyle, Show},
|
||||
event,
|
||||
event::{Event, KeyCode, KeyEvent, KeyModifiers},
|
||||
terminal, Result,
|
||||
terminal, QueueableCommand, Result,
|
||||
},
|
||||
std::{fs::File, io, io::Write, process::Command, time::Duration, time::SystemTime},
|
||||
};
|
||||
@ -147,6 +148,14 @@ struct BufferEditor {
|
||||
|
||||
impl Drop for Reedline {
|
||||
fn drop(&mut self) {
|
||||
if self.cursor_shapes.is_some() {
|
||||
let _ignore = terminal::enable_raw_mode();
|
||||
let mut stdout = std::io::stdout();
|
||||
let _ignore = stdout.queue(SetCursorStyle::DefaultUserShape);
|
||||
let _ignore = stdout.queue(Show);
|
||||
let _ignore = stdout.flush();
|
||||
}
|
||||
|
||||
// Ensures that the terminal is in a good state if we panic semigracefully
|
||||
// Calling `disable_raw_mode()` twice is fine with Linux
|
||||
let _ignore = terminal::disable_raw_mode();
|
||||
|
Loading…
Reference in New Issue
Block a user