leave alternate screen when going into external editor (fixes #152)

This commit is contained in:
Stephan 2020-06-29 10:27:16 +02:00
parent 80f98d6b6d
commit ce4f3af767

View file

@ -2,11 +2,11 @@ use super::{
textinput::TextInputComponent, visibility_blocking,
CommandBlocking, CommandInfo, Component, DrawableComponent,
};
use crate::strings::COMMIT_EDITOR_MSG;
use crate::{
get_app_config_path, keys,
queue::{InternalEvent, NeedsUpdate, Queue},
strings,
strings::COMMIT_EDITOR_MSG,
ui::style::SharedTheme,
};
use anyhow::{anyhow, Result};
@ -14,10 +14,15 @@ use asyncgit::{
sync::{self, CommitId},
CWD,
};
use crossterm::event::Event;
use crossterm::{
event::Event,
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand,
};
use scopeguard::defer;
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::io::{self, Read, Write};
use std::path::PathBuf;
use std::process::Command;
use strings::commands;
@ -150,6 +155,12 @@ impl CommitComponent {
anyhow!("unable to read editor command")
})?;
io::stdout().execute(LeaveAlternateScreen)?;
defer! {
io::stdout().execute(EnterAlternateScreen).expect("failed to reset terminal");
}
Command::new(command)
.args(editor)
.status()